Skip to content

Properly handle full and partial sync

MRs

Why

Context - #396423 (comment 1316886168)

How

  • Add 2 database fields - desired_state_updated_at and sent_to_agent_at.
  • desired_state_updated_at is always updated to current time when desired_state is updated.
  • sent_to_agent_at is always updated whenever we respond to agent with information about the workspace. The information includes config_to_apply or persisted_deployment_resource_version or both
  • For Full Sync, we will send information about all workspaces for that agent.
  • For Partial Sync, we will send information about all workspaces for that agent using the filter desired_state_updated_at >= sent_to_agent_at, defined by the scope Workspace.with_desired_state_updated_more_recently_than_sent_to_agent.
  • Regardless of Full or Partial Sync, we always echo back the persisted resource version of all workspaces that we received from agentk.
  • Fetch from the DB for new/updated/deleted workspaces first and then save the information received from agentk to the DB. This is to ensure that a workspace which was updated by the user and agentk also sends an update about the same workspace in the upcoming poll.

Modelling of different scenarios that can occur for Partial Sync

https://gitlab.com/gitlab-org/remote-development/gitlab-remote-development-docs/-/blob/main/doc/workspace-updates.md

Edited by Chad Woolley