Skip to content

PoC Generalize Feature Flag system and implement unleash adapter

Shinya Maeda requested to merge implement-unleash-client into master

What does this MR do?

This MR is PoC for https://gitlab.com/gitlab-org/release/framework/issues/32.

This MR accomplishes the following things:

  • Generalize the Feature class. Currently, it heavily depends on Flipper implementation thus it's very hard to extend for the other FF tools, such as Unleash. We create adapters in FeatureFlag::Adapters domain to make the Feature class compatible with any adapters. The system chooses one of the adapters always and keeps using it until the configuration file is changed.
  • Unleash configuration is defined in gitlab.yml/gitlab.rb. This allows us to turn on Unleash-FF on any environments flexibly. You can start using it in local environment, even today.
  • Initializing Unleash clients at the initializers/unleash.rb (for Unicorn) or puma.rb (for Puma). This is the same initialization approach written in official guideline. https://github.com/Unleash/unleash-client-ruby
  • If unleash is disabled in gitlab.yml, Flipper is used always, like today.
  • Logging unleash client's activity in unleash.log with the structured logging.
  • Per Project/Group/User gate is capable with userWithId strategy (Although, it requires https://gitlab.com/gitlab-org/gitlab-ee/issues/14017 to be fixed at first). If you want to enable a particular feature on a project, then define a param in the convention <The class of Active Record>:<The id of the row> e.g. Project:123

TODO

  • Prepare API
  • Connect API
  • Feature.enable(:name, gate) (console)
  • Feature.disable(:name, gate) (console)
  • Feature.all
  • GET api/v4/features (chatops)
  • DELETE api/v4/features/:name (chatops)
  • POST api/v4/features/:name (chatops)
  • https://gitlab.com/gitlab-com/chatops percentage_of_time
  • Cleanup API. Do we really need ee/lib/api/feature_flag/scopes.rb?
  • safe rollout

Checkpoints

  • Can we start dogfooding on pre-production environment only (dev.gitlab.org, stanging.gitlab.com)
  • Can we start dogfooding on production environment with safe manner (gitlab.com)
  • If Unleash adapter is problematic and affects production reliability, can we disable the adapter and fallback to Flipper adapter?
  • Can we control feature flags via Feature.enable/disable command on rails console?
  • Can we control feature flags via Feature API i.e. api/v4/features? (which is connected to Chatops)
  • Can we know which feature adapter is affecting the feature currently?
  • Safe boot? (Fetching flags before application starts running?)
  • There is an unified interface than having separate interfaces per FF engine.

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Performance and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Shinya Maeda

Merge request reports

Loading