NetApp / trident

Storage orchestrator for containers
Apache License 2.0
762 stars 222 forks source link

setting tridentAutosupportImage fallbacks to "latest" image #944

Closed lapkritinis closed 1 week ago

lapkritinis commented 2 weeks ago

Describe the bug Our cluster cannot access Internet therefore we are setting images override. While rest of images overrides did work as expected specifically tridentAutosupportImage got issue. Issue is that despite that it should pull 24.10 version it actually tries to pull "latest"

Environment Provide accurate information about the environment to help us reproduce the issue.

To Reproduce You can replicate it by setting chart value to "itself": tridentAutosupportImage: docker.io/netapp/trident-autosupport

Failed to pull image "docker.io/netapp/trident-autosupport": failed to pull and unpack image "docker.io/netapp/trident-autosupport:latest"<...>

Expected behavior It should try to pull not the latest, but 24.10 tag In my described scenario tridentAutosupportImageTag also got ignored

dmc5179 commented 2 weeks ago

The challenge is here in the template:

Trident AutoSupport image
*/}}
{{- define "trident.autosupportImage" -}}
{{- if .Values.tridentAutosupportImage }}
{{- .Values.tridentAutosupportImage }}
{{- else if .Values.imageRegistry }}
{{- .Values.imageRegistry }}/trident-autosupport:{{ .Values.tridentAutosupportImageTag | default .Chart.AppVersion | trunc 5}}
{{- else }}
{{- "" }}docker.io/netapp/trident-autosupport:{{ .Values.tridentAutosupportImageTag | default .Chart.AppVersion | trunc 5}}
{{- end }}
{{- end }}

The chart allows for the override of the image name but only checks the tag override if the imageRegistry is also set. The if then logic could be cleaned up a bit or at least more detail added to the values.yaml to explain how these variables will be put together and when.

lapkritinis commented 1 week ago

I do not see any real difference between operator image which works as intended:

{{/*
Trident image
*/}}
{{- define "trident.image" -}}
{{- if .Values.tridentImage }}
{{- .Values.tridentImage }}
{{- else if .Values.imageRegistry }}
{{- .Values.imageRegistry }}/trident:{{ .Values.tridentImageTag | default .Chart.AppVersion }}
{{- else }}
{{- "" }}docker.io/netapp/trident:{{ .Values.tridentImageTag | default .Chart.AppVersion }}
{{- end }}
{{- end }}

The only missing thing is that {{/* at the beginning and this one has trunc 5

lapkritinis commented 1 week ago

I used helm template command to quickly evaluate how it gets rendered. Turned out all images in template ends up without tags if any specific image is specified like:

operatorImage: xxx
tridentImage: xxx
tridentAutosupportImage: xxx

Because images are hosted in two different artifactories - single imageRepository does not work in my case. So ended up with this config which does what I wanted:

imageRegistry: remote-docker-kubernetes.artifactory.example.com/sig-storage
operatorImage: remote-docker-hub.artifactory.example.com/netapp/trident-operator:24.10.0
tridentImage: remote-docker-hub.artifactory.example.com/netapp/trident:24.10.0
tridentAutosupportImage: remote-docker-hub.artifactory.example.com/netapp/trident-autosupport:24.10