Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/replicated-engine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"helm-charts": minor
---

feat: fresh installs with the bundled ClickHouse write ClickStack tables to a dedicated `otel` database, created as Replicated with `Replicated*` tables. `helm upgrade` keeps the database and engines of existing installs, and an external ClickHouse keeps `default`. `HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE` now also drives the default sources and ClickHouse user grants. `HYPERDX_OTEL_EXPORTER_CLICKHOUSE_FALLBACK_DATABASE` keeps existing installs writing to `default` when the chart is rendered without cluster access (ArgoCD, `helm template`). See docs/UPGRADE.md.
10 changes: 6 additions & 4 deletions .github/workflows/chart-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
echo "Discovered suites: $SUITES"

integration-test:
name: integration-test (${{ matrix.suite }}${{ matrix.mode == 'upgrade' && ', upgrade' || '' }})
name: integration-test (${{ matrix.suite }}${{ matrix.mode != 'install' && format(', {0}', matrix.mode) || '' }})
needs: discover
runs-on: ubuntu-latest
timeout-minutes: 60
Expand All @@ -41,7 +41,8 @@ jobs:
matrix:
suite: ${{ fromJson(needs.discover.outputs.suites) }}
# PRs also upgrade from the base branch, to catch changes that only break existing releases.
mode: ${{ github.event_name == 'pull_request' && fromJson('["install","upgrade"]') || fromJson('["install"]') }}
# upgrade-template applies the upgrade with helm template | kubectl apply, as Argo CD does.
mode: ${{ github.event_name == 'pull_request' && fromJson('["install","upgrade","upgrade-template"]') || fromJson('["install"]') }}
env:
SUITE: ${{ matrix.suite }}
steps:
Expand All @@ -51,7 +52,7 @@ jobs:
persist-credentials: false

- name: Checkout base branch
if: matrix.mode == 'upgrade'
if: matrix.mode != 'install'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.base.sha }}
Expand Down Expand Up @@ -90,7 +91,8 @@ jobs:

- name: Run integration test suite
env:
UPGRADE_FROM: ${{ matrix.mode == 'upgrade' && format('{0}/.upgrade-base', github.workspace) || '' }}
UPGRADE_FROM: ${{ matrix.mode != 'install' && format('{0}/.upgrade-base', github.workspace) || '' }}
UPGRADE_METHOD: ${{ matrix.mode == 'upgrade-template' && 'template' || 'helm' }}
run: |
chmod +x integration-tests/run-suite.sh
integration-tests/run-suite.sh "$SUITE"
Expand Down
8 changes: 4 additions & 4 deletions charts/clickstack/README.md

Large diffs are not rendered by default.

78 changes: 77 additions & 1 deletion charts/clickstack/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ repeated because ClickHouse ignores its legacy prometheus.endpoint settings once
handlers block exists.
*/}}
{{- define "clickstack.clickhouse.promqlSettings" -}}
{{- $database := .Values.clickstack.config.HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE | default "default" }}
{{- $database := include "clickstack.clickhouse.database" . }}
extraConfig:
prometheus:
handlers:
Expand Down Expand Up @@ -466,3 +466,79 @@ stringData:
{{ $k }}: {{ tpl (toString $v) $ | quote }}
{{- end }}
{{- end }}

{{/*
Whether the bundled ClickHouse is enabled. Accepts a bool or a "true"/"false" string
(e.g. from --set-string). Renders "true" or "".
*/}}
{{- define "clickstack.clickhouse.enabled" -}}
{{- if eq (lower (toString .Values.clickhouse.enabled)) "true" }}true{{- end -}}
{{- end }}

{{/*
Default ClickStack database and replicated seed flag, as JSON with "database" and "replicated".
- External ClickHouse: default, not replicated.
- Upgrade: reuse the existing clickstack-config ConfigMap, so installs keep their database and
engines. A missing key means default or "false", matching charts that predate these keys.
- Fresh install, or a render without cluster access (helm template): Replicated otel database.
*/}}
{{- define "clickstack.clickhouse.seedDefaults" -}}
{{- $defaults := dict "database" "otel" "replicated" "true" -}}
{{- if not (include "clickstack.clickhouse.enabled" .) -}}
{{- $defaults = dict "database" "default" "replicated" "false" -}}
{{- else -}}
{{- $existing := lookup "v1" "ConfigMap" .Release.Namespace "clickstack-config" -}}
{{- if $existing -}}
{{- $data := default (dict) $existing.data -}}
{{- $defaults = dict
"database" (default "default" (get $data "HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE"))
"replicated" (default "false" (get $data "HYPERDX_OTEL_EXPORTER_CLICKHOUSE_REPLICATED")) -}}
{{- end -}}
{{- end -}}
{{- toJson $defaults -}}
{{- end }}

{{/*
Default for clickstack.config.HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE. See clickstack.clickhouse.seedDefaults.
*/}}
{{- define "clickstack.clickhouse.defaultDatabase" -}}
{{- (include "clickstack.clickhouse.seedDefaults" . | fromJson).database -}}
{{- end }}

{{/*
Default for clickstack.config.HYPERDX_OTEL_EXPORTER_CLICKHOUSE_REPLICATED. See clickstack.clickhouse.seedDefaults.
*/}}
{{- define "clickstack.clickhouse.defaultReplicated" -}}
{{- (include "clickstack.clickhouse.seedDefaults" . | fromJson).replicated -}}
{{- end }}

{{/*
Default for clickstack.config.HYPERDX_OTEL_EXPORTER_CLICKHOUSE_FALLBACK_DATABASE: default for the
bundled ClickHouse, so renders without lookup keep existing installs on default, and empty otherwise.
*/}}
{{- define "clickstack.clickhouse.defaultFallbackDatabase" -}}
{{- if include "clickstack.clickhouse.enabled" . }}default{{- end -}}
{{- end }}

{{/*
ClickHouse database for ClickStack tables: clickstack.config.HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE
rendered through tpl, so the collector seed, default sources, PromQL handlers, and user grants always agree.
*/}}
{{- define "clickstack.clickhouse.database" -}}
{{- $config := default (dict) .Values.clickstack.config -}}
{{- tpl (toString (default "default" (index $config "HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE"))) . -}}
{{- end }}

{{/*
ClickHouse grant elements for ClickStack tables. Always covers default.* so data written
before the dedicated database stays readable, plus the configured database when it differs.
Usage: include "clickstack.clickhouse.databaseGrants" (dict "privileges" "SELECT" "context" .)
*/}}
{{- define "clickstack.clickhouse.databaseGrants" -}}
{{- $database := include "clickstack.clickhouse.database" .context -}}
{{- $grants := list (printf "%s ON default.*" .privileges) -}}
{{- if ne $database "default" -}}
{{- $grants = append $grants (printf "%s ON %s.*" .privileges $database) -}}
{{- end -}}
{{- join ", " $grants -}}
{{- end }}
50 changes: 50 additions & 0 deletions charts/clickstack/tests/app-configmap_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,56 @@ tests:
path: data.NEXT_PUBLIC_ENABLE_PROMQL
value: "false"

- it: should use the otel database for the bundled ClickHouse
asserts:
- equal:
path: data.HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE
value: "otel"

- it: should use the default database for an external ClickHouse
set:
clickhouse:
enabled: false
asserts:
- equal:
path: data.HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE
value: "default"

- it: should render a plain string database override
set:
clickstack:
config:
HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE: "clickstack"
asserts:
- equal:
path: data.HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE
value: "clickstack"

- it: should enable replicated seeding for the bundled ClickHouse
asserts:
- equal:
path: data.HYPERDX_OTEL_EXPORTER_CLICKHOUSE_REPLICATED
value: "true"

- it: should disable replicated seeding for an external ClickHouse
set:
clickhouse:
enabled: false
asserts:
- equal:
path: data.HYPERDX_OTEL_EXPORTER_CLICKHOUSE_REPLICATED
value: "false"

- it: should allow opting out of replicated seeding
set:
clickstack:
config:
HYPERDX_OTEL_EXPORTER_CLICKHOUSE_REPLICATED: "false"
asserts:
- equal:
path: data.HYPERDX_OTEL_EXPORTER_CLICKHOUSE_REPLICATED
value: "false"

- it: should fail when the removed 1.x usageStatsEnabled key is set
set:
hyperdx:
Expand Down
Loading
Loading