Skip to content

Cache certificate_based_clusters ff Feature.enabled? per request

What does this MR do and why?

On 15.0 we want to add ~4.4k actors to the certificate_based_clusters_ff. We've opened an issue to discuss how to viabilize this. One of the actions we've decided to take, is to cache the results of running Feature.enabled? for a specific GitLab namespace for the time of a request. We do this just in case we're executing it more than once on the same request. This is necessary as Flipper re-evaluates the Redis key every time we call Feature.enabled?.

In other words, Flipper already caches fetching the Redis key. But for such a big key, we should also cache checking the key in memory.

So we're wrapping these calls like the following:

::Gitlab::SafeRequestStore.fetch("certificate_based_clusters:...") do
  Feature.enabled?(:certificate_based_clusters, ...)
end

How to set up and validate locally

This should validate that the FF still work as it should:

  1. Have created a group and a user project.
  2. On rails c: Feature.remove(:certificate_based_clusters). This will guarantee that the FF is valuable from the default yaml file.
  3. Go to "Menu -> Admin" and check that you can see the "Kubernetes" left menu button.
  4. Go to your group and check that you can see the "Kubernetes" left menu button.
  5. Go to your project, click on the left menu button "Infrastructure -> Kubernetes clusters", then check on the blue button on the top right corner, that the button can be expanded and show the following clickable option "Create a cluster (certificate - deprecated)"
  6. Disable the FF globally Feature.disable(:certificate_based_clusters)
  7. Do all the former steps but now check that:
    • The admin page does not show "kubernetes" left menu button anymore.
    • The Group does not show "kubernetes" left menu button anymore. And the page for the groups clusters returns 404, if you had it open.
    • The project clusters page don't show the option anymore to create clusters for the certificate - deprecated options.
  8. Enable the FF just for your group: Feature.enable(:certificate_based_clusters, group)
    • check that the "kubernetes" left side menu button is back for it, and instance and project are still disabled.
  9. Enable the FF just for the user project and check that the button to add certificate - deprecated clusters shows once more, but the admin page still does not show the "kubernetes" left side menu button. Feature.enable(:certificate_based_clusters, project.namespace)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by João Alexandre Cunha

Merge request reports