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:
### 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),
but in some cases, you'd want to gauge the impact at first, so that we can be
more confident that the change wouldn't require revert/rollback on production.
At a major version, like 13.0 or 14.0, [stable templates](#stable-version) must be
updated with their corresponding [latest template versions](#latest-version).
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, you can redirect to the latest template in 25% of projects on `gitlab.com`, by the following chatops command:
For example, to redirect the stable `Jobs/Deploy` template to its latest template in 25% of
projects on `gitlab.com`:
```shell
/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,
remove the latest template and remove the corresponding feature flag.
After you're confident the latest template can be moved to stable:
1. Update the stable template with the content of the latest version.
1. Remove the corresponding feature flag.
### Further reading
......
......@@ -18,6 +18,7 @@ module Gitlab
end
class << self
extend ::Gitlab::Utils::Override
include Gitlab::Utils::StrongMemoize
def extension
......@@ -63,6 +64,7 @@ module Gitlab
)
end
override :find
def find(key, project = nil)
if try_redirect_to_latest?(key, project)
key += '.latest'
......
......@@ -23,6 +23,7 @@ RSpec.describe Gitlab::Template::GitlabCiYmlTemplate do
describe '.find' do
let_it_be(:project) { create(:project) }
let_it_be(:other_project) { create(:project) }
described_class::TEMPLATES_WITH_LATEST_VERSION.keys.each do |key|
it "finds the latest template for #{key}" 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
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
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