Abstract
This proposes a solution on how to migrate feature-flags/toggles (when GA-ing) into paid privileges for domains that may not have a paid plan or are below the plan that the toggle is being upgraded into.
The solution proposes to migrate the StaticToggle document into a new FrozenToggle document (thereby disabling its Edits in the Edit Toggle UI for further edits) and patch domain_has_privilege with a decorator that checks the FrozenToggle for enablement for a given domain.
Motivation
Currently, we are in the process of GA-ing all the feature flags and deleting them after GA. It is often the case that some of the flags need to be converted into a new privilege under one of the paid subscription plans. The domains that have these flags enabled may not be subscribed to these plans and we might want to still enable the functionality provided via the new privilege to these domains.
There is an existing strategy that has been used to do one of migrations such as ERM migration. This involves creating custom software plans and roles to grandfather the domains under the new privilege. While this works well for one-off cases, it has few below drawbacks.
- Extra custom subscription (role, plan) model objects will need to be created for each of the domains and privilege to be migrated (potentially around the order of Number of Domains X Number of toggles). This could get more complicated as the toggles will be migrated one after another, hence creating custom plans/roles on top of each other to capture various combinations of the feature flags on various domains.
- The process involves multi stage migration.
Given that we want to migrate a large number of toggles, this becomes specially challenging, so a simpler method is desired.
Specification
- A new FrozenToggle class will be added with pretty much the same spec as Toggle class except that the 'enabled_users' attribute on FrozenToggle class (which holds enabled domains also) will be frozen for further modifications.
- The FrozenToggle document will have an additional attribute to hold the new privilege which the flag will be migrated to.
domain_has_privilege function will be updated to check FrozenToggle document to lookup domains that have the toggle enabled historically.
The migration process involves
- removing the
StaticToggle for the feature flag,
- creating a new
FrozenToggle object with the new privilege and
- writing a Django migration that converts the
Toggle document into FrozenToggle document
The migration can be run as part of the migration inside the deploy. After the deploy the toggle will not be available for editing in the UI. So this solution can be deployed in one go without a manual maintenance.
Impact on users
For the purpose of this CEP, this doesn't impact the users directly.
Impact on hosting
There is no manual migrations to be run, so this will be a simpler process.
Release Timeline
This will be implemented as soon as the it is deemed good enough and other the feedback is integrated.
Open questions and issues
- One of the goals of GAing features is to be able to delete all the toggle related code (?). While this solution still requires various Toggle related code in place for now, when we do want to remove the code it will still be possible by converting all the FrozenToggle documents to a simple static JSON documents to lookup the privilege for old domains with historical privilege for a toggle. (Think of
FrozenToggle as a place to keep track of a new privilege and enabled-domains, it can exist without any of the toggle related code when/if we want to)
- This doesn't/can't address the user only feature-flags. As there are only 7 such feature-flags it will need to be dealt in a different way at a different time.
Abstract
This proposes a solution on how to migrate feature-flags/toggles (when GA-ing) into paid privileges for domains that may not have a paid plan or are below the plan that the toggle is being upgraded into.
The solution proposes to migrate the
StaticToggledocument into a newFrozenToggledocument (thereby disabling its Edits in the Edit Toggle UI for further edits) and patchdomain_has_privilegewith a decorator that checks theFrozenTogglefor enablement for a given domain.Motivation
Currently, we are in the process of GA-ing all the feature flags and deleting them after GA. It is often the case that some of the flags need to be converted into a new privilege under one of the paid subscription plans. The domains that have these flags enabled may not be subscribed to these plans and we might want to still enable the functionality provided via the new privilege to these domains.
There is an existing strategy that has been used to do one of migrations such as ERM migration. This involves creating custom software plans and roles to grandfather the domains under the new privilege. While this works well for one-off cases, it has few below drawbacks.
Given that we want to migrate a large number of toggles, this becomes specially challenging, so a simpler method is desired.
Specification
domain_has_privilegefunction will be updated to checkFrozenToggledocument to lookup domains that have the toggle enabled historically.The migration process involves
StaticTogglefor the feature flag,FrozenToggleobject with the new privilege andToggledocument intoFrozenToggledocumentThe migration can be run as part of the migration inside the deploy. After the deploy the toggle will not be available for editing in the UI. So this solution can be deployed in one go without a manual maintenance.
Impact on users
For the purpose of this CEP, this doesn't impact the users directly.
Impact on hosting
There is no manual migrations to be run, so this will be a simpler process.
Release Timeline
This will be implemented as soon as the it is deemed good enough and other the feedback is integrated.
Open questions and issues
FrozenToggleas a place to keep track of a new privilege and enabled-domains, it can exist without any of the toggle related code when/if we want to)