fix: relax git auto-pull polling only once the webhook has delivered

Merged
HU
19h ago
+143-15

Summary

Git auto-pull relaxed its safety-net poll from ~1 min to ~10 min as soon as a repository webhook was registered. Registering only proves Windmill can reach the git host; it says nothing about the host reaching Windmill. On an instance that can call GitHub but that GitHub cannot call back (a typical air-gapped setup), the hook was created, every delivery failed, and new commits took up to 10 minutes to deploy, while the card claimed "Syncing instantly via webhook".

Polling now relaxes only once the hook has actually delivered to this instance, and drops back to every minute when a poll finds a head no delivery brought.

Changes

  • AutoPullSettings.webhook_verified_id: the webhook_id a delivery last arrived for. It is server-owned: sanitized from client saves, carried across settings saves, and stripped from the settings export. A newly registered hook has a new id, so it starts unverified without touching the hook create/delete paths.
  • effective_poll_interval_s relaxes to 600s only when webhook_verified_id == webhook_id.
  • GitHub and GitLab receivers (EE) record the id after a delivery authenticates. This happens once per hook, not per delivery, and is best-effort so it can never fail a delivery. GitHub's ping on hook creation verifies a reachable instance within seconds. GitLab sends no ping, so a GitLab repo polls every minute until its first push delivery.
  • The poller clears the id when it has to enqueue a pull for a verified hook, meaning the webhook missed that push. It skips this while the last pull failed: a failed pull rolls its synced sha back, which would otherwise look like a missed delivery and retry the failing pull every minute.
  • set_auto_pull_webhook_verified_id does a targeted jsonb write, guarded against jsonb_set NULLing git_sync.
  • Repository card: says "Syncing instantly via webhook" only for a verified hook. Otherwise it says it checks every minute until the webhook delivers.

Known ceilings:

  • If GitHub's ping lands before the new hook id is persisted, it is ignored, and the repo keeps 60s polling until the first push delivery. That costs extra polling, not missed changes.
  • A webhook that breaks after working costs at most one 10-minute delay before polling tightens again.

Test plan

  • Unit: test_effective_poll_interval covers an unverified hook, a stale verified id from an older hook, and a verified hook.
  • EE backend (quickjs,enterprise,private), local smart-HTTP git remote, with state planted by SQL:
    • A signed ping with a bad signature returns 401 and leaves the id unset.
    • A valid signed ping returns 200 and sets webhook_verified_id=777.
    • A push with no delivery: the next poll enqueues the pull, clears the id, and logs moved without a webhook delivery. The rest of git_sync is intact.
    • Verified hook with a failed last pull: the poll re-enqueues and the id stays. With a successful last pull it is cleared.
  • UI: the card text for unverified and verified hooks (below).

Screenshots

Hook registered, no delivery yet:
ui-unverified

Hook verified:
ui-verified

Follow-up (separate PR): remove AutoPullMode. No UI ever set it, and with polling now a reliable baseline every repo can create a hook when it can hold one and always poll.

šŸ¤– Generated with Claude Code


Summary by cubic

Git auto-pull now relaxes its polling interval only after the webhook has actually delivered to the instance, not when the webhook is registered. This prevents a 10-minute deployment delay on air-gapped setups where the host can reach Windmill but not the reverse.

  • Adds a server-owned webhook_verified_id to AutoPullSettings, sanitized from client saves and stripped from settings exports. Polling stays at every minute until the current webhook_id matches it.
  • The poller clears the verified id when it finds a fresh head that no delivery brought, falling back to 60-second polling. It skips clearing after a failed pull and for a ref's first sync, which no delivery could have brought.
  • The repository card says "Syncing instantly via webhook" only for a verified hook; otherwise it states minute-cadence polling until the webhook delivers.