Skip to content

feat(service): Roll each Service release with no webhook gap #6058

Closed

Description

@dan-petty

Problem

The roadmap Service deploys with strategy: Recreate and 1 replica (k8s/devops/roadmap-service/deployment.yaml): the old pod drains for up to 600 s (grace 660 s) and stops, and only then the new pod starts. While no pod is ready, GitHub webhook deliveries fail: 5 of the 40 deliveries before 22:08Z on 2026-11-16 got HTTP 503, during the rollout of release 0.169.1. A failed delivery is not sent again by GitHub, so each rollout loses events, and a poll must repair them with GitHub budget. The project ships about 19 releases a day (owner decision of 2026-11-13), so the gap repeats often.

The Service holds singleton state: the home volume roadmap-service-home (ReadWriteOnce, local-path) with the schedule and budget files, and one in-process GitHub budget and set of rows. Two pods at once would run each row twice and spend the budget twice.

Owner, 2026-11-16: "we should do rolling releases with health checks before cutting traffic for the service".

Expected behavior

  • A release of the Service rolls with no gap: the new pod starts, passes its readiness check, and gets traffic before the old pod stops getting it (RollingUpdate, maxUnavailable: 0, readiness gates the traffic, a PodDisruptionBudget).
  • The webhook route answers during the whole rollout: no 5xx from the Service for a signed delivery (measured on the hook deliveries during a release).
  • The rows run once at a time: one pod holds a Kubernetes Lease (or an equal lock), the new pod takes the rows only after the old pod releases them, and a kill of the holder lets the other pod take them after the lease ends.
  • The state that two pods need is in Valkey or in the Lease, not on a ReadWriteOnce volume, or the design says why a part can stay.
  • A test of the manifests holds the strategy and the probes; a live check of one release shows no 5xx on the hook.

Related

Proposed design

Problem statement

The Service runs one pod with strategy: Recreate. Each release drains the old pod for up to 600 s and starts no new pod. During that time GitHub webhook deliveries get HTTP 503, and GitHub does not send them again. The change makes the Deployment roll with two replicas, maxUnavailable: 0 and a readiness gate. It adds a PodDisruptionBudget and a Kubernetes Lease, so two pods never run a row twice.

Acceptance criteria

Requirement: Rolling update strategy

The roadmap-service Deployment SHALL run two replicas with RollingUpdate, maxUnavailable: 0 and maxSurge: 1.

Scenario: Manifest holds the rollout strategy

  • WHEN The check reads k8s/devops/roadmap-service/deployment.yaml.
  • THEN The check finds replicas: 2, strategy.type: RollingUpdate, rollingUpdate.maxUnavailable: 0 and rollingUpdate.maxSurge: 1.

Requirement: Probes gate the traffic

The roadmap-service Deployment SHALL keep a readiness probe on /readyz and a liveness probe on /healthz, each on port 8000.

Scenario: Manifest holds both probes

  • WHEN The check reads the container of the Deployment.
  • THEN It finds the readiness probe path /readyz and the liveness probe path /healthz, each on port 8000.

Requirement: Follower reports ready

A Service pod that does not hold the Lease SHALL answer /readyz with HTTP 200.

Scenario: Second pod is ready without the Lease

  • WHEN Two Service instances start and the first takes the Lease.
  • THEN GET /readyz on the second returns 200, and the second runs no row.

Requirement: Only the holder runs a row

The Service SHALL run a row and write the schedule and budget files only on the pod that holds the Lease.

Scenario: Due row on both pods

  • WHEN The Lease holder and the follower both have a due row.
  • THEN Only the holder runs the row, and the follower runs none until it takes the Lease.

Requirement: Lease takeover after a kill

A Service pod SHALL take the Lease after the holder stops renewing it, and run each row once.

Scenario: Holder is killed

  • WHEN The holder is killed with no release, and the other pod waits.
  • THEN The other pod takes the Lease after leaseDurationSeconds and runs the row once.

Requirement: Readiness fails on SIGTERM

On SIGTERM the Service SHALL fail /readyz at once, finish the current row, and release the Lease before the process exits.

Scenario: Stop during a row

  • WHEN The pod receives SIGTERM while a row runs.
  • THEN /readyz returns 503 at once, the row ends, the Lease is released, and the process exits within terminationGracePeriodSeconds.

Requirement: Pod disruption budget

The manifest set SHALL hold a PodDisruptionBudget that keeps one roadmap-service pod available during a node drain.

Scenario: Budget selects the Service pods

  • WHEN The check reads k8s/devops/roadmap-service/pdb.yaml and k8s/devops/roadmap-service/kustomization.yaml.
  • THEN The budget selects app.kubernetes.io/name: roadmap-service with minAvailable: 1, and the kustomization lists the file.

Requirement: Role grants the Lease

The roadmap-service Role SHALL grant get, create, update and patch on leases in the coordination.k8s.io API group.

Scenario: Role rule for leases

  • WHEN The check reads k8s/devops/roadmap-service/role.yaml.
  • THEN It finds a rule with apiGroups: [coordination.k8s.io], resources: [leases] and the four verbs.

Requirement: Instance id per pod

Each roadmap-service pod SHALL set service.instance.id to its own pod name.

Scenario: Instance id comes from the pod

  • WHEN The check reads the environment of the container.
  • THEN OTEL_RESOURCE_ATTRIBUTES takes the downward API field metadata.name, and no fixed service.instance.id=roadmap-service stays.

Requirement: No 5xx on the hook during a release

The Service SHALL answer each signed webhook delivery with no 5xx status during a release.

Scenario: One release rolls

  • WHEN A release rolls and the check reads the recorded hook deliveries of its window.
  • THEN No delivery has a 5xx status from the Service.

Requirement: Spec holds the two-replica requirement

The change SHALL replace the requirement The Service runs as one pod with the two-replica rollout requirement.

Scenario: Spec after the archive

  • WHEN The change is archived.
  • THEN openspec/specs/roadmap-service-deployment/spec.md holds the rollout requirement and no requirement that the Service runs as one pod.

Existing Tool Considered

No alternatives check has run. The need is a single-active-runner lock and a rolling Deployment. The open, maintained tool is the coordination.k8s.io/v1 Lease API, reached through the official kubernetes Python client that the Service already uses to reach the API server. It lacks a Python leader-election loop, because only client-go ships one. The project writes a renew loop of about 100 lines and its tests: about 25k tokens to build, keep and fix that code, and about one day of elapsed work. The Deployment, the PodDisruptionBudget and the probes need no code, because they are manifest fields.

Key questions

  • Which rollout strategy and replica count does the Service use?: Use RollingUpdate with replicas: 2, maxUnavailable: 0 and maxSurge: 1, and a PodDisruptionBudget with minAvailable: 1. ADR 0021 records this target for the Service, and the owner asked on 2026-11-16 for rolling releases with health checks before the traffic moves. (best practice) [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:33, k8s/devops/roadmap-service/deployment.yaml]
    • Chosen: RollingUpdate, 2 replicas, maxUnavailable 0. ADR 0021 names it, and one pod always answers the webhook route.
    • Rejected: Recreate with a preStop hold. One pod stops before the next starts, so the webhook gap stays.
    • Rejected: RollingUpdate, 1 replica, maxUnavailable 1. The only pod stops before the new pod is ready, so the gap stays.
  • How does the Service keep the rows to one pod at a time?: The pod takes a coordination.k8s.io/v1 Lease before it runs a row, and it renews the Lease. Only the holder runs rows and writes the state files. The follower serves the webhook route and the read-only API, and it reports ready. Use leaseDurationSeconds: 30, renewDeadline: 20 and retryPeriod: 5: a killed holder is replaced within 30 s, and a live holder keeps the Lease. (best practice) [sources: k8s/devops/roadmap-service/deployment.yaml, k8s/devops/roadmap-service/role.yaml]
    • Chosen: Kubernetes Lease through the official Python client. The Service already holds a service account and an API token, and the Lease outlives a Valkey outage.
    • Rejected: Valkey lock through the Valkey client. The Service already reaches Valkey, but the lock adds a second failure domain and no fencing token.
    • Rejected: No lock, one pod by hand. Argo CD self-heals the replica count, and a rollout starts a second pod.
  • Where do the schedule and budget files live while two pods run?: They stay on the roadmap-service-home volume. The local-path volume binds to the node where the pod first runs, so the second pod lands on that node and mounts the same files. The Lease makes the holder the only writer, so the follower writes no file and runs no row. The move to Valkey stays with feat(service): share the GitHub budget and holds in Valkey #4563 and feat(roadmap): move Service work to Workflows and Valkey #4517. (best practice) [sources: k8s/devops/roadmap-service/deployment.yaml, k8s/devops/roadmap-service/pvc.yaml, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:33]
  • Must /readyz wait for the Lease?: No. /readyz reports that the process can serve HTTP. If it waited for the Lease, the new pod would never be ready, and with maxUnavailable: 0 the old pod would never stop. The rollout would stall. (best practice) [sources: k8s/devops/roadmap-service/deployment.yaml]
    • Chosen: Readiness reports the HTTP server only. The new pod takes traffic before it takes the rows, so the gap closes.
    • Rejected: Readiness includes the Lease. The old pod holds the Lease until SIGTERM, so the new pod is never ready and the rollout deadlocks.
  • What must the pod do on SIGTERM?: Fail /readyz at once, so the endpoint is removed. Finish the current row, release the Lease, drain the in-flight requests and exit. Keep the 600 s drain and the 660 s grace period: the new pod serves the webhook route during the drain, and fix(roadmap): a Service rollout stops stage rounds with no record #4485 set those values. (best practice) [sources: k8s/devops/roadmap-service/deployment.yaml]
    • Chosen: Fail readiness at once, then drain. The endpoint goes away before the pod stops, so no delivery reaches a draining pod.
    • Rejected: Keep readiness true during the drain. New deliveries reach the draining pod and get 503.
    • Rejected: Shorten the drain. A shorter drain cuts the rows that are in flight, and fix(roadmap): a Service rollout stops stage rounds with no record #4485 set the value.
  • What changes in the metrics identity when two pods run?: Each pod sets service.instance.id to its own pod name from the downward API field metadata.name. The fixed value roadmap-service merges two pods into one series. (best practice) [sources: k8s/devops/roadmap-service/deployment.yaml, CONTEXT.md]
    • Chosen: Set service.instance.id to the pod name. The manifest comment says the fixed id holds only for one replica and the Recreate strategy.
    • Rejected: Keep the fixed service.instance.id. Prometheus then merges two pods into one series, and the breakdown panel shows one line.
  • Which check holds the manifests?: Add a gate check under tests/gate/k8s_checks/ that reads the shipped manifests and asserts the strategy, the replicas, the probes, the PodDisruptionBudget, the Lease rule and the instance id. (best practice) [sources: tests/gate/k8s_checks/gateway_database.py, k8s/devops/roadmap-service/deployment.yaml]
    • Chosen: A gate check under tests/gate/k8s_checks/. The gate checks read the shipped manifests against the deployment requirements.
    • Rejected: A unit test under tests/commands/k8s/. It tests the command, not the manifests that the cluster runs.
  • Does the change update the spec requirement that the Service runs as one pod?: Yes. The change's spec delta replaces The Service runs as one pod with the two-replica rollout requirement. Without that, the gate check and the spec contradict the manifest. (best practice) [sources: openspec/specs/roadmap-service-deployment/spec.md]
    • Chosen: Replace the requirement in the spec delta. The spec and the manifest then agree on two replicas and the rolling update.
    • Rejected: Keep the requirement and the one-pod manifest. The Service keeps the gap, and the change delivers nothing.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/feature
    source/agent
    on Nov 16, 2026
  2. dan-petty commented on Nov 16, 2026

    @dan-petty
    OwnerAuthor
    • Priority: P1-High. Webhook deliveries fail with 503 on every rollout (19 per day) and GitHub does not redeliver them, causing recurring data loss and increased error rate.
    • Related: feat(service): make the webhook router stateless #4575, which asks for a different change. Both change the roadmap Service Deployment from Recreate to RollingUpdate in the same file, but #4575 targets only the stateless router component while the candidate covers the full Service including stateful row execution, Lease locking, a
  3. added
    status/new
    effort/medium
    value/high
    scope/service
    priority/p1-high
    owner/agent
    on Nov 16, 2026
  4. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.

  5. dan-petty commented on Nov 16, 2026

    @dan-petty
    OwnerAuthor

    The service design patterns of #6059 (docs/SERVICE_PATTERNS.md) give the rules that this item applies first. The points for the plan:

  6. dan-petty commented on Nov 17, 2026

    @dan-petty
    OwnerAuthor

    Returned: this item cannot be built in one pull request as written

    The owner comment of 2026-11-16 asks for RL1 to RL3, WK2, IN1 and ST2 of docs/SERVICE_PATTERNS.md. IN1 and ST2 put the state that two pods share into the Valkey coordination keys of #4563, not on the ReadWriteOnce volume. That state is the list of ADR 0021 (line 87), and #4563, #4574 and #4575 own its move. Thus this item cannot meet RL1, IN1 and ST2 without their work. No code was written. Checked on main at ddaa91c.

    What forces one pod and Recreate today

    # Singleton Where Effect with two pods Owner
    1 Volume roadmap-service-home: ReadWriteOnce, local-path. The live PV has nodeAffinity kubernetes.io/hostname In [condor]. k8s/devops/roadmap-service/pvc.yaml:13-17, deployment.yaml:185-187 Both pods must run on condor. A PodDisruptionBudget with minAvailable: 1 then stops each drain of condor: the evicted pod cannot start on another node, so the second eviction never gets permission. #4575
    2 The planner run Job mounts the same claim, read only. k8s/devops/roadmap-service/cronjob-planner-run.yaml:104-107 It must also run on condor. #4517
    3 The lane queues are in process memory. The webhook route adds each delivery to the workers of its own pod. src/devops_cli/server/service.py:475-786, :922-955; src/devops_cli/server/routes/webhooks.py:265-323 A delivery to the pod that has no Lease has no path to the holder. About half of the 780 webhook triggers of the last 24 h (devops_cli_service_triggers_total) then wait for the next poll of the holder: 151 s, or 600 s for an idle repository (src/devops_cli/config/defaults.py:1315-1317). That breaks IN5. #4575 (due marks, units), #4574
    4 The delivery ids are in process memory (LRU). webhooks.py:347-363, :574; service.py:849 A redelivery to the other pod runs a second time (IN4). #4563
    5 The request budget window is a file and a deque. The constructor reads the file one time. service.py:210-353, :245; src/devops_cli/config/constants.py:1838 The second pod reads an old copy. Its next write removes the requests of the first pod. #4563
    6 The identity halt is a file that the constructor reads one time. The GraphQL hold is in memory only. service.py:356-472, :389-390, :462-464; constants.py:1837 A halt or a hold of one pod does not stop the other pod. #4563
    7 The poll timer and the idle state are in process memory. service.py:788-810, :837, :882-920 Two pods poll two times. #4574
    8 The schedules, the intake record, the row queues, and the release, conflict and watch ledgers of each repository. src/devops_cli/roadmap/run.py:367, :573, :617, :646, :691, :916, :945, :1292, :2032; constants.py:3756-3768 Two writers, or a reader with an old copy. #4517, #4563
    9 The failure ledgers and the stage plan records. run.py:2145; src/devops_cli/roadmap/implement/consecutive_failures.py:134; src/devops_cli/roadmap/stage/stage_plan_record.py:208-214 Same as row 8. #4517, #4563
    10 The listing snapshots and the lane clones. The start of a pod removes the retired ones. src/devops_cli/roadmap/stores/listing_snapshot.py:213-235; run.py:2167-2190; src/devops_cli/commands/serve.py:155 A new pod can remove a clone that the old pod still uses. #4517
    11 uvicorn 0.54.0 closes its socket before the lifespan stop that runs the 600 s drain. uvicorn/server.py:284-311; service.py:1164-1169 The old pod refuses connections during its drain. A rolling release needs a short preStop sleep (RL3). this item
    12 service.instance.id=roadmap-service is a fixed value. deployment.yaml:124-128 Two pods give one series. this item
    13 The spec requirement "The Service runs as one pod". openspec/specs/roadmap-service-deployment/spec.md:8-13 It contradicts a second replica. this item

    Rows 3 to 10 are the state that two pods share. ADR 0021 (line 87) and #4563 move it to valkey-roadmap. That instance does not exist: k8s/llm/ holds only valkey.yaml, valkey-devops.yaml and valkey-runs.yaml. It needs three new passwords that a person pushes before the merge. #4563 gives its own cost as about 200,000 model tokens and 9 hours. ST2 does not let coordination keys go to valkey-devops, because that instance can evict keys.

    Rejected options

    • Two replicas, a PodDisruptionBudget, and the volume kept (the refine design). Row 1: the budget stops each drain of condor. Row 3: about half of the deliveries wait for a poll. The owner comment also says "not to a ReadWriteOnce volume".
    • Readiness that waits for the Lease. With maxUnavailable: 0 the new pod never gets ready, so the rollout stops.
    • A holder label on the pod, and a Service that selects it. The Role then needs patch on each pod of namespace devops. During the 600 s drain no ready pod has the label, so the gap stays.
    • The follower sends each delivery on to the holder. This is custom glue that feat(service): make the webhook router stateless #4575 removes, and it fails while the holder drains.

    Proposed split

    Each step delivers value.

    1. This item, smaller: a surge release with a Lease handover. Set replicas: 1 and RollingUpdate with maxSurge: 1 and maxUnavailable: 0. The new pod mounts the same volume on condor (ReadWriteOnce lets two pods on one node mount it). It passes /readyz and gets traffic before the old pod gets SIGTERM. A preStop sleep of 10 s lets the endpoint go before uvicorn closes its socket (10 + 600 + 30 s stays inside the grace period of 660 s). A Lease roadmap-service-rows (coordination.k8s.io/v1) holds the rows: a pod reads the state files, removes the retired clones, and starts its workers and its poll only after it takes the Lease. It gives the Lease back after drain_and_stop, and a killed holder loses it after leaseDurationSeconds. While a pod waits for the Lease, its lane queues keep the deliveries, and it runs them when it takes the Lease. service.instance.id comes from the pod name. docs/CLUSTER.md records the RL1 exception (one replica, no PodDisruptionBudget, a node drain still makes a gap) and links feat(service): make the webhook router stateless #4575. Value: no webhook gap at a release, about 19 times a day. It meets RL2, RL3, RL4 and WK2, and RL1 through its exception clause. It does not meet IN1 or ST2. It removes no setting and adds no credential.
    2. feat(service): share the GitHub budget and holds in Valkey #4563. valkey-roadmap, with the windows, the holds, the halt and the delivery ids. A person runs devops k8s push-secrets before the merge.
    3. feat(roadmap): run the reconcile sweep on a cluster schedule #4574. The sweep on a cluster schedule. The rows and the poll leave the Service pod.
    4. feat(service): make the webhook router stateless #4575. A stateless router: two replicas, a PodDisruptionBudget with minAvailable: 1, no volume. The Lease of step 1 goes. This step meets RL1 in full, IN1 and ST2, and it also closes the gap at a node drain.

    A person decides if step 1, with its RL1 exception, is acceptable. If yes, the refine job can write the design of this item again as step 1.

  7. dan-petty commented on Nov 17, 2026

    @dan-petty
    OwnerAuthor

    Owner decision, 2026-11-17 (direct answer: "proceed as recommended"): build step 1 of the split in the return comment above as this item. Steps 2 to 4 stay with #4563, #4574 and #4575.

    Scope of #6058 (step 1):

    • Manifest: replicas: 1, RollingUpdate with maxSurge: 1 and maxUnavailable: 0. The new pod shares the RWO volume on the same node.
    • Shutdown: a preStop sleep of 10 s before the 600 s drain, inside the 660 s grace period, because uvicorn closes its socket before the lifespan stop.
    • Lease roadmap-service-rows (coordination.k8s.io/v1): a pod reads its state files and starts its workers and the poll only when it holds the Lease. It gives the Lease back after the drain. A pod that waits for the Lease keeps deliveries in its lane queues, and runs them when it gets the Lease. Readiness does not wait for the Lease, so the rollout does not deadlock.
    • Telemetry: service.instance.id comes from the pod name.
    • docs/CLUSTER.md and docs/SERVICE_PATTERNS.md record the RL1 exception (one replica, no PDB, a node drain still makes a gap) and link feat(service): make the webhook router stateless #4575. The spec "The Service runs as one pod" changes to state the Lease holder.

    Proof: an integration test of the Lease handover and of a killed holder that loses the Lease after its duration, against a contract fake of the Lease API; an integration test that SIGTERM fails /readyz, ends the drain and gives back the Lease; kubectl kustomize with kubeconform for the manifest. No test that reads the manifest (#6060).

    Live check after the deploy: zero 5xx in the GitHub hook deliveries during one release, and one Lease holder at a time.

  8. added
    status/in-progress
    and removed
    status/new
    on Nov 17, 2026
  9. dan-petty commented on Nov 17, 2026

    @dan-petty
    OwnerAuthor

    Pull request #6112 (for #6068) runs kube-linter no-rolling-update-strategy in CI. Deployment devops/roadmap-service holds the annotation ignore-check.kube-linter.io/no-rolling-update-strategy (reason: Recreate until this item). When this item sets RollingUpdate, remove that annotation: the kube-linter row of devops ci then checks the strategy, and the readiness probe with no-readiness-probe. No test that reads the manifest is necessary.

  10. added
    status/in-review
    and removed
    status/in-progress
    on Nov 17, 2026
  11. removed
    status/in-review
    owner/agent
    on Nov 17, 2026
  12. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor
  13. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-17 08:08 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p1-highscope/servicesource/agenttype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions