Rails: Migrate workspaces with config_version=1 to config_version=2 for self-managed
MR: !131402 (merged)
Description
In Add support creating and reconciling workspaces... (!129715 - merged) , we added support for reconciling workspaces with config_version=2. This required the following changes
- Existing code of
devfile_parser
/devfile_parser_spec
and been moved todevfile_parser_prev1
/devfile_parser_prev1_spec
. This is required for all workspaces withconfig_version=1
. - The new code in
devfile_parser
/devfile_parser_spec
is for workspaces withconfig_version=2
. - Existing code of
desired_config_generator
/desired_config_generator_spec
and been moved todesired_config_generator_prev1
/desired_config_generator_prev1_spec
. It now callsdevfile_parser_prev1
. This is required for all workspaces withconfig_version=1
. - The new code in
desired_config_generator
is for workspaces withconfig_version=2
.
After a week of that MR landing of production SaaS, there will no longer be any workspaces with config_version=1
on SaaS due to workspace timeout. This issue is created to remove the support for the old config_version
for self-managed as well.
Acceptance Criteria
-
There are no devfile_parser_prev1
/devfile_parser_prev1_spec
/desired_config_generator_prev1
/desired_config_generator_prev1_spec
. -
All non-terminated workspaces in the DB are migrated to config_version=2 -
There is a smooth migration while migrating from config_version=1 to config_version=2
Solution approach
-
Add a new boolean column( force_include_all_resources
) inworkspaces
table. Default value isfalse
. -
Add logic in Rails to send full reconciliation for the workspace if force_include_all_resources
is set totrue
. It would not matter whether the update type from agent is partial/full. Once data is sent to agent, updateforce_include_all_resources
tofalse
for the workspace. -
Create a DB migration which identifies all non-terminated workspaces with config_version=1 and does the following - Set the config_version=2.
- Set the force_include_all_resources=true.
Having the ability to "force to include all resources" for a particular workspace is a good thing. If we feel like something is off about the workspace, we can just set the force_include_all_resources
of the workspace to true
and it will be full reconciled with the agent without waiting for the full update type from agent. This is also useful for migrations of such kinds.