Skip to content

Fix public Grafana crash-loop: converge pyroscope datasource to its pinned uid - #236

Merged
kondratyevd merged 1 commit into
mainfrom
fix-grafana-datasource-uid-crash
Sep 7, 2026
Merged

Fix public Grafana crash-loop: converge pyroscope datasource to its pinned uid#236
kondratyevd merged 1 commit into
mainfrom
fix-grafana-datasource-uid-crash

Conversation

@kondratyevd

Copy link
Copy Markdown
Collaborator

Outage

After merging #190, the public grafana pod entered CrashLoopBackOff:

logger=provisioning level=error msg="Failed to provision data sources" error="Datasource provisioning error: data source not found"
Error: ✗ invalid service state: Failed ... [starting module provisioning: ...]

grafana-private was unaffected (Running, fresh database).

Root cause

#190 pinned uid: pyroscope on the shared pyroscope datasource. Grafana 12.3.1 cannot change an existing datasource's uid through provisioning: the provisioner passes the existing row's id plus the uid from the file, and UpdateDataSource fetches the row with WHERE id AND uid (datasource.go#L488-L496). The public database still had the old auto-generated uid (PAF2BCAF32F82481F), so the lookup returned ErrDataSourceNotFound, the provisioning module failed, and Grafana exits on provisioning failure — crash-loop. The private instance inserted the datasource fresh with the pinned uid, which is why it came up healthy.

Fix

Add deleteDatasources: [pyroscope] to the same provisioning file. Grafana's provisioner deletes any pre-existing row first and re-creates it with the pinned uid in the same pass — it explicitly skips the deletion event when the datasource is re-created (datasources.go#L249-L265) and skips rows that don't exist. Every instance (current public, current private, any future rebuild) converges to uid: pyroscope, which the private pyroscope dashboard references.

Recovery path

On merge, Flux updates the grafana-datasources ConfigMap → helm upgrade → both pods restart → public provisioning succeeds and the instance comes back. No manual cluster action needed.

Validation

Rendered core-production through kustomize + envsubst + helm template (chart 10.5.15): the provisioning file carries the deleteDatasources block, all 7 shared datasources, and the pinned uid.

🤖 Generated with Claude Code

PR #190 pinned uid: pyroscope on the shared pyroscope datasource, but
Grafana (12.3.1) cannot change an existing datasource's uid via
provisioning: UpdateDataSource looks the row up by id AND the new uid,
gets "data source not found", and the failed provisioning module
crash-loops the instance. The public instance's database still had the
old auto-generated uid, so its pod went down after the merge;
grafana-private survived because its fresh database inserted the
datasource with the pinned uid.

Add deleteDatasources for pyroscope in the same provisioning file:
Grafana deletes any pre-existing row (skipping the delete event when
the datasource is re-created in the same pass, and skipping rows that
do not exist) and re-creates it with the pinned uid, converging every
instance — including a future rebuilt one — to uid pyroscope.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kondratyevd
kondratyevd merged commit 6094e4a into main Sep 7, 2026
15 checks passed
@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

1 participant