Skip to content

feat(service): make the webhook router stateless #4575

Open

Description

@dan-petty

Problem or Motivation

The roadmap Service Deployment uses Recreate because of its ReadWriteOnce volume (k8s/devops/roadmap-service/deployment.yaml:13-15). No replica is available for 36.9 minutes a day, about 116 s for each rollout. After the sweep item, the router holds no volume and runs no round, so it can run 2 replicas.

Proposed Solution & Architectural Design

  • Remove the volume mount. strategy: RollingUpdate with maxUnavailable: 0 and maxSurge: 1. 2 replicas. A PodDisruptionBudget with minAvailable: 1.
  • The drain finishes only the open HTTP requests. The round drain goes. Remove service.drain_timeout_seconds from the live ConfigMap before the image that drops the setting rolls (a removed setting crash-looped the Service on 2026-11-07).
  • OTEL_RESOURCE_ATTRIBUTES sets service.instance.id=roadmap-service and relies on one pod at a time (deployment.yaml:82-86). Use the pod name as the instance, and sum over instances in the queries.
  • Delete the Mattermost /roadmap command and its handler (owner decision 2026-11-11: it had 0 uses in 7 days; the read-only API, the CLI read and the Grafana dashboard cover the need). No shim.

Removes: the round drain of drain_and_stop (src/devops_cli/server/service.py:889-913), the volume mount, Recreate.

Target Subsystem

Kubernetes & Minikube Automation (k8s/devops/roadmap-service/, src/devops_cli/server/).

Existing Tool Considered

Kubernetes RollingUpdate and PodDisruptionBudget. Cost: about 80,000 tokens and 4 hours to build, about 5,000 tokens a month to keep, about 10,000 tokens to fix. New resources: one more router pod (requests of today).

Acceptance Criteria

  • During a rollout, a delivery sent each second gets 2xx every time (a test sender to the cluster route).
  • Counters do not double or reset in the dashboards across a rollout.
  • Measure: minutes a day with no available router pod, from 36.9 to 0; redeliveries a week near 0.

Dependencies

Source: #4517

