Explicit feature flag cannot be enabled for specific project or user
Summary
(Summarize the bug encountered concisely)
Explicit feature flags cannot be enabled for a specific target (project, user).
Steps to reproduce
(How one can reproduce the issue - this is very important)
- Add a feature to one of the constants (EES_FEATURES, EEP_FEATURES, EEU_FEATURES) in ee/app/models/license.rb. Make sure you have the correct license to use the feature you added. For example, if you added the feature to the EEU_FEATURES constant, make sure you have the Ultimate license.
- In your rails console, enable the feature flag for a particular project. For example, if you had added
incident_managementas a feature in the step above, you would execute the following in your rails console:where Project.find(1) is the project for which you want to enable the::Feature.enable(:incident_management, Project.find(1))incident_managementfeature flag. - Check that
::Feature.enabled?(:incident_management)returns false and::Feature.enabled?(:incident_management, Project.find(1))return true. This shows that the feature has only been enabled for project with ID 1. - In your rails console, run this command:
Project.find(1).feature_available?(:incident_management, Project.find(1))
This should return true, but it instead returns false.
Example Project
(If possible, please create an example project here on GitLab.com that exhibits the problematic behaviour, and link to it here in the bug report)
(If you are using an older version of GitLab, this will also determine whether the bug has been fixed in a more recent version)
What is the current bug behavior?
(What actually happens)
project.feature_available?(:incident_management, project) returns false. project is the project object for which the incident_management feature_flag has been enabled.
What is the expected correct behavior?
(What you should see instead)
With an explicit feature flag that has been enabled for a particular project, project.feature_available?(:incident_management, project) should return true where project is the project for which the feature flag incident_management has been enabled.
Relevant logs and/or screenshots
(Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's very hard to read otherwise.)
Output of checks
(If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com)
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:env:info)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)(we will only investigate if the tests are passing)
Possible fixes
This appears to be the line that causes this behavior: https://gitlab.com/gitlab-org/gitlab-ee/blob/master/ee/app/models/license.rb#L312
(If you can, link to the line of code that might be responsible for the problem)