Feature flag is a software development technique that turns functionality on and off without deploying new code. Feature flags allow us to be more confident in shipping features continuously to Mattermost Cloud. Feature flags also allow us to control which features are enabled on a cluster level.
There are no hard rules on when a feature flag should be used. It is left up to the best judgement of the responsible engineers to determine if a feature flag is required. The following are guidelines designed to help the determination:
In all cases, ask yourself: Why do I need to add a feature flag? If I don’t add one, what options do I have to control the impact on user experience (e.g. a config setting or System Console setting)?
model/feature_flags.go
.SetDefaults
function in the same file.SetDefaults
function.Feature flag values can be changed via environment variables. The environment variable set follows the pattern MM_FEATUREFLAGS_<name>
where <name>
is the uppercase key of the feature flag you added to model/feature_flags.go
Feature flag adjustments (ie, turning something on or off) in the Mattermost Cloud environment are owned and controlled by the Cloud team. To change the value for a feature flag, please open a ticket.
Typically feature flag will initially disable the feature. It’s a good idea to test the feature during a safe time or on a subset of instances. Each team can decide what’s best and there’s no need to request the flag value changes from the Cloud team. If you think there might be a performance impact there’s no harm in communicating your plan beforehand.
For smaller, non-risky features, the above process can be more fast tracked as needed, such as starting with a 10% rollout to test servers, then 100%. Features have to soak on Cloud for at least two weeks for testing. Focus is on severity and number of bugs found; if there are major bugs found at any stage, the feature flag can be turned off to roll back the feature.
When the feature is rolled out to customers, logs will show if there are crashes, and normally users will report feedback on the feature (e.g. bugs).
For self-hosted releases, typically a flagged feature will be released in an enabled state. That said, you can release a feature to self-hosted disabled, it's not unprecedented.
Tests should be written to verify all states of the feature flag. Tests should cover any migrations that may take place in both directions (i.e., from “off” to “on” and from “on” to “off”). Ideally E2E tests should be written before the feature is merged, or at least before the feature flag is removed.
Some examples are here.
What are the expected values for boolean feature flags?
true
or false
, but this may not always equate to enabled/disabled. A feature flag that introduces three new sorting algorithms can also be written:
Is it possible to use a plugin feature flag such as PluginIncidentManagement
to “prepackage” a plugin only on Cloud by only setting a plugin version to that flag on Cloud? Can self-hosted customers manually set that flag to install the said plugin?
How do feature flags work on webapp?
How do feature flags work on mobile?
What is the environment variable to set a feature flag?
MM_FEATUREFLAGS_<myflag>
.Can plugins use feature flags to enable small features aside of the version forcing feature flag?
Do feature flag changes require the server to be restarted?
For features that are requested by self-hosted customers, why do we have to deploy to Cloud first, rather than having the customer who has the test case test it?
How does the current process take into account bugs that may arise on self-hosted specifically?
How can self-hosted installations set feature flags?