2020-04-21 17:09:38 -04:00
---
2022-05-29 20:08:35 -04:00
stage: Systems
2021-10-05 05:12:23 -04:00
group: Distribution
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2020-04-21 17:09:38 -04:00
description: "GitLab administrator: enable and disable GitLab features deployed behind feature flags"
---
2021-01-28 01:08:59 -05:00
# Enable and disable GitLab features deployed behind feature flags **(FREE SELF)**
2020-04-21 17:09:38 -04:00
GitLab adopted [feature flags strategies ](../development/feature_flags/index.md )
to deploy features in an early stage of development so that they can be
incrementally rolled out.
Before making them permanently available, features can be deployed behind
2021-03-25 11:09:35 -04:00
flags for a [number of reasons ](https://about.gitlab.com/handbook/product-development-flow/feature-flag-lifecycle/#when-to-use-feature-flags ), such as:
2020-04-21 17:09:38 -04:00
- To test the feature.
- To get feedback from users and customers while in an early stage of the development of the feature.
- To evaluate users adoption.
2020-12-09 22:09:53 -05:00
- To evaluate how it impacts the performance of GitLab.
2020-04-21 17:09:38 -04:00
- To build it in smaller pieces throughout releases.
Features behind flags can be gradually rolled out, typically:
1. The feature starts disabled by default.
1. The feature becomes enabled by default.
1. The feature flag is removed.
2022-02-24 13:19:04 -05:00
These features can be enabled and disabled to allow or prevent users from using
2020-04-21 17:09:38 -04:00
them. It can be done by GitLab administrators with access to GitLab Rails
console.
2021-07-30 14:09:08 -04:00
When you disable a feature flag, the feature is hidden from users and all of the functionality is turned off.
For example, data is not recorded and services do not run.
2020-04-21 17:09:38 -04:00
If you used a certain feature and identified a bug, a misbehavior, or an
2020-05-21 02:08:25 -04:00
error, it's very important that you [**provide feedback** ](https://gitlab.com/gitlab-org/gitlab/-/issues/new?issue[title]=Docs%20-%20feature%20flag%20feedback%3A%20Feature%20Name&issue[description]=Describe%20the%20problem%20you%27ve%20encountered.%0A%0A%3C!--%20Don%27t%20edit%20below%20this%20line%20--%3E%0A%0A%2Flabel%20~%22docs%5C-comments%22%20 ) to GitLab as soon
2020-04-21 17:09:38 -04:00
as possible so we can improve or fix it while behind a flag. When you upgrade
2022-01-26 10:12:36 -05:00
GitLab, the feature flag status may change.
2020-04-21 17:09:38 -04:00
2021-07-30 14:09:08 -04:00
## Risks when enabling features still in development
Features that are disabled by default may change or be removed without notice in a future version of GitLab.
2021-11-05 14:12:21 -04:00
Data corruption, stability degradation, performance degradation, or security issues might occur if
2021-07-30 14:09:08 -04:00
you enable a feature that's disabled by default. Problems caused by using a default
disabled feature aren't covered by GitLab support, unless you were directed by GitLab
to enable the feature.
2021-11-05 14:12:21 -04:00
Security issues found in features that are disabled by default are patched in regular releases
and do not follow our regular [maintenance policy ](../policy/maintenance.md#security-releases )
with regards to backporting the fix.
2021-07-30 14:09:08 -04:00
## Risks when disabling released features
In most cases, the feature flag code is removed in a future version of GitLab.
If and when that occurs, from that point onward you can't keep the feature in a disabled state.
2020-04-21 17:09:38 -04:00
## How to enable and disable features behind flags
Each feature has its own flag that should be used to enable and disable it.
The documentation of each feature behind a flag includes a section informing
the status of the flag and the command to enable or disable it.
### Start the GitLab Rails console
2022-06-29 17:09:23 -04:00
The first thing you must do to enable or disable a feature behind a flag is to
2020-04-21 17:09:38 -04:00
start a session on GitLab Rails console.
For Omnibus installations:
```shell
sudo gitlab-rails console
```
For installations from the source:
```shell
sudo -u git -H bundle exec rails console -e production
```
2020-10-14 11:08:42 -04:00
For details, see [starting a Rails console session ](operations/rails_console.md#starting-a-rails-console-session ).
2020-04-21 17:09:38 -04:00
### Enable or disable the feature
2022-06-29 17:09:23 -04:00
After the Rails console session has started, run the `Feature.enable` or
2020-04-21 17:09:38 -04:00
`Feature.disable` commands accordingly. The specific flag can be found
in the feature's documentation itself.
To enable a feature, run:
```ruby
Feature.enable(:< feature flag > )
```
2020-10-07 02:09:03 -04:00
Example, to enable a fictional feature flag named `my_awesome_feature` :
2020-04-21 17:09:38 -04:00
```ruby
2020-10-07 02:09:03 -04:00
Feature.enable(:my_awesome_feature)
2020-04-21 17:09:38 -04:00
```
To disable a feature, run:
```ruby
Feature.disable(:< feature flag > )
```
2020-10-07 02:09:03 -04:00
Example, to disable a fictional feature flag named `my_awesome_feature` :
2020-04-21 17:09:38 -04:00
```ruby
2020-10-07 02:09:03 -04:00
Feature.disable(:my_awesome_feature)
2020-04-21 17:09:38 -04:00
```
2020-05-29 02:08:16 -04:00
Some feature flags can be enabled or disabled on a per project basis:
```ruby
Feature.enable(:< feature flag > , Project.find(< project id > ))
```
2020-08-17 05:10:08 -04:00
For example, to enable the [`:product_analytics` ](../operations/product_analytics.md#enable-or-disable-product-analytics ) feature flag for project `1234` :
2020-05-29 02:08:16 -04:00
```ruby
2020-08-17 05:10:08 -04:00
Feature.enable(:product_analytics, Project.find(1234))
2020-05-29 02:08:16 -04:00
```
2022-07-04 23:08:33 -04:00
`Feature.enable` and `Feature.disable` always return `true` , even if the application doesn't use the flag:
2020-07-10 14:09:45 -04:00
```ruby
2020-10-07 02:09:03 -04:00
irb(main):001:0> Feature.enable(:my_awesome_feature)
2022-07-04 23:08:33 -04:00
=> true
2020-07-10 14:09:45 -04:00
```
2022-01-25 16:15:18 -05:00
When the feature is ready, GitLab removes the feature flag, and the option for
enabling and disabling it no longer exists. The feature becomes available in all instances.
### Check if a feature flag is enabled
To check if a flag is enabled or disabled, use `Feature.enabled?` or `Feature.disabled?` .
For example, for a feature flag named `my_awesome_feature` that is already enabled:
2020-07-10 14:09:45 -04:00
```ruby
2020-10-07 02:09:03 -04:00
Feature.enabled?(:my_awesome_feature)
2020-07-10 14:09:45 -04:00
=> true
2020-10-07 02:09:03 -04:00
Feature.disabled?(:my_awesome_feature)
2020-07-10 14:09:45 -04:00
=> false
```
2022-01-26 10:12:36 -05:00
When the feature is ready, GitLab removes the feature flag, and the option for
enabling and disabling it no longer exists. The feature becomes available in all instances.
### View set feature flags
You can view all GitLab administrator set feature flags:
```ruby
Feature.all
=> [#< Flipper::Feature:198220 name = "my_awesome_feature" , state = :on, enabled_gate_names = [:boolean], adapter = :memoizable > ]
```
### Unset feature flag
2022-06-29 17:09:23 -04:00
You can unset a feature flag so that GitLab falls back to the current defaults for that flag:
2022-01-26 10:12:36 -05:00
```ruby
Feature.remove(:my_awesome_feature)
=> true
```