Alternatives check of 2026-11-26: in-use.
The repository already uses this tool.
Tool: kubernetes/kubernetes (https://github.com/kubernetes/kubernetes), Apache-2.0, last activity 2026-11-25, maintained.
Reason: Searches found no tool beyond the built-in Kubernetes rollout and disruption-budget features (Argo Rollouts adds unneeded canary steps); those cover the deployment side, while the drain, telemetry and command removals stay code in this repo.

Covers:

  • RollingUpdate with maxUnavailable 0 and maxSurge 1 keeps a pod serving
  • PodDisruptionBudget minAvailable 1 guards voluntary disruptions
  • Pod name as instance id through a fieldRef env value

Lacks:

  • Removal of the round drain in drain_and_stop
  • Dashboard counter queries that sum over instances
  • Deletion of the Mattermost /roadmap command and handler

Owner decision 2026-11-13

The router runs a scoped sweep (due_jobs for one item or PR) for each delivery, and it keeps its refusal of the deliveries of the App. Source: tracker #5482, Phase 4.

  • Live proof: after the merge, a router restart during a unit stops 0 units. A comment gives the unit names and the restart time.

Proposed design

Problem statement

The roadmap-service Deployment uses Recreate because its home volume is ReadWriteOnce. No router pod answers a webhook for 36.9 minutes a day, about 116 s for each rollout. After #4574 the router holds no volume and runs only a scoped sweep for each delivery. This change runs 2 router replicas with RollingUpdate and a PodDisruptionBudget, drains only open HTTP requests, sets service.instance.id from the pod name, sums the dashboard queries over instances, and deletes the unused Mattermost /roadmap command.

Acceptance criteria

Requirement: Stateless rolling deployment

The roadmap-service kustomization SHALL run 2 router replicas with strategy RollingUpdate, maxUnavailable 0, maxSurge 1, no home volume mount, and a PodDisruptionBudget with minAvailable 1.

Scenario: Validate the roadmap-service manifests

  • WHEN uv run devops ci --check --only k8s runs on the change.
  • THEN The check passes with no error about k8s/devops/roadmap-service/.

Requirement: Instance id from the pod name

The roadmap-service Deployment SHALL set service.instance.id from the pod name in OTEL_RESOURCE_ATTRIBUTES.

Scenario: Validate the Deployment env

  • WHEN uv run devops ci --check --only k8s runs on the change.
  • THEN The check passes with no error about the OTEL_RESOURCE_ATTRIBUTES of k8s/devops/roadmap-service/deployment.yaml.

Requirement: Two instances answer a delivery

The router SHALL answer each signed webhook delivery with a 2xx response while more than one router instance serves the route.

Scenario: One delivery to each of two instances

  • WHEN A test sends one signed delivery to each of two router instances.
  • THEN Each response is 2xx and no instance returns a 5xx.

Requirement: A repeated delivery writes nothing twice

The scoped sweep MUST read its marker before it writes, so a delivery that a second instance runs writes nothing twice.

Scenario: Run one delivery twice

  • WHEN A test runs the scoped sweep of one delivery two times on one item.
  • THEN The item gets one comment and one record mark, and the second run sends no write.

Requirement: HTTP-only drain

On SIGTERM the Service SHALL wait only for the open HTTP requests, MUST wait for no round and no worker, and MUST cut the request budget.

Scenario: SIGTERM with a round in flight

  • WHEN A test calls drain_and_stop while a worker holds a round in flight.
  • THEN drain_and_stop returns before the round ends, it waits for no worker, and it cuts the request budget.

Requirement: Counter queries sum over instances

Each devops-cli dashboard panel that reads a roadmap-service counter SHALL aggregate the counter across instances with sum.

Scenario: Validate the dashboard manifests

  • WHEN uv run devops ci --check --only k8s runs on the change.
  • THEN The check passes with no error about k8s/monitoring/dashboards/.

Requirement: Mattermost command removed

The change SHALL delete the Mattermost /roadmap slash command, its bootstrap registration and its webhook handler, and MUST add no shim.

Scenario: Search the source for the command

  • WHEN A test searches the modules under src/devops_cli/ for the /roadmap slash command and reads src/devops_cli/server/routes/webhooks.py.
  • THEN No module registers the /roadmap slash command, and webhooks.py names no Mattermost provider.

Requirement: Pending a person after the merge

After the merge, a person SHALL restart the router during a unit and MUST record the unit names and the restart time in a comment.

Scenario: Restart the router during a unit

  • WHEN After the merge, a person restarts the router pod while a unit runs.
  • THEN No unit stops, and a comment on the issue gives the unit names and the restart time.

Existing Tool Considered

kubernetes/kubernetes (https://github.com/kubernetes/kubernetes), Apache-2.0, maintained. The alternatives check of 2026-11-26 records the verdict in-use and lists what the tool covers and lacks (see the alternatives block in the issue body). The change builds the code that the tool lacks: it removes the round drain, sums the dashboard queries over instances, and deletes the Mattermost /roadmap command and handler. Written cost: about 80,000 tokens and 4 hours to build, about 5,000 tokens a month to keep, about 10,000 tokens to fix, and one more router pod at today's requests.

Key questions

  • Does the router create a unit of work for each delivery, or run a scoped sweep in its own pod?: The router runs a scoped sweep for one item or PR for each delivery in its own pod. It keeps its refusal of the App deliveries. Owner decision 2026-11-13 sets this. (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, src/devops_cli/roadmap/run.py]
    • Chosen: Run the scoped sweep in the router pod. The owner decision of 2026-11-13 sets it, and the work stays in the pod that receives the delivery.
    • Rejected: Create an intake unit for each delivery. A unit adds a pod for each delivery, and the owner decision of 2026-11-13 replaces it.
  • Does the stateless router still mount the ReadWriteOnce home volume?: No. ADR 0021 moves the shared state to valkey-roadmap. The Deployment mounts no volume. (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, k8s/devops/roadmap-service/deployment.yaml:13-15]
  • Which rollout strategy and disruption budget does the stateless router use?: RollingUpdate with maxUnavailable 0 and maxSurge 1, 2 replicas, and a PodDisruptionBudget with minAvailable 1. ADR 0021 sets this for the stateless router. (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, k8s/devops/roadmap-service/deployment.yaml:13-15]
    • Chosen: RollingUpdate with maxUnavailable 0 and maxSurge 1. ADR 0021 sets it for the stateless router, and it keeps one pod available.
    • Rejected: Recreate. It stops every router pod during a rollout and leaves no pod available.
    • Rejected: argoproj/argo-rollouts canary. It adds canary and analysis steps that this item does not need; the built-in strategy covers the rollout.
  • What does the SIGTERM drain wait for after the round leaves the Service?: It waits only for the open HTTP requests. It cuts the request budget so a background scoped sweep ends at its next request. It waits for no worker and no round. (best practice) [sources: src/devops_cli/server/service.py:1109, docs/CLUSTER.md:54, openspec/changes/archive/2026-11-11-4485-a-service-rollout-stops-stage-rounds/proposal.md]
  • Must this change remove service.drain_timeout_seconds from the live ConfigMap before the image rolls?: No. fix(roadmap): a Service rollout stops stage rounds with no record #4485 already removed the setting and its default. ServiceConfig ignores an unknown key, so a live ConfigMap that still holds the key loads. [sources: openspec/changes/archive/2026-11-11-4485-a-service-rollout-stops-stage-rounds/proposal.md, src/devops_cli/config/settings.py, docs/CLUSTER.md:54]
  • How does each router instance identify itself in telemetry, and how do the dashboard queries count across instances?: The Deployment sets service.instance.id from the pod name. Each dashboard query that reads a router counter sums over the instance. A fixed id makes two pods report one instance, so a counter doubles or resets. (best practice) [sources: k8s/devops/roadmap-service/deployment.yaml:82-86, docs/TELEMETRY.md:34, src/devops_cli/telemetry/tracer.py]
    • Chosen: Pod name as service.instance.id, with a sum over instances. Each pod reports a distinct instance, and the sum counts each pod once.
    • Rejected: Fixed service.instance.id=roadmap-service. Two pods report one instance, so a counter can collide or reset.
  • Should the Mattermost /roadmap slash command stay?: No. Delete the command, its bootstrap registration and its webhook handler with no shim. The owner decided this on 2026-11-11 after 0 uses in 7 days, and the read-only API, the CLI read and the Grafana dashboard cover the need. (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, src/devops_cli/server/routes/webhooks.py]
    • Chosen: Delete the command and the handler. It had 0 uses in 7 days, and other read paths cover the need.
    • Rejected: Keep the command. It keeps a provider in a router that must stay small, and no use holds it.
  • How do two router pods keep a repeated delivery from a double scoped sweep?: The scoped sweep reads its marker before it writes. A redelivery that a second instance runs writes nothing twice. The in-memory delivery cache stays a fast path of one pod. (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, src/devops_cli/server/routes/webhooks.py, src/devops_cli/roadmap/run.py]
    • Chosen: Keep the marker read in the scoped sweep. The sweep is already idempotent, and the marker read makes a second run write nothing.
    • Rejected: Move the delivery cache to Valkey. The shared cache adds state and scope, and the marker read already stops a double write.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4574

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/feature
    scope/service
    status/new
    value/high
    effort/medium
    on Nov 11, 2026
  3. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/service. The (service) scope of the title gives the scope.
    • Priority: P2-Medium. It removes 36.9 minutes of daily downtime but is a planned improvement, not a breaking defect.
    • Value: High. It eliminates all rollout downtime and removes redeliveries for users.
    • Effort: Medium. It spans deployment YAML, drain code removal, OTEL attributes, and a Mattermost command deletion.
    • Related: fix(roadmap): a Service rollout stops stage rounds with no record #4485, which asks for a different change. Both work on the Recreate strategy and round drain, but #4485 bounds the drain while this item removes it by making the router stateless.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 818ac6f while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

    The next refine round also looks at the item again when a commit on the default branch changes one of these files: src/devops_cli/server/service.py.

  6. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at c3130a3 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

    The next refine round also looks at the item again when a commit on the default branch changes one of these files: src/devops_cli/server/service.py, src/devops_cli/roadmap/run.py.

  7. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

    Alternatives check: partly

    Reason: Searches found no separate library for this work; the only relevant tool is Kubernetes itself, whose built-in Deployment RollingUpdate strategy and PodDisruptionBudget already provide the zero-downtime rollout and the one-pod availability guarantee the issue describes. They cannot, however, make the application-side changes: removing the round drain and the ConfigMap setting, switching service.instance.id to the pod name and summing dashboard queries, and deleting the Mattermost /roadmap command.

    Tool: kubernetes/kubernetes (https://github.com/kubernetes/kubernetes)

    • License: Apache-2.0
    • Last activity: 2026-11-12
    • Maintained: yes

    Covers:

    • Deployment RollingUpdate with maxUnavailable 0 and maxSurge 1 keeps a router pod serving through a rollout
    • PodDisruptionBudget with minAvailable 1 keeps one router pod available during voluntary disruptions
    • Runs several replicas of a stateless Deployment with no volume, so the Recreate strategy is unnecessary

    Lacks:

    • Removal of the round drain in drain_and_stop (src/devops_cli/server/service.py)
    • Removal of service.drain_timeout_seconds from the live ConfigMap before the new image rolls
    • service.instance.id from the pod name plus dashboard queries that sum over instances
    • Deletion of the Mattermost /roadmap slash command, its bootstrap registration and its webhook handler

    Tools considered:

    Searches run:

    • graceful shutdown drain in-flight HTTP requests Kubernetes SIGTERM library, results: 5
    • Kubernetes Deployment RollingUpdate PodDisruptionBudget zero downtime stateless service, results: 5
    • kubernetes.io PodDisruptionBudget documentation, results: 5
    • kubernetes deployment rolling update maxUnavailable maxSurge documentation, results: 5
    • Argo Rollouts progressive delivery canary deployment, results: 5
    • kubernetes/kubernetes github repository, results: 5
    • opentelemetry service.instance.id pod name resource attributes, results: 5
    • PodDisruptionBudget, results: 5
    • Kubernetes, results: 5

    Sources:

    Checked on 2026-11-12. A person decides what this means for the item. The check changes no label and closes no issue.

  8. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at b15faab while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

  9. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: partly, tool https://github.com/kubernetes/kubernetes. A person decides what the new result means for the item.

    Searches (10)

    Tools considered:

    Searches run:

    • PodDisruptionBudget minAvalable 1 rolling update stateless replicas, results: 5
    • Kubernetes Deployment RollingUpdate maxUnavailable 0 zero downtime webhook service, results: 5
    • Kubernetes PodDisruptionBudget minAvailable rolling update availability, results: 5
    • stateless webhook receiver multiple replicas rolling deployment open source, results: 5
    • Kubernetes Deployment RollingUpdate maxUnavailable 0 maxSurge 1 zero downtime, results: 5
    • kubernetes.io documentation deployments rolling update strategy, results: 5
    • Argo Rollouts canary deployment kubernetes, results: 5
    • Kubernetes rolling update zero downtime guide deployment replicas, results: 5
    • Kubernetes pod disruption budget documentation voluntary disruptions, results: 5
    • site:kubernetes.io rolling update deployment, results: 5

    Sources:

  10. devops-cli-service commented on Nov 26, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

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/p2-mediumscope/servicesource/agentstatus/newtype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions