Commit d2e19edc authored by Marcel Amirault's avatar Marcel Amirault Committed by Shinya Maeda

Apply 3 suggestion(s) to 1 file(s)

parent 0c063e8f
...@@ -309,19 +309,23 @@ include: ...@@ -309,19 +309,23 @@ include:
### Use a feature flag to rollout the latest template ### Use a feature flag to rollout the latest template
At a GitLab major version update, we should renew [stable templates](#stable-version) by the corresponding [latest templates](#latest-version), At a major version, like 13.0 or 14.0, [stable templates](#stable-version) must be
but in some cases, you'd want to gauge the impact at first, so that we can be updated with their corresponding [latest template versions](#latest-version).
more confident that the change wouldn't require revert/rollback on production. It may be hard to gauge the impact of this change, so use the `redirect_to_latest_template_<name>`
feature flag to test the impact on a subset of users. Using a feature flag can help
reduce the risk of reverts or rollbacks on production.
To do so, you can use the feature flag, named `redirect_to_latest_template_<name>`. For example, to redirect the stable `Jobs/Deploy` template to its latest template in 25% of
For example, you can redirect to the latest template in 25% of projects on `gitlab.com`, by the following chatops command: projects on `gitlab.com`:
```shell ```shell
/chatops run feature set redirect_to_latest_template_jobs_deploy 25 --actors /chatops run feature set redirect_to_latest_template_jobs_deploy 25 --actors
``` ```
Once you're confident on the latest template, you should renew the stable template by the latest content, After you're confident the latest template can be moved to stable:
remove the latest template and remove the corresponding feature flag.
1. Update the stable template with the content of the latest version.
1. Remove the corresponding feature flag.
### Further reading ### Further reading
......
...@@ -18,6 +18,7 @@ module Gitlab ...@@ -18,6 +18,7 @@ module Gitlab
end end
class << self class << self
extend ::Gitlab::Utils::Override
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
def extension def extension
...@@ -63,6 +64,7 @@ module Gitlab ...@@ -63,6 +64,7 @@ module Gitlab
) )
end end
override :find
def find(key, project = nil) def find(key, project = nil)
if try_redirect_to_latest?(key, project) if try_redirect_to_latest?(key, project)
key += '.latest' key += '.latest'
......
...@@ -23,6 +23,7 @@ RSpec.describe Gitlab::Template::GitlabCiYmlTemplate do ...@@ -23,6 +23,7 @@ RSpec.describe Gitlab::Template::GitlabCiYmlTemplate do
describe '.find' do describe '.find' do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:other_project) { create(:project) }
described_class::TEMPLATES_WITH_LATEST_VERSION.keys.each do |key| described_class::TEMPLATES_WITH_LATEST_VERSION.keys.each do |key|
it "finds the latest template for #{key}" do it "finds the latest template for #{key}" do
...@@ -57,7 +58,7 @@ RSpec.describe Gitlab::Template::GitlabCiYmlTemplate do ...@@ -57,7 +58,7 @@ RSpec.describe Gitlab::Template::GitlabCiYmlTemplate do
context 'when `redirect_to_latest_template` feature flag is enabled on the other project' do context 'when `redirect_to_latest_template` feature flag is enabled on the other project' do
before do before do
stub_feature_flags("redirect_to_latest_template_#{key.underscore.tr('/', '_')}".to_sym => create(:project)) stub_feature_flags("redirect_to_latest_template_#{key.underscore.tr('/', '_')}".to_sym => other_project)
end end
it "finds the stable template for #{key}" do it "finds the stable template for #{key}" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment