Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
54056a31
Commit
54056a31
authored
Feb 28, 2022
by
Doug Stull
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add circuit breaker for gitlab experimentation
- a quick way to kill all experiments on SaaS Changelog: added
parent
e09a291d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
6 deletions
+30
-6
config/feature_flags/ops/gitlab_experiment.yml
config/feature_flags/ops/gitlab_experiment.yml
+8
-0
lib/gitlab/experiment/rollout/feature.rb
lib/gitlab/experiment/rollout/feature.rb
+11
-2
spec/lib/gitlab/experiment/rollout/feature_spec.rb
spec/lib/gitlab/experiment/rollout/feature_spec.rb
+11
-4
No files found.
config/feature_flags/ops/gitlab_experiment.yml
0 → 100644
View file @
54056a31
---
name
:
gitlab_experiment
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81834
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/353921
milestone
:
'
14.9'
type
:
ops
group
:
group::conversion
default_enabled
:
true
lib/gitlab/experiment/rollout/feature.rb
View file @
54056a31
...
...
@@ -12,10 +12,11 @@ module Gitlab
# - not have rolled out the feature flag at all (no percent of actors,
# no inclusions, etc.)
def
enabled?
return
false
if
::
Feature
::
Definition
.
get
(
feature_flag_name
).
nil
?
return
false
unless
feature_flag_defined
?
return
false
unless
Gitlab
.
dev_env_or_com?
return
false
unless
::
Feature
.
enabled?
(
:gitlab_experiment
,
type: :ops
,
default_enabled: :yaml
)
::
Feature
.
get
(
feature_flag_name
).
state
!=
:off
# rubocop:disable Gitlab/AvoidFeatureGet
feature_flag_instance
.
state
!=
:off
end
# For assignment we first check to see if our feature flag is enabled
...
...
@@ -58,6 +59,14 @@ module Gitlab
private
def
feature_flag_instance
::
Feature
.
get
(
feature_flag_name
)
# rubocop:disable Gitlab/AvoidFeatureGet
end
def
feature_flag_defined?
::
Feature
::
Definition
.
get
(
feature_flag_name
).
present?
end
def
feature_flag_name
experiment
.
name
.
tr
(
'/'
,
'_'
)
end
...
...
spec/lib/gitlab/experiment/rollout/feature_spec.rb
View file @
54056a31
...
...
@@ -9,9 +9,10 @@ RSpec.describe Gitlab::Experiment::Rollout::Feature, :experiment do
describe
"#enabled?"
do
before
do
allow
(
Feature
::
Definition
).
to
receive
(
:get
).
and_return
(
'_instance_'
)
stub_feature_flags
(
gitlab_experiment:
true
)
allow
(
subject
).
to
receive
(
:feature_flag_defined?
).
and_return
(
true
)
allow
(
Gitlab
).
to
receive
(
:dev_env_or_com?
).
and_return
(
true
)
allow
(
Feature
).
to
receive
(
:get
).
and_return
(
double
(
state: :on
))
allow
(
subject
).
to
receive
(
:feature_flag_instance
).
and_return
(
double
(
state: :on
))
end
it
"is enabled when all criteria are met"
do
...
...
@@ -19,7 +20,7 @@ RSpec.describe Gitlab::Experiment::Rollout::Feature, :experiment do
end
it
"isn't enabled if the feature definition doesn't exist"
do
expect
(
Feature
::
Definition
).
to
receive
(
:get
).
with
(
'namespaced_stub'
).
and_return
(
nil
)
expect
(
subject
).
to
receive
(
:feature_flag_defined?
).
and_return
(
false
)
expect
(
subject
).
not_to
be_enabled
end
...
...
@@ -31,7 +32,13 @@ RSpec.describe Gitlab::Experiment::Rollout::Feature, :experiment do
end
it
"isn't enabled if the feature flag state is :off"
do
expect
(
Feature
).
to
receive
(
:get
).
with
(
'namespaced_stub'
).
and_return
(
double
(
state: :off
))
expect
(
subject
).
to
receive
(
:feature_flag_instance
).
and_return
(
double
(
state: :off
))
expect
(
subject
).
not_to
be_enabled
end
it
"isn't enabled if the gitlab_experiment feature flag is false"
do
stub_feature_flags
(
gitlab_experiment:
false
)
expect
(
subject
).
not_to
be_enabled
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment