From c8fb3a8ea7ddf39e9ea8b18567d9ebaf0ebee39b Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Thu, 9 Jan 2025 16:42:12 +0100 Subject: [PATCH] Fix Jobs not using addional labels The selfsigned, the issuer and the upgrade check Jobs did not use additonal global labels. Fixed by using the common helper functions for labels. Closes https://gitlab.com/gitlab-org/charts/gitlab/-/issues/5903 Changelog: fixed --- .../certmanager-issuer/templates/issuer-job.yaml | 5 +++-- spec/configuration/labels_spec.rb | 14 +++++++++++++- templates/shared-secrets/self-signed-cert-job.yml | 5 +++-- templates/upgrade_check_hook.yaml | 5 +++-- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/charts/certmanager-issuer/templates/issuer-job.yaml b/charts/certmanager-issuer/templates/issuer-job.yaml index 4bb5adce82..2c57c00da0 100644 --- a/charts/certmanager-issuer/templates/issuer-job.yaml +++ b/charts/certmanager-issuer/templates/issuer-job.yaml @@ -13,8 +13,9 @@ spec: template: metadata: labels: - app: {{ template "name" . }} - release: {{ .Release.Name }} + {{- include "gitlab.standardLabels" . | nindent 8 }} + {{- include "gitlab.commonLabels" . | nindent 8 }} + {{- include "gitlab.podLabels" . | nindent 8 }} spec: {{- include "gitlab.nodeSelector" . | nindent 6 }} {{- include "gitlab.podSecurityContext" .Values.global.kubectl.securityContext | nindent 6 }} diff --git a/spec/configuration/labels_spec.rb b/spec/configuration/labels_spec.rb index 1900337e85..c6b87f43a8 100644 --- a/spec/configuration/labels_spec.rb +++ b/spec/configuration/labels_spec.rb @@ -15,6 +15,7 @@ describe 'Labels configuration' do let(:ignored_charts) do [ + 'Job/test-certmanager-startupapicheck', 'Deployment/test-certmanager-cainjector', 'Deployment/test-certmanager-webhook', 'Deployment/test-certmanager', @@ -49,7 +50,18 @@ describe 'Labels configuration' do resources_by_kind = t.resources_by_kind('Deployment').reject{ |key, _| ignored_charts.include? key } resources_by_kind.each do |key, _| - expect(t.dig(key, 'spec', 'template', 'metadata', 'labels')).to include(default_values['global']['pod']['labels']) + expect(t.dig(key, 'spec', 'template', 'metadata', 'labels')).to include(default_values['global']['pod']['labels']), key + end + end + + it 'Populates labels for all Job templates' do + t = HelmTemplate.new(default_values) + expect(t.exit_code).to eq(0) + + resources_by_kind = t.resources_by_kind('Job').reject{ |key, _| ignored_charts.include? key } + + resources_by_kind.each do |key, _| + expect(t.dig(key, 'spec', 'template', 'metadata', 'labels')).to include(default_values['global']['pod']['labels']), key end end diff --git a/templates/shared-secrets/self-signed-cert-job.yml b/templates/shared-secrets/self-signed-cert-job.yml index c92f467c39..e9bd365569 100644 --- a/templates/shared-secrets/self-signed-cert-job.yml +++ b/templates/shared-secrets/self-signed-cert-job.yml @@ -21,8 +21,9 @@ spec: template: metadata: labels: - app: {{ template "name" . }} - release: {{ .Release.Name }} + {{- include "gitlab.standardLabels" . | nindent 8 }} + {{- include "gitlab.commonLabels" . | nindent 8 }} + {{- include "gitlab.podLabels" . | nindent 8 }} annotations: {{- range $key, $value := $sharedSecretValues.annotations }} {{ $key }}: {{ $value | quote }} diff --git a/templates/upgrade_check_hook.yaml b/templates/upgrade_check_hook.yaml index aeef33984d..fa4cd5de23 100644 --- a/templates/upgrade_check_hook.yaml +++ b/templates/upgrade_check_hook.yaml @@ -36,8 +36,9 @@ spec: template: metadata: labels: - app: {{ template "name" . }} - release: {{ .Release.Name }} + {{- include "gitlab.standardLabels" . | nindent 8 }} + {{- include "gitlab.commonLabels" . | nindent 8 }} + {{- include "gitlab.podLabels" . | nindent 8 }} {{- if .Values.upgradeCheck.annotations }} {{- range $key, $value := .Values.upgradeCheck.annotations }} annotations: -- GitLab