Rails: Update the reconciliation logic to send information about workspaces with desired state as Terminated in every reconciliation
MR:Rails: Update the reconciliation logic to send ... (#519257 - closed)
Description
Currently, when we want to terminate a workspace, we send the following information from Rails to Agent among other things - desired_state and the config_to_apply. The agent check if the desired_state is Terminated and if yes, it deletes the namespace of the workspace. This leads to a cascading delete of all the resources in the namespace. The agent completely ignores the config_to_apply value when the desired_state of the workspace is Terminated.
Because the agent currently relies on deleting the namespace directly, it was okay for us to not send information about workspaces with desired_state == Terminated && actual_state != Terminated in every reconciliation loop. However, with the changes introduced in Rails: Update the reconciliation logic to send ... (#519257 - closed) , we updated the value of the config_to_apply to be all the inventory config maps of the workspaces. In order to support this approach, we need to send information about workspaces with desired_state == Terminated && actual_state != Terminated in every reconciliation loop. This is in sync with the general behaviour of the reconciliation loop where Rails will respo
Acceptance criteria
-
Workspaces with desired_state == Terminated && actual_state != Terminatedare sent back in every reconciliation loop.
Implementation plan
- ~~Update
RemoteDevelopment::WorkspaceOperations::Reconcile::Output::ResponsePayloadBuilderto never send anilvalue. The response should always be a string. ~~- NOTE: This change to return a string has already been merged: !180824 (diffs)
- Update its
should_include_config_to_apply?function to include workspaces withdesired_state == Terminated && actual_state != Terminated. - Update
RemoteDevelopment::WorkspaceOperations::Reconcile::Persistence::WorkspacesToBeReturnedFinder'sgenerate_workspaces_to_be_returned_queryfunction to include workspaces withdesired_state == Terminated && actual_state != Terminated.
Here is a reference spike implementation - Draft: Spike: Workspaces in a single namespace (!181086 - closed)