Skip to content
Snippets Groups Projects

Add new feature flag type called `worker`

Merged Marco (Gregorius) requested to merge mg-add-worker-ff-type into master
All threads resolved!

What does this MR do and why?

Add new feature flag type called worker

This feature flag type is similar to undefined where the feature flag names are not defined in the GitLab codebase. Each feature flag's name might have the worker name in it. These feature flags will be used to control the behavior of Sidekiq workers dynamically, e.g. deferring jobs from runaway workers during an incident.

Changelog: added


Resolves gitlab-com/gl-infra/scalability#2345.

More context can be found in the epic gitlab-com/gl-infra&1004 (closed) and this discussion.

The immediate usage of this new type of feature flag is at Defer Sidekiq jobs from worker type feature flags (!120606 - merged)

How to set up and validate locally

  1. Checking for a random feature flag will follow the default_enabled_if_undefined behavior

    [1] pry(main)> Feature.enabled?(:some_feature_flag, type: :worker, default_enabled_if_undefined: false)
      Feature::FlipperGate Load (0.3ms)  SELECT "feature_gates".* FROM "feature_gates" WHERE "feature_gates"."feature_key" = 'some_feature_flag' /*application:console,db_config_name:main,console_hostname:Gregoriuss-MBP,console_username:gregoriusmarco,line:/lib/feature.rb:237:in `block in current_feature_value'*/
    => false
    [2] pry(main)> Feature.enabled?(:some_feature_flag, type: :worker, default_enabled_if_undefined: true)
    => true
  2. Turn on that feature flag from API (requires to create a personal access token first):

    $ curl -s -H "PRIVATE-TOKEN: $PERSONAL_ACCESS_TOKEN" http://gdk.test:3000/api/v4/features/some_feature_flag --data "value=true" | jq
    {
      "name": "some_feature_flag",
      "state": "on",
      "gates": [
        {
          "key": "boolean",
          "value": true
        }
      ],
      "definition": null
    }
  3. Check again if the feature is enabled:

    [4] pry(main)> Feature.enabled?(:some_feature_flag, type: :worker, default_enabled_if_undefined: false)
    => true
    [5] pry(main)> Feature.enabled?(:some_feature_flag, type: :worker, default_enabled_if_undefined: true)
    => true

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 Marco (Gregorius)

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading