Skip to content

Fix grafana StatefulSet rendering with extraContainers and a service account - #924

Merged
marcleblanc2 merged 1 commit into
mainfrom
fix/grafana-extracontainers-ordering
Aug 20, 2026
Merged

Fix grafana StatefulSet rendering with extraContainers and a service account#924
marcleblanc2 merged 1 commit into
mainfrom
fix/grafana-extracontainers-ordering

Conversation

@marcleblanc2

@marcleblanc2 marcleblanc2 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

The grafana StatefulSet template renders serviceAccountName between the containers list and grafana.extraContainers, so setting both a service account and extraContainers produces invalid YAML:

Error: YAML parse error on sourcegraph/templates/grafana/grafana.StatefulSet.yaml: error converting YAML to JSON: yaml: line 94: did not find expected key

This moves the extraContainers block before renderServiceAccountName, matching the ordering every other template uses (e.g. gitserver.StatefulSet.yaml). Grafana is the only template with this misordering.

This fix is required for customers using the Airgapped Analytics dashboard, with AWS IAM (IRSA) authentication to their Postgres database in RDS.

Checklist

Test plan

With test values setting both keys:

grafana:
  serviceAccount:
    create: false
    name: grafana-test-sa
  extraContainers:
    - name: test-sidecar
      image: busybox
  • Before: helm template sourcegraph charts/sourcegraph -f test-values.yaml fails with the YAML parse error above
  • After: renders cleanly; parsed the StatefulSet with PyYAML and verified spec.template.spec.serviceAccountName: grafana-test-sa and containers: [grafana, test-sidecar]
  • Verified no other template renders extraContainers after renderServiceAccountName

…account

The grafana StatefulSet template rendered serviceAccountName between the
containers list and grafana.extraContainers, so setting both a service
account and extraContainers produced invalid YAML:

    Error: YAML parse error on
    sourcegraph/templates/grafana/grafana.StatefulSet.yaml: error
    converting YAML to JSON: yaml: line 94: did not find expected key

Emit extraContainers inside the containers list before
serviceAccountName, matching the ordering every other template uses
(e.g. gitserver.StatefulSet.yaml).

Amp-Thread-ID: https://ampcode.com/threads/T-01a01d78-960e-7559-9ae0-cfb8bb51fff1
Co-authored-by: Amp <amp@ampcode.com>
@marcleblanc2
marcleblanc2 enabled auto-merge (squash) August 20, 2026 06:16
@marcleblanc2
marcleblanc2 requested a review from a team August 20, 2026 06:17
@marcleblanc2
marcleblanc2 merged commit e8fed45 into main Aug 20, 2026
5 checks passed
@marcleblanc2
marcleblanc2 deleted the fix/grafana-extracontainers-ordering branch August 20, 2026 06:29
@marcleblanc2 marcleblanc2 added the backport 7.6.x Backport to 7.6.x release branch label Aug 20, 2026
@sourcegraph-release-bot

Copy link
Copy Markdown
Collaborator

The backport to 7.6.x failed at https://github.com/sourcegraph/deploy-sourcegraph-helm/actions/runs/32339881719:

The process '/usr/bin/git' failed with exit code 1

To backport this PR manually, you can either:

Via the sg tool

Use the sg backport command to backport your commit to the release branch.

sg backport -r 7.6.x -p 924
Via your terminal

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-7.6.x 7.6.x
# Navigate to the new working tree
cd .worktrees/backport-7.6.x
# Create a new branch
git switch --create backport-924-to-7.6.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 e8fed45af40538315e049ecf9080ea8d8e5b2494
# Push it to GitHub
git push --set-upstream origin backport-924-to-7.6.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-7.6.x

If you encouter conflict, first resolve the conflict and stage all files, then run the commands below:

git cherry-pick --continue
# Push it to GitHub
git push --set-upstream origin backport-924-to-7.6.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-7.6.x
  • Follow above instructions to backport the commit.
  • Create a pull request where the base branch is 7.6.x and the compare/head branch is backport-924-to-7.6.x., click here to create the pull request.

Once the pull request has been created, please ensure the following:

  • Make sure to tag @sourcegraph/release in the pull request description.

  • kindly remove the release-blocker from this pull request.

marcleblanc2 added a commit that referenced this pull request Aug 20, 2026
…rs and a service account (#924) (#925)

Manual backport of #924 to `7.6.x` (the automated backport failed on a
CHANGELOG conflict).

cc @sourcegraph/release

The grafana StatefulSet template renders `serviceAccountName` between
the `containers` list and `grafana.extraContainers`, so setting both a
service account and `extraContainers` produces invalid YAML. This moves
the `extraContainers` block before `renderServiceAccountName`, matching
the ordering every other template uses.

This fix is required for customers using the Airgapped Analytics
dashboard, with AWS IAM (IRSA) authentication to their Postgres database
in RDS.

### Conflict resolution

Only `charts/sourcegraph/CHANGELOG.md` conflicted: the hunk context on
`main` included an unrelated `searcher.autoCacheSize` entry that does
not exist on `7.6.x`. Kept only the grafana bullet; the template change
applied cleanly.

### Test plan

With test values setting both keys:

```yaml
grafana:
  serviceAccount:
    create: false
    name: grafana-test-sa
  extraContainers:
    - name: test-sidecar
      image: busybox
```

`helm template sourcegraph charts/sourcegraph -f test-values.yaml -s
templates/grafana/grafana.StatefulSet.yaml` on this branch renders
cleanly, with `test-sidecar` inside the `containers` list and
`serviceAccountName: grafana-test-sa` after it.

Co-authored-by: Amp <amp@ampcode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants