Skip to content

Conversation

@marcleblanc2
Copy link
Contributor

@marcleblanc2 marcleblanc2 commented Dec 6, 2025

Linear issue FEIE-297: Add priorityClassName to remaining pods

  • Customer's Kubernetes cluster policy blocks pods from starting if they do not have a priorityClassName in their config.
  • We already had support for priorityClassName, but only for ~5 pods, need to add this for all remaining pods
  • Added logic so that priorityClassName could be defined once, under the sourcegraph top level key, and / or under each pod's top-level key, which would override the config on the sourcegraph top level key, so the customer could configure:
sourcegraph:
  priorityClassName: p2

pgsql:
  priorityClassName: p1

Checklist

Test plan

  • Tested with Helm template
  • Followed the manual testing process
  • Deployed it on my test cluster, with the following override file:
priorityClasses:
- name: test
  value: 100
  preemptionPolicy: Never
  description: "test"
- name: test2
  value: 102
  preemptionPolicy: Never
  description: "test2"

sourcegraph:
  image:
    defaultTag: 6.10.3349
    useGlobalTagAsDefault: true
  priorityClassName: test
  • Then re-applied, adding:
gitserver:
  priorityClassName: test2
  • Both worked, output:
[2025-12-15 03:58:52] config % kubectl get pods -o custom-columns=NAME:.metadata.name,PRIORITY_CLASS:.spec.priorityClassName,PRIORITY_VALUE:.spec.priority
NAME                                         PRIORITY_CLASS   PRIORITY_VALUE
blobstore-579cbc4cb9-2gn69                   test             100
codeinsights-db-0                            test             100
codeintel-db-0                               test             100
gitserver-0                                  test2            102
gitserver-1                                  test2            102
grafana-0                                    test             100
indexed-search-0                             test             100
pgsql-0                                      test             100
precise-code-intel-worker-5b6bd8d898-9zrbg   test             100
prometheus-65468d765d-j4rgw                  test             100
redis-cache-595c746f84-2wxtf                 test             100
redis-store-5f4b87dbf4-8n24m                 test             100
searcher-0                                   test             100
sourcegraph-frontend-677d647479-77zrl        test             100
syntect-server-657b89b6f4-p59x6              test             100
worker-6d68db5b5c-twxkk                      test             100

@marcleblanc2 marcleblanc2 requested a review from a team December 6, 2025 02:25
@marcleblanc2 marcleblanc2 added the backport 6.11.x Backport to 6.11.x release branch label Dec 6, 2025
@DaedalusG DaedalusG requested review from a team and removed request for a team December 8, 2025 21:49
Copy link
Member

@michaellzc michaellzc left a comment

Choose a reason for hiding this comment

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

can we DRY things up a bit using partial template?

see

{{- include "sourcegraph.nodeSelector" (list . "gitserver" ) | trim | nindent 6 }}
{{- include "sourcegraph.affinity" (list . "gitserver" ) | trim | nindent 6 }}
{{- include "sourcegraph.tolerations" (list . "gitserver" ) | trim | nindent 6 }}

{{- define "sourcegraph.nodeSelector" -}}
{{- $top := index . 0 }}
{{- $service := index . 1 }}
{{- $globalNodeSelector := (index $top.Values "sourcegraph" "nodeSelector") }}
{{- $serviceNodeSelector := (index $top.Values $service "nodeSelector") }}
nodeSelector:
{{- if $serviceNodeSelector }}
{{- $serviceNodeSelector | toYaml | trim | nindent 2 }}
{{- else if $globalNodeSelector }}
{{- $globalNodeSelector | toYaml | trim | nindent 2 }}
{{- end }}
{{- end }}

@marcleblanc2
Copy link
Contributor Author

can we DRY things up a bit using partial template?

@michaellzc Yes, I'm working on a few fixes, starting with #780, and will continue with DRYing up our templates a bit better.

This change is holding up a customer project, so I'll fast follow with the DRY updates.

@marcleblanc2
Copy link
Contributor Author

Hey @michaellzc, I created a partial template / helper function to DRY things up a bit.

Helm templating seems to have some limitations in terms of preventing excess whitespace, so the current implementation is the cleanest way I've found so far to avoid adding whitespace when priorityClassName is not defined, without over-chomping when it is defined.

Helm whitespacing seems to be a weak point for Amp.

@marcleblanc2
Copy link
Contributor Author

Quick and dirty bash script to find all helm charts in the repo, template them without and with --set sourcegraph.priorityClassName=test, then diff the templates without and with.
template-all-charts.sh

@marcleblanc2 marcleblanc2 changed the title Add priorityClassName to Helm charts and docs Add priorityClassName to remaining pods Dec 15, 2025
@marcleblanc2 marcleblanc2 merged commit a49fce2 into main Dec 15, 2025
5 checks passed
@marcleblanc2 marcleblanc2 deleted the marc/add-priority-to-remaining-pods branch December 15, 2025 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 6.11.x Backport to 6.11.x release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants