Skip to main content

GitOps sync

Sync is how Grid’s inventory catches up with Git. It is pull-based reconciliation of desired-state JSON, not a CD pipeline that auto-applies Terraform.

Configuration​

Variable / settingMeaning
GRID_GITOPS_REPO_URLRemote intent repository
GRID_GITOPS_BRANCHBranch to track (default main)
GRID_GITOPS_PATHOptional subdirectory (relative; no ..)
GRID_GITOPS_SYNC_INTERVAL_SECAuto interval; default 600 when a URL is set; 0 = manual only
GRID_CONFIG_ROOTWorking tree on the control plane

Console: Admin → Sources (desired-state + module bank). Infrastructure also exposes a sync / drift panel for the current workspace.

What Sync does​

  1. Ensures GRID_CONFIG_ROOT matches the remote (fetch + reset tracked files to origin/<branch>).
  2. Walks JSON units under the path prefix.
  3. For each unit: create, update content hash, or leave unchanged.
  4. For previously tracked paths missing from Git: set status stale.
  5. Never auto-destroys cloud resources.

Untracked paths such as generated archive/ are left alone on reset.

Stale vs destroyed​

StatusMeaningTypical next step
pending / running / …Active inventoryPlan / apply as usual
staleJSON gone (or marked missing) but unit may still exist in cloudRestore JSON, or explicit Destroy, or remove after cleanup
destroyedDestroy completedUsually dropped from active counts

Removing a file from Git is a signal, not a delete in the cloud.

Desired ahead / drift​

SignalMeaning
Content hash ≠ last applied hash (desiredAhead)Git intent changed since last successful apply
terraform plan wants changesLive/state differs from current generated desired
Empty planLive matches current desired

Drift check APIs compare those signals; reverse-engineering full Grid JSON from state is not fully automated.

Unit identity during sync​

  • Default id = UUID v5(path) — durable across store wipe if the path is unchanged
  • Optional metadata.id only if you set it yourself
  • See Unit JSON

Concurrency​

  • Manual Sync fails fast if another sync is in progress.
  • Interval sync skips a tick if busy (no queue pile-up).
  • Failures wait for the next interval; they do not tight-loop retry.

API surface​

MethodPath
GET/api/v1/gitops/status
GET / PUT/api/v1/gitops/settings
POST/api/v1/gitops/sync
POST/api/v1/infrastructures/:id/drift-check

Repo URLs with embedded credentials are redacted in API responses.