Rules of thumb (going forward)

  1. Feature toggles. Use Waffle via waffle_utils for boolean flags to toggle or rollout a feature.
    1. Use WaffleSwitch for a simple toggle that can be dynamically changed while the server is running. 
    2. Use WaffleFlag for a staged rollout of the feature when you want to increase gradually the percentage of the population.
    3. Use CourseWaffleFlag for supporting course-level opt-in (during staged rollout) or opt-out (after full rollout) of the feature.
  2. Feature settings. Use Configuration models for more complex settings and non-boolean fields to configure a feature.
    1. Configuration models are based on Django models.
    2. To remove a model-based config field, use a 2-phase deployment strategy where you remove use of it from the code before removing the field with a migration.  See Migration Don'ts.
  3. System settings. Use Django settings for open edX instance/deployment wide configurations that do not change while the server is running.
    1. Add the setting's default value to (lms|cms)/envs/common.py (example).
    2. Override the value in other relevant (lms|cms)/envs/* files (example).
    3. Make sure to update aws.py so the setting can be configurable via JSON files (example).
      1. If the setting is security-sensitive, read its value from AUTH_TOKENS
      2. Else, read the value from ENV_TOKENS

Why are feature flags used?

What alternatives are there?

How feature flags are currently used (simple case):

Feature flag best practices:

Using Waffle

Staged Rollout

You can use Waffle and the edx-platform Waffle Utils to have a staged rollout of a feature using a temporary flag. Typically, the sooner you can reach completion, the better.  Not all stages or capabilities are required.

Definitions:


Early BetaLate Beta (more optional)StableComplete

Use a Waffle Flag to beta test with individual users in Production, both internal and partners. Implement with CourseWaffleFlag or WaffleFlag to enable future rollout capabilities.

Use Waffle Utils Course Override capabilities to add one or more courses to the beta test.

Use Waffle to turn the feature on for everyone in an environment (e.g. edx.org).

Other environments (e.g. edge.edx.org) may lag (or be ahead).

Change the default for the feature to "on" for environments that aren't yet using the flag (e.g. some devstacks, sandboxes, Open edX releases*).

Waffle Utils Course Override could be used to turn the feature off for a course, but this will delay completion, so use sparingly.

The feature has been rolled out to all edX environments. The flag and legacy code should all be removed.

If there is a strong reason to enable the Open edX community to have the same rollout capabilities, consider delaying clean-up until after the next Open edX release.

If you absolutely must support the feature both on and off, transition the Waffle Flag to a more permanent setting or ConfigModel.

Open edX releases*: The aim is for these waffle flags to be short-lived.  However, due to timing or complicated rollouts, you may need to consider how to handle the flag across different Open edX releases as described in the table above.

Testing Waffle Flags

Python Unit Tests:

Bok-choy Testing:

Current edX Feature Flag usage, a step-by-step guide:

Reference: http://martinfowler.com/bliki/FeatureToggle.html