Skip to content

feat(chart): pre-upgrade hook migrates otel_traces schema (ScopeName cols) - #545

Merged
blue4209211 merged 2 commits into
mainfrom
feat/clickhouse-schema-pre-upgrade-hook
Jul 17, 2026
Merged

feat(chart): pre-upgrade hook migrates otel_traces schema (ScopeName cols)#545
blue4209211 merged 2 commits into
mainfrom
feat/clickhouse-schema-pre-upgrade-hook

Conversation

@mayankpande88

Copy link
Copy Markdown
Contributor

Description

Follow-up to #543/#544. The otel clickhouse exporter only creates tables when absent — it never ALTERs existing ones. The 0.75 → 0.156 collector upgrade added ScopeName/ScopeVersion to the traces insert, so existing installs fail every traces batch post-upgrade:

No such column ScopeName in table default.otel_traces

Caught in the 0.1.16-rc-1 dev-gke validation; applying the ALTER manually there restored flow immediately (0 export failures, 8.4k trace rows/3min).

This adds a pre-upgrade hook Job so customers never see it:

  • runs ALTER TABLE … ADD COLUMN IF NOT EXISTS ScopeName/ScopeVersion — additive + idempotent; keeps existing telemetry (7d TTL) instead of requiring a drop
  • skips cleanly when otel_traces doesn't exist (fresh installs: exporter creates the current schema)
  • gated on clickhouse.enabled && opentelemetry-collector.enabled; uses the chart's clickhouse image + the bitnami subchart's admin secret/service, respecting fullnameOverride
  • hook-delete-policy: hook-succeeded keeps the namespace clean; failed jobs stay for debugging

Chart 0.1.160.1.17.

How Has This Been Tested?

  • helm template renders correctly with default naming (<release>-clickhouse) and with fullnameOverride (dev style); helm lint clean
  • The ALTER itself validated live in dev-gke (manual application → traces flowing)
  • RC 0.1.17-rc-1 → dev-gke: hook runs as a no-op (columns already present) — confirms idempotence end-to-end

…cols)

The otel clickhouse exporter only creates tables when absent — it never ALTERs
an existing one. The collector 0.75 -> 0.156 upgrade added ScopeName /
ScopeVersion to the traces insert, so existing installs fail every traces
batch with "No such column ScopeName in table default.otel_traces" after the
upgrade (caught in the 0.1.16-rc-1 dev-gke validation; fixed there manually
with the same ALTER, after which traces flowed again — 8.4k rows/3min).

Add a pre-upgrade hook Job that runs the additive ALTER idempotently
(ADD COLUMN IF NOT EXISTS), preserving existing telemetry (7d TTL) instead of
requiring a table drop:
- gated on clickhouse.enabled && opentelemetry-collector.enabled
- skips cleanly when otel_traces doesn't exist yet (fresh installs: the
  exporter creates the current schema itself)
- uses the chart's clickhouse image (has clickhouse-client) and the bitnami
  subchart's admin secret/service, respecting fullnameOverride
- waits for the still-running pre-upgrade clickhouse before altering

Chart 0.1.16 -> 0.1.17.
@mayankpande88
mayankpande88 requested a review from a team as a code owner July 17, 2026 08:32

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a pre-upgrade schema migration job for the OTel ClickHouse exporter tables to add missing columns (ScopeName and ScopeVersion) before upgrading, and bumps the chart version to 0.1.17. The review feedback recommends making the migration job more robust by dynamically resolving ClickHouse configuration values (such as name overrides, existing secrets, and custom database/table names) and using them in the environment variables and migration script. Additionally, the reviewer suggests security and resource management improvements, specifically disabling automatic service account token mounting and defining resource requests and limits for the container.

Comment thread charts/nudgebee-agent/templates/clickhouse-schema-upgrade-job.yaml Outdated
Comment thread charts/nudgebee-agent/templates/clickhouse-schema-upgrade-job.yaml Outdated
Comment thread charts/nudgebee-agent/templates/clickhouse-schema-upgrade-job.yaml Outdated
Comment thread charts/nudgebee-agent/templates/clickhouse-schema-upgrade-job.yaml
Comment thread charts/nudgebee-agent/templates/clickhouse-schema-upgrade-job.yaml
…curity)

Review follow-ups:
- resolve the clickhouse fullname like the bitnami subchart (fullnameOverride,
  else <release>-<nameOverride|clickhouse>) so nameOverride installs work
- honor auth.existingSecret/existingSecretKey for the password lookup
- read database/traces_table_name from the exporter config values so the hook
  stays in lockstep with custom table setups instead of silently skipping
- automountServiceAccountToken: false (the job never talks to the K8s API)
- minimal resources on the container

Verified: helm template across default naming, nameOverride, and
fullnameOverride+existingSecret+custom-table; helm lint clean.
@blue4209211
blue4209211 merged commit 8caa0e3 into main Jul 17, 2026
6 checks passed
@blue4209211
blue4209211 deleted the feat/clickhouse-schema-pre-upgrade-hook branch July 17, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants