Skip to content

Commit

Permalink
Fix: Update handling of version strings in Helm template and helpers.…
Browse files Browse the repository at this point in the history
…tpl (#845)

* Update condition to include regexReplaceAll for outputting proper numbers from minor versions

Signed-off-by: HJJ256 <[email protected]>

* Update condition

Signed-off-by: HJJ256 <[email protected]>

* Update definition of strippedKubeVersion to handle variety of version numbering systems

Signed-off-by: HJJ256 <[email protected]>

* Update job-createSecret.yaml

Signed-off-by: HJJ256 <[email protected]>

* Update job-patchWebhook.yaml

Signed-off-by: HJJ256 <[email protected]>

---------

Signed-off-by: HJJ256 <[email protected]>
  • Loading branch information
HJJ256 authored Feb 13, 2025
1 parent 2234fcf commit 4b14ec7
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions charts/hami/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 2 }}


{{/*
Remove the part after the `+` in the Kubernetes version string.
Return the stripped Kubernetes version string by removing extra parts after semantic version number.
v1.31.1+k3s1 -> v1.31.1
v1.30.8-eks-2d5f260 -> v1.30.8
v1.31.1 -> v1.31.1
*/}}
{{- define "strippedKubeVersion" -}}
{{- $parts := split "+" .Capabilities.KubeVersion.Version -}}
{{- print $parts._0 -}}
{{ regexReplaceAll "^(v[0-9]+\\.[0-9]+\\.[0-9]+)(.*)$" .Capabilities.KubeVersion.Version "$1" }}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/hami/templates/scheduler/configmapnew.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
{{- include "hami-vgpu.labels" . | nindent 4 }}
data:
config.yaml: |
{{- if gt (.Capabilities.KubeVersion.Minor | int) 25}}
{{- if gt (regexReplaceAll "[^0-9]" .Capabilities.KubeVersion.Minor "" | int) 25}}
apiVersion: kubescheduler.config.k8s.io/v1
{{- else }}
apiVersion: kubescheduler.config.k8s.io/v1beta2
Expand Down
4 changes: 2 additions & 2 deletions charts/hami/templates/scheduler/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
imagePullPolicy: {{ .Values.scheduler.kubeScheduler.imagePullPolicy | quote }}
command:
- kube-scheduler
{{- if ge (.Capabilities.KubeVersion.Minor | int) 22 }}
{{- if ge (regexReplaceAll "[^0-9]" .Capabilities.KubeVersion.Minor "" | int) 22 }}
{{- range .Values.scheduler.kubeScheduler.extraNewArgs }}
- {{ . }}
{{- end }}
Expand Down Expand Up @@ -132,7 +132,7 @@ spec:
{{- if .Values.scheduler.kubeScheduler.enabled }}
- name: scheduler-config
configMap:
{{- if ge (.Capabilities.KubeVersion.Minor | int) 22 }}
{{- if ge (regexReplaceAll "[^0-9]" .Capabilities.KubeVersion.Minor "" | int) 22 }}
name: {{ template "hami-vgpu.scheduler" . }}-newversion
{{- else }}
name: {{ template "hami-vgpu.scheduler" . }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
{{- end }}
containers:
- name: create
{{- if ge (.Capabilities.KubeVersion.Minor | int) 22 }}
{{- if ge (regexReplaceAll "[^0-9]" .Capabilities.KubeVersion.Minor "" | int) 22 }}
image: {{ .Values.scheduler.patch.imageNew }}
{{- else }}
image: {{ .Values.scheduler.patch.image }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
{{- end }}
containers:
- name: patch
{{- if ge (.Capabilities.KubeVersion.Minor | int) 22 }}
{{- if ge (regexReplaceAll "[^0-9]" .Capabilities.KubeVersion.Minor "" | int) 22 }}
image: {{ .Values.scheduler.patch.imageNew }}
{{- else }}
image: {{ .Values.scheduler.patch.image }}
Expand Down

0 comments on commit 4b14ec7

Please sign in to comment.