Repository navigation
fix(metrics): make ClickHouse and Redpanda addons resilient to pod rescheduling - #1459
Merged
Merged
Conversation
…ent to pod rescheduling When GKE node pools roll or pods restart, the ephemeral Redpanda and ClickHouse metrics addons lose the `xmc-metrics` topic and ClickHouse tables (`xmc_metrics`, `xmc_metrics_queue`, and materialized views). Additionally, during GKE upgrades (`deploy-gke.yml`), the `xmc_app` Helm release rolled out `ingestion-gateway-deployment` before `setup_metrics_addons.sh` ran, causing `ingestion-gateway` to fail its single-shot startup topic topology check and blocking the Helm rollout. Key changes: - Mount `deploy/clickhouse/schema.sql` into ClickHouse via ConfigMap `clickhouse-init-scripts` at `/docker-entrypoint-initdb.d/init.sql` with `CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS=1` so schema initialization runs automatically on every container startup. - Add a `postStart` lifecycle hook on the Redpanda container (with `publishNotReadyAddresses: true` on the headless service) to automatically ensure the `xmc-metrics` topic (`128` partitions, `1` replica) is created whenever `redpanda-0` starts. - Add `ValidateTopicTopologyWithRetry` in `ingestiongateway` so startup topic validation retries transiently missing topics or broker readiness errors for up to 30s (bounded by context) before failing. - Pre-provision metrics addons before running `dev_env.py gke-deploy` when upgrading an existing GKE cluster in `deploy-gke.yml`, and expand failure diagnostics to capture pod descriptions and logs across both `xmc` and `xmc-metrics` namespaces. TAG=agy CONV=817ce1b8-5e4c-47e5-839f-333d06bf7842
There was a problem hiding this comment.
Code Review
This pull request introduces a retry mechanism for Kafka topic topology validation (ValidateTopicTopologyWithRetry) and enhances the self-healing capabilities of the in-cluster metrics stack by automating ClickHouse schema initialization and Redpanda topic creation. Feedback on these changes highlights two key improvements: adding defensive parameter validation to the retry function to prevent potential nil pointer panics or CPU-burning busy loops, and removing the optional: true flag from the ClickHouse initialization script volume mount to avoid container startup failures when using subPath with a missing ConfigMap.
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 10:33 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 10:43 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 10:46 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 10:46 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 10:46 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 10:46 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 10:46 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 10:46 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 10:46 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 10:46 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 10:46 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 10:46 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 10:46 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 10:46 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 10:46 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 10:46 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 10:46 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 10:46 — with
GitHub Actions
Inactive
…manifest self-healing
janzak-dev
had a problem deploying
to
xmc-nightly
October 28, 2026 13:09 — with
GitHub Actions
Failure
Gate ClickHouse pod readiness on HTTP /ping (port 8123) so Kubernetes rollouts and Service endpoints wait until /entrypoint.sh finishes running /docker-entrypoint-initdb.d/init.sql on its loopback-only bootstrap server and starts the main ClickHouse server. TAG=agy
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 13:20 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 13:30 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 13:33 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 13:33 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 13:33 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 13:33 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 13:33 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 13:33 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 13:33 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 13:33 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 13:33 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 13:33 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 13:33 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 13:33 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 13:33 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 13:33 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 13:33 — with
GitHub Actions
Inactive
janzak-dev
temporarily deployed
to
xmc-nightly
October 28, 2026 13:33 — with
GitHub Actions
Inactive
janzak-dev
marked this pull request as ready for review
October 28, 2026 13:45
janzak-dev
enabled auto-merge
October 28, 2026 13:48
AntonTyb
approved these changes
Oct 28, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardens the in-cluster ClickHouse and Redpanda metrics addons and the GKE deployment workflow against pod rescheduling and node pool rollouts.
Motivation & Context
During the
XMC Nightly buildrun (Run 40612800311), a GKE node pool update rescheduledredpanda-0andclickhouse-0onto new nodes. Because the lightweight dev/CI metrics addons use ephemeral storage,redpanda-0came up without thexmc-metricstopic andclickhouse-0came up without thexmc_metricstables and materialized views.In
.github/workflows/deploy-gke.yml, theExecute GKE Deployment Pipelinestep (xmc_appHelm release withwait: true) executed beforeDeploy Metrics Addons (ClickHouse & Redpanda)(setup_metrics_addons.sh). Wheningestion-gateway-deploymentrolled out, its startup check (ValidateTopicTopology) failed becausexmc-metricswas missing on the rescheduledredpanda-0pod, causingingestion-gatewayto enterCrashLoopBackOff. This caused thexmc_appHelm release to time out after 10 minutes and preventedsetup_metrics_addons.shfrom running, leavingxmc_metricsmissing in ClickHouse for all subsequentNightly Examples E2E Test Suitejobs (Run 40629962765).Key Changes
deploy/addons/metrics/):deploy/addons/metrics/setup_metrics_addons.shanddeploy/addons/metrics/clickhouse/README.mdto create ConfigMapclickhouse-init-scriptsfromdeploy/clickhouse/schema.sqland ensure bothxmcandxmc-metricsnamespaces exist upfront.deploy/addons/metrics/manifests/metrics-addons.yamlto mount theclickhouse-init-scriptsConfigMap at/docker-entrypoint-initdb.dwithCLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS=1, soclickhouse-0automatically appliesschema.sql(CREATE TABLE/VIEW IF NOT EXISTS) on every pod startup or restart.readinessProbe(/pingon port8123) toStatefulSet/clickhouseso Kubernetes rollouts and service endpoints wait until/entrypoint.shfinishes running/docker-entrypoint-initdb.d/init.sqlon its loopback-only bootstrap server and starts the main ClickHouse server.deploy/addons/metrics/manifests/metrics-addons.yaml):publishNotReadyAddresses: trueon the headlessService/redpandasoredpanda-0.redpanda.xmc.svc.cluster.localresolves during container startup hooks.lifecycle.postStarthook toStatefulSet/redpandathat polls untilrpk topic describe xmc-metricsorrpk topic create xmc-metrics --partitions 128 --replicas 1succeeds on every pod start (and before Kubernetes marks the container Ready).deploy/clickhouse/schema_test.py(and exported the manifest/script files indeploy/addons/metrics/BUILD.bazelanddeploy/clickhouse/BUILD.bazel)..github/workflows/deploy-gke.yml):Pre-Deploy Metrics Addons on Existing Clusterstep beforeExecute GKE Deployment Pipelineso existing clusters reconcile Redpanda and ClickHouse beforexmc_approlls outingestion-gateway-deployment.Collect Diagnostics on Failureto capture pod statuses, descriptions, and current/previous container logs across all pods in bothxmcandxmc-metricsnamespaces.Assumptions
clickhouse/clickhouse-server:24.3-alpine/entrypoint.shexecutes/docker-entrypoint-initdb.d/*.sqlviaclickhouse-client --multiqueryon a loopback-only (127.0.0.1) bootstrap server on every container start whenCLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS=1is set, and only listens on<PodIP>:8123(/ping) once initialization finishes and the main ClickHouse server starts.docker.redpanda.com/redpandadata/redpanda:v24.1.1includes/bin/sh,rpk,seq, andsleepfor thepostStarttopic creation hook.Verification & Testing
bazel test //deploy/clickhouse/...(passed).HEAD(ba25d6981) viaXMC Nightly build(Run 40695549515) andNightly Examples E2E Test Suite(Run 40697009915) — all 16 example workloads passed../tools/analyze_diff_size.py --base-ref origin/main...(86 prod lines in deploy/workflow manifests, 14 test lines, 4 doc lines — zero Go application binary changes).Related Issues / Bugs
TAG=agy
CONV=817ce1b8-5e4c-47e5-839f-333d06bf7842