Feature flag for :force_autodevops_on_by_default not honored
Summary
The code path that references the feature flag :force_autodevops_on_by_default
does not appear to ever get reached, so the feature flag will have no effect if set for a project, or as a percentage_of_actors
instance wide.
The single code reference to the flag is in Project#first_auto_devops_config
on/near Line:807
in app/models/project.rb
(sha ref is master HEAD from a few days ago)
Steps to reproduce
See also: https://gitlab.com/gitlab-com/gl-infra/infrastructure/-/issues/3160#note_353290817 for a GitLab.com example
For self-managed:
- Set the flag for a project:
> p = Project.find(26)
=> #<Project id:26 k8s-instance-test/rails-autodevops-test>>
> Feature.enable(:force_autodevops_on_by_default, p)
=> nil
> Feature.enabled?(:force_autodevops_on_by_default, p)
=> true
> p.reload
=> #<Project id:26 k8s-instance-test/rails-autodevops-test>>
- Make sure that Auto Devops is off for the instance and project namespace has a nil configuration (or is not disabled)
> Gitlab::CurrentSettings.auto_devops_enabled?
=> false
> p.namespace.auto_devops_enabled
=> nil
> p.namespace.auto_devops_enabled?
=> false
- Verify that the Project's auto_devops configuration is nil
p.auto_devops
=> nil
- Observe that
Project#auto_devops_enabled?
andProject#has_auto_devops_implicitly_enabled?
returnfalse
, when they should returntrue
because of the feature flag
> p.auto_devops_enabled?
=> false
> p.has_auto_devops_implicitly_enabled?
=> false
What is the current bug behavior?
The feature flag is not honored as expected: Project#has_auto_devops_implicitly_enabled?
is false when the :force_autodevops_on_by_default
feature flag is enabled for the project and Project#auto_devops
is nil
What is the expected correct behavior?
Project#has_auto_devops_implicitly_enabled?
should be true when the :force_autodevops_on_by_default
feature flag is enabled for the project and Project#auto_devops
is nil
Output of checks
Happens on GitLab.com and self-managed instances.
Results of GitLab environment info
Not applicable.
Results of GitLab application Check
Not applicable.
Possible fixes
See the code path overview at: https://gitlab.com/gitlab-com/gl-infra/infrastructure/-/issues/3160#note_352374536
This appears to just have fallen out from the code reorganization from the introduction of .auto_devops_enabled
at the Group Level
I'm unclear reading the test specs what test might should have caught this.
It seems like Project#has_auto_devops_implicitly_enabled?
should have an explicit check for the :force_autodevops_on_by_default
feature flag when auto_devops
is false for the namespace/instance scope (meaning that the project setting indeterminate: Project#auto_devops
is nil
)
Also, on GitLab.com, the flag value as of writing is 22%, so we will need to consider if we want to maintain this value or start incrementally from 0% again to avoid a potential sudden spike