Improve full reconciliation to avoid sending workspaces that are already Terminated
MR: Exclude terminated workspaces from full reconcile (!131853 - merged)
Problem
During full reconciliation of workspace, the Rails logic, currently in ee/lib/remote_development/workspaces/reconcile/persistence/workspaces_to_be_returned_finder.rb
, is
def self.generate_workspaces_to_be_returned_query(agent:, update_type:, workspaces_from_agent_infos:)
# For a FULL update, return all workspaces for the agent which exist in the database
return agent.workspaces.all if update_type == FULL
Now, if 1000 workspace were already created and terminated successfully, then currently we would be sending information about even these workspaces to agentk. Not to mention that we can dramatically improve reduce the records fetched from the DB. As more and more workspaces will be created, this problem will only increase.
Solution
During full reconciliation, send all workspaces for an agent where desired_state != Terminated && actual_state != Terminated
.
Availability and Testing
Ensure updated test coverage in unit/integration/feature tests.