Support Flipper API in GitLab Feature Flag

Proposal

Today, GitLab's feature flag only supports Unleash schema/API, but it can also support any schema/APIs, such as Flipper API.

Benefits

  • This allows us to easily connect Flipper client to GitLab Feature Flag. #222266 (closed)
  • It's likely an acceptable level of performance on production. We can continue using L1/L2 caches of Feature class. Most of the times, flag data are returned from cache layers, so it barely requests to Feature Flag server.
  • We can expect more active users in GitLab's feature flag as Flipper is one of the most popular feature flag system in ruby community (Flipper: 2.2k stars and used by 303 projects. Unleash: 2.2k starts and used by 32 projects). The new API can be used by any Flipper projects regardless of the scale (Ruby projects only, for the other language, unleash APIs can be used).
  • This encourages us to build a generic UI/UX, which allows us to support more various Feature Flag clients with GitLab Feature Flag.

Schema Mapping

GitLab UI Unleash's strategy Flipper's gate Example of value
All users default boolean true
User IDs userWithId actors Project:123
Percent rollout (Based on User ID) flexibleRollout or gradualRolloutUserId percentage_of_actors 50
Percent rollout (Random) flexibleRollout percentage_of_time 50

Flipper

GET /features

features:
  - key:
    state: 
    gates:
      - key: (boolean/groups/actors/percentage_of_actors/percentage_of_time)
        name:
        value:

Unleash

GET features

features:
  - name:
    description:
    enabled:
    strategies:
      - name:
        parameters:

Endpoints

We replicate the endpoints for Flipper API

GET         /api/:version/feature_flags/flipper/:project_id/features(.:format)                                      - Get all features
POST        /api/:version/feature_flags/flipper/:project_id/features(.:format)                                      - Create a new feature
GET         /api/:version/feature_flags/flipper/:project_id/features/:feature_name(.:format)                        - Retrieve a feature
DELETE      /api/:version/feature_flags/flipper/:project_id/features/:feature_name(.:format)                        - Delete a feature
DELETE      /api/:version/feature_flags/flipper/:project_id/features/:feature_name/clear(.:format)                  - Clear a feature
POST        /api/:version/feature_flags/flipper/:project_id/features/:feature_name/boolean(.:format)                - Boolean enable a feature
DELETE      /api/:version/feature_flags/flipper/:project_id/features/:feature_name/boolean(.:format)                - Boolean disable a feature
POST        /api/:version/feature_flags/flipper/:project_id/features/:feature_name/groups(.:format)                 - Enable Group
DELETE      /api/:version/feature_flags/flipper/:project_id/features/:feature_name/groups(.:format)                 - Disable Group
POST        /api/:version/feature_flags/flipper/:project_id/features/:feature_name/actors(.:format)                 - Enable Actor
DELETE      /api/:version/feature_flags/flipper/:project_id/features/:feature_name/actors(.:format)                 - Disable Actor
POST        /api/:version/feature_flags/flipper/:project_id/features/:feature_name/percentage_of_actors(.:format)   - Enable Percentage of Actors
DELETE      /api/:version/feature_flags/flipper/:project_id/features/:feature_name/percentage_of_actors(.:format)   - Disable Percentage of Actors
POST        /api/:version/feature_flags/flipper/:project_id/features/:feature_name/percentage_of_time(.:format)     - Enable Percentage of Time
DELETE      /api/:version/feature_flags/flipper/:project_id/features/:feature_name/percentage_of_time(.:format)     - Disable Percentage of Time
GET         /api/:version/feature_flags/flipper/:project_id/actors/:flipper_id(.:format)                            - Check if features are enabled for an actor

Tasks

Auth

  • Flipper client includes instance_id in request header and GitLab authorizes the requests if it's sent by a valid client.
  • If it's a valid token, the client can CRUD feature flags
  • If it's not a valid token, the client get an 401 error code
  • If the project id is not found, the client get an 404 error code

NOTE

  • This feature is going to be shipped as alpha feature, and is going to be evaluated in infrastructure issues. If we confirm that it's safe to be exposed, we publish this feature to the world i.e. announce in a release blog post.
  • This is a part of ~Dogfooding issues.
Edited by Orit Golowinski