[Feature flag] Enable add_all_ci_running_builds/remove_all_ci_running_builds
Summary
This issue is to roll out the feature on production, that is currently behind the add_all_ci_running_builds
/remove_all_ci_running_builds
feature flags.
Owners
- Most appropriate Slack channel to reach out to:
#g_runner
- Best individual to reach out to: @pedropombeiro
Expectations
What are we expecting to happen?
Enabling the add_all_ci_running_builds
feature flag on a project should result on builds that are running on non-shared runners to be recorded in the ci_running_builds
table. Currently, that table is only being populated for builds running on shared runners.
We should also enable the remove_all_ci_running_builds
FF so that builds from non-shared runners are removed from the table once they complete.
What can go wrong and how would we detect it?
This could cause an unacceptable increase in load to the database server, given that we're multiplying the rate of insertion to the ci_running_builds
table by a factor of 4 to 5.
We could monitor the following:
- Metric:
pgbouncer saturation/error ratio
:- Location: https://dashboards.gitlab.net/d/pgbouncer-main/pgbouncer3a-overview?orgId=1&from=now-24h&to=now
- What changes to this metric should prompt a rollback:
- pgbouncer saturation reaching a level 20% above the level from 24h ago.
- pgbouncer service error ratio sensibly increasing.
- Metric: rails_primary_sql SLI RPS - Requests per Second
- Location: https://dashboards.gitlab.net/d/patroni-ci-main/patroni-ci3a-overview?orgId=1&from=now-24h&to=now
- What changes to this metric should prompt a rollback:
- Given that we'll be writting 4-5x times more to the
ci_running_builds
table, we expect an increase in RPS to the primary node. If this increases more than 10% compared to the previous week, we should consider rolling the change back.
- Given that we'll be writting 4-5x times more to the
Rollout Steps
Note: Please make sure to run the chatops commands in the Slack channel that gets impacted by the command.
Rollout on non-production environments
-
Verify the MR with the feature flag is merged to master
and have been deployed to non-production environments with/chatops run auto_deploy status <merge-commit-of-your-feature>
-
Deploy the remove_all_ci_running_builds
feature flag with/chatops run feature set remove_all_ci_running_builds true --project=gitlab-org/gitlab --staging --staging-ref
-
Deploy the add_all_ci_running_builds
feature flag with/chatops run feature set add_all_ci_running_builds true --project=gitlab-org/gitlab --staging --staging-ref
-
Globally deploy the remove_all_ci_running_builds
feature flag with/chatops run feature set remove_all_ci_running_builds true --dev --pre --staging --staging-ref
-
Deploy the feature flag at 10% with /chatops run feature set add_all_ci_running_builds 10 --actors --dev --pre --staging --staging-ref
-
Monitor that the error rates did not increase (repeat with a different percentage as necessary). -
Deploy the feature flag at 25% with /chatops run feature set add_all_ci_running_builds 25 --actors --dev --pre --staging --staging-ref
-
Deploy the feature flag at 50% with /chatops run feature set add_all_ci_running_builds 50 --actors --dev --pre --staging --staging-ref
-
Deploy the feature flag at 75% with /chatops run feature set add_all_ci_running_builds 75 --actors --dev --pre --staging --staging-ref
-
Enable the feature globally on non-production environments with /chatops run feature set add_all_ci_running_builds true --dev --pre --staging --staging-ref
-
Verify that the feature works as expected. The best environment to validate the feature in is staging-canary
as this is the first environment deployed to. Make sure you are configured to use canary. -
If the feature flag causes end-to-end tests to fail, disable the feature flag on staging to avoid blocking deployments. - See
#qa-staging
Slack channel and look for the following messages:- test kicked off:
Feature flag add_all_ci_running_builds has been set to true on **gstg**
- test result:
This pipeline was triggered due to toggling of add_all_ci_running_builds feature flag
- test kicked off:
- See
For assistance with end-to-end test failures, please reach out via the #test-platform
Slack channel. Note that end-to-end test failures on staging-ref
don't block deployments.
Specific rollout on production
For visibility, all /chatops
commands that target production should be executed in the #production
Slack channel and cross-posted (with the command results) to the responsible team's Slack channel.
-
Ensure that the feature MRs have been deployed to both production and canary with /chatops run auto_deploy status <merge-commit-of-your-feature>
-
Depending on the type of actor you are using, pick one of these options: /chatops run feature set --project=gitlab-org/gitlab,gitlab-org/gitlab-foss,gitlab-com/www-gitlab-com remove_all_ci_running_builds true
/chatops run feature set --project=gitlab-org/gitlab,gitlab-org/gitlab-foss,gitlab-com/www-gitlab-com add_all_ci_running_builds true
-
Verify that the feature works for the specific actors.
Preparation before global rollout
-
Set a milestone to this rollout issue to signal for enabling and removing the feature flag when it is stable. -
Check if the feature flag change needs to be accompanied with a change management issue. Cross link the issue here if it does. -
Ensure that you or a representative in development can be available for at least 2 hours after feature flag updates in production. If a different developer will be covering, or an exception is needed, please inform the oncall SRE by using the @sre-oncall
Slack alias. -
Ensure that documentation exists for the feature, and the version history text has been updated. -
Leave a comment on the feature issue announcing estimated time when this feature flag will be enabled on GitLab.com. -
Ensure that any breaking changes have been announced following the release post process to ensure GitLab customers are aware. -
Notify the #support_gitlab-com
Slack channel and your team channel (more guidance when this is necessary in the dev docs). -
Ensure that the feature flag rollout plan is reviewed by another developer familiar with the domain.
Global rollout on production
For visibility, all /chatops
commands that target production should be executed in the #production
Slack channel and cross-posted (with the command results) to the responsible team's Slack channel (#g_runner
).
-
(Optional) Incrementally roll out the feature on production environment. - Between every step wait for at least 15 minutes and monitor the appropriate graphs on https://dashboards.gitlab.net.
- Perform rollout:
/chatops run feature set remove_all_ci_running_builds true
- Perform actor-based rollout:
/chatops run feature set add_all_ci_running_builds <rollout-percentage> --actors
-
Enable the feature globally on production environment: /chatops run feature set add_all_ci_running_builds true
-
Observe appropriate graphs on https://dashboards.gitlab.net and verify that services are not affected. -
Leave a comment on [the feature issue][main-issue] announcing that the feature has been globally enabled. -
Wait for at least one day for the verification term.
(Optional) Release the feature with the feature flag
WARNING: This approach has the downside that it makes it difficult for us to clean up the flag. For example, on-premise users could disable the feature on their GitLab instance. But when you remove the flag at some point, they suddenly see the feature as enabled and they can't roll it back to the previous behavior. To avoid this potential breaking change, use this approach only for urgent matters.
See instructions if you're sure about enabling the feature globally through the feature flag definition
If you're still unsure whether the feature is deemed stable but want to release it in the current milestone, you can change the default state of the feature flag to be enabled. To do so, follow these steps:
-
Create a merge request with the following changes. Ask for review and merge it. -
If feature was enabled for various actors, ensure the feature has been enabled globally on production /chatops run feature get add_all_ci_running_builds
. If the feature has not been globally enabled then enable the feature globally using:/chatops run feature set add_all_ci_running_builds true
-
Set the default_enabled
attribute in the feature flag definition totrue
. -
Decide which changelog entry is needed.
-
-
Ensure that the default-enabling MR has been included in the release package. If the merge request was deployed before the monthly release was tagged, the feature can be officially announced in a release blog post: /chatops run release check https://gitlab.com/gitlab-org/gitlab/-/merge_requests/147943 16.11
-
Consider cleaning up the feature flag from all environments by running these chatops command in #production
channel. Otherwise these settings may override the default enabled:/chatops run feature delete add_all_ci_running_builds --dev --pre --staging --staging-ref --production
-
Close [the feature issue][main-issue] to indicate the feature will be released in the current milestone. -
Set the next milestone to this rollout issue for scheduling the flag removal. -
(Optional) You can create a separate issue for scheduling the steps below to Release the feature. -
Set the title to "[Feature flag] Cleanup add_all_ci_running_builds
/remove_all_ci_running_builds
". -
Execute the /copy_metadata <this-rollout-issue-link>
quick action to copy the labels from this rollout issue. -
Link this rollout issue as a related issue. -
Close this rollout issue.
-
Release the feature
After the feature has been deemed stable, the clean up should be done as soon as possible to permanently enable the feature and reduce complexity in the codebase.
You can either create a follow-up issue for Feature Flag Cleanup or use the checklist below in this same issue.
-
Create a merge request to remove the add_all_ci_running_builds
andremove_all_ci_running_builds
feature flags. Ask for review/approval/merge as usual. The MR should include the following changes:- Remove all references to the feature flags from the codebase.
- Remove the YAML definitions for the feature from the repository.
- Create a changelog entry.
-
Ensure that the cleanup MR has been included in the release package. If the merge request was deployed before the monthly release was tagged, the feature can be officially announced in a release blog post: /chatops run release check https://gitlab.com/gitlab-org/gitlab/-/merge_requests/150172 16.11
-
Close [the feature issue][main-issue] to indicate the feature will be released in the current milestone. -
Clean up the feature flag from all environments by running these chatops command in #production
channel:/chatops run feature delete add_all_ci_running_builds --dev --pre --staging --staging-ref --production
-
Clean up the feature flag from all environments by running these chatops command in #production
channel:/chatops run feature delete remove_all_ci_running_builds --dev --pre --staging --staging-ref --production
-
Close this rollout issue.
Rollback Steps
-
This feature can be disabled on production by running the following Chatops command: /chatops run feature set add_all_ci_running_builds false
-
Disable the feature flag on non-production environments: /chatops run feature set add_all_ci_running_builds false --dev --pre --staging --staging-ref
-
Delete feature flag from all environments: /chatops run feature delete add_all_ci_running_builds --dev --pre --staging --staging-ref --production
Patch to remove FF
Patch
diff --git a/app/models/ci/running_build.rb b/app/models/ci/running_build.rb
index 898a110c5e8a..94b3e5f9912e 100644
--- a/app/models/ci/running_build.rb
+++ b/app/models/ci/running_build.rb
@@ -23,10 +23,6 @@ class RunningBuild < Ci::ApplicationRecord
enum runner_type: ::Ci::Runner.runner_types
def self.upsert_build!(build)
- unless Feature.enabled?(:add_all_ci_running_builds, build.project) || build.shared_runner_build?
- raise ArgumentError, 'build has not been picked by a shared runner'
- end
-
if build.runner.nil?
raise ArgumentError, 'build has not been picked by a runner'
end
diff --git a/app/services/ci/update_build_queue_service.rb b/app/services/ci/update_build_queue_service.rb
index a28b063b5fdc..08454816a6bc 100644
--- a/app/services/ci/update_build_queue_service.rb
+++ b/app/services/ci/update_build_queue_service.rb
@@ -54,7 +54,6 @@ def remove!(build)
#
def track(build, transition)
return if build.runner.nil?
- return unless add_all_ci_running_builds(build) || build.shared_runner_build?
raise InvalidQueueTransition unless transition.to == 'running'
@@ -74,7 +73,7 @@ def track(build, transition)
#
def untrack(build, transition)
return if build.runner.nil?
- return unless add_all_ci_running_builds(build) || build.shared_runner_build?
+ return unless Feature.enabled?(:add_all_ci_running_builds) || build.shared_runner_build?
raise InvalidQueueTransition unless transition.from == 'running'
@@ -110,9 +109,5 @@ def tick_for(build, runners)
runner.pick_build!(build)
end
end
-
- def add_all_ci_running_builds(build)
- Feature.enabled?(:add_all_ci_running_builds, build.project)
- end
end
end
diff --git a/config/feature_flags/gitlab_com_derisk/add_all_ci_running_builds.yml b/config/feature_flags/gitlab_com_derisk/add_all_ci_running_builds.yml
deleted file mode 100644
index 06cc4a4351ad..000000000000
--- a/config/feature_flags/gitlab_com_derisk/add_all_ci_running_builds.yml
+++ /dev/null
@@ -1,9 +0,0 @@
----
-name: add_all_ci_running_builds
-feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/437846
-introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/147943
-rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/452166
-milestone: '16.11'
-group: group::runner
-type: gitlab_com_derisk
-default_enabled: false
diff --git a/lib/gitlab/seeders/ci/runner/runner_fleet_pipeline_seeder.rb b/lib/gitlab/seeders/ci/runner/runner_fleet_pipeline_seeder.rb
index d7890be0ab92..6b2d250001eb 100644
--- a/lib/gitlab/seeders/ci/runner/runner_fleet_pipeline_seeder.rb
+++ b/lib/gitlab/seeders/ci/runner/runner_fleet_pipeline_seeder.rb
@@ -171,10 +171,7 @@ def create_build(pipeline, runner, job_status, index)
::Ci::Build.transaction do
build = ::Ci::Build.new(importing: true, **build_attrs).tap(&:save!)
- if build.running? &&
- (Feature.enabled?(:add_all_ci_running_builds, build.project) || build.shared_runner_build?)
- ::Ci::RunningBuild.upsert_build!(build)
- end
+ ::Ci::RunningBuild.upsert_build!(build) if build.running?
end
end
diff --git a/spec/models/ci/running_build_spec.rb b/spec/models/ci/running_build_spec.rb
index e78b8b4fff65..6122d5c3196d 100644
--- a/spec/models/ci/running_build_spec.rb
+++ b/spec/models/ci/running_build_spec.rb
@@ -35,16 +35,6 @@
it 'returns a build id as a result' do
expect(upsert_build.rows.dig(0, 0)).to eq build.id
end
-
- context 'with add_all_ci_running_builds FF disabled' do
- before do
- stub_feature_flags(add_all_ci_running_builds: false)
- end
-
- it 'raises an error' do
- expect { upsert_build }.to raise_error(ArgumentError, 'build has not been picked by a shared runner')
- end
- end
end
context 'when build has not been picked by a runner yet' do
@@ -53,16 +43,6 @@
it 'raises an error' do
expect { upsert_build }.to raise_error(ArgumentError, 'build has not been picked by a runner')
end
-
- context 'with add_all_ci_running_builds FF disabled' do
- before do
- stub_feature_flags(add_all_ci_running_builds: false)
- end
-
- it 'raises an error' do
- expect { upsert_build }.to raise_error(ArgumentError, 'build has not been picked by a shared runner')
- end
- end
end
end
diff --git a/spec/services/ci/update_build_queue_service_spec.rb b/spec/services/ci/update_build_queue_service_spec.rb
index c0841436c04b..772efa0878d6 100644
--- a/spec/services/ci/update_build_queue_service_spec.rb
+++ b/spec/services/ci/update_build_queue_service_spec.rb
@@ -177,18 +177,6 @@
.not_to have_received(:increment_queue_operation)
.with(:shared_runner_build_new)
end
-
- context 'with add_all_ci_running_builds FF disabled' do
- before do
- stub_feature_flags(add_all_ci_running_builds: false)
- end
-
- it 'does not create a new project runner build tracking entry' do
- build_id = subject.track(build, transition)
-
- expect(build_id).to be_nil
- end
- end
end
context 'when invalid transition is detected' do
@@ -265,18 +253,6 @@
.not_to have_received(:increment_queue_operation)
.with(:shared_runner_build_done)
end
-
- context 'with add_all_ci_running_builds FF disabled' do
- before do
- stub_feature_flags(add_all_ci_running_builds: false)
- end
-
- it 'does not remove project runner build' do
- build_id = subject.untrack(build, transition)
-
- expect(build_id).to be_nil
- end
- end
end
context 'when tracking entry does not exist' do