From c83cc1bcc1b015dfbce0eaf917c20d6a25391d7a Mon Sep 17 00:00:00 2001 From: Akos Eros Date: Wed, 15 Jan 2025 16:25:51 +0100 Subject: [PATCH] Fix commit and push parallelization issue There was a race condition when running seed pipelines after the last refactor when commiting and pushing to ops repo. Moved the base image build to only run together with frontend component as it is only used there. --- .../pipelines/templates/_helpers.tpl | 14 +++++--- .../build-and-test-iot-component.yaml | 9 +++-- .../pipelines/templates/pipelines/seed.yaml | 36 +++++++++++++++++-- 3 files changed, 49 insertions(+), 10 deletions(-) diff --git a/charts/datacenter/pipelines/templates/_helpers.tpl b/charts/datacenter/pipelines/templates/_helpers.tpl index 510e4ee7e..584ec0d49 100644 --- a/charts/datacenter/pipelines/templates/_helpers.tpl +++ b/charts/datacenter/pipelines/templates/_helpers.tpl @@ -17,8 +17,8 @@ ie-registry {{- end }} {{- end }} -{{- define "build-base-images" -}} -- name: buildah-build +{{- define "build-frontend-base-image" -}} +- name: build-base-image taskRef: name: buildah runAfter: @@ -42,7 +42,7 @@ ie-registry value: IMAGE_ACCOUNT - name: OUTPUT_IMAGE_NAME value: httpd-ionic -{{- end }} {{/* build-base-images */}} +{{- end }} {{/* build-frontend-base-image */}} {{- define "build-iot-component" }} - name: bump-build-version-{{ .component.component_name }} @@ -50,8 +50,12 @@ ie-registry taskRef: name: bumpversion runAfter: +{{- if (eq .component.component_name "iot-frontend") }} + - build-base-image +{{- else }} - git-clone-ops - git-clone-dev +{{- end }} workspaces: - name: gitrepos workspace: gitrepos @@ -160,7 +164,9 @@ ie-registry value: $(tasks.bump-build-version-{{ .component.component_name }}.results.image-tag) - name: subdirectory value: ops +{{- end }} {{/* build-iot-component */}} +{{- define "commit-and-push-ops-iot-component" -}} - name: commit-ops-{{ .component.component_name }} taskRef: name: git-commit @@ -188,7 +194,7 @@ ie-registry value: ops - name: PUSH_FLAGS value: --all -{{- end }} {{/* build-iot-component */}} +{{- end }} {{/* commit-and-push-ops-iot-component */}} {{- define "test-all" }} - name: sensor-broker-test diff --git a/charts/datacenter/pipelines/templates/pipelines/build-and-test-iot-component.yaml b/charts/datacenter/pipelines/templates/pipelines/build-and-test-iot-component.yaml index 21a8d9180..c5ffd75eb 100644 --- a/charts/datacenter/pipelines/templates/pipelines/build-and-test-iot-component.yaml +++ b/charts/datacenter/pipelines/templates/pipelines/build-and-test-iot-component.yaml @@ -1,8 +1,5 @@ {{- range .Values.pipeline_components }} --- - {{/*- include "build-iot-component" (dict "root" $.Values "component" . "seed_prod" "true") | nindent 4 */}} - {{/*- include "test_include" (dict "root" $.Values "component" . "seed_prod" "true") | nindent 4 */}} - apiVersion: tekton.dev/v1beta1 kind: Pipeline metadata: @@ -51,6 +48,10 @@ spec: - name: deleteExisting value: "true" +{{- if (eq .component_name "iot-frontend") -}} +{{- include "build-frontend-base-image" $ | nindent 2 }} +{{- end }} + {{- include "build-iot-component" (dict "root" $.Values "component" . "seed_prod" "false") | nindent 2 }} - name: argocd-sync-application @@ -71,6 +72,8 @@ spec: - name: argocd-server value: "{{ $.Values.clusterGroup.name }}-gitops-server.{{ $.Values.global.pattern }}-{{ $.Values.clusterGroup.name }}.svc" +{{- include "commit-and-push-ops-iot-component" (dict "root" $.Values "component" . ) | nindent 2 }} + {{- include "test-all" . | nindent 2 }} {{- include "trigger-staging" (dict "root" $.Values "component" . ) | nindent 2 }} diff --git a/charts/datacenter/pipelines/templates/pipelines/seed.yaml b/charts/datacenter/pipelines/templates/pipelines/seed.yaml index ebfb7cbf2..0895b2ed7 100644 --- a/charts/datacenter/pipelines/templates/pipelines/seed.yaml +++ b/charts/datacenter/pipelines/templates/pipelines/seed.yaml @@ -44,8 +44,38 @@ spec: - name: deleteExisting value: "true" - {{- include "build-base-images" $ | nindent 4 }} {{- range .Values.pipeline_components }} + {{- if (eq .component_name "iot-frontend") -}} + {{- include "build-frontend-base-image" $ | nindent 4 }} + {{- end }} {{- include "build-iot-component" (dict "root" $.Values "component" . "seed_prod" "true") | nindent 4 }} - {{/*- include "test_include" (dict "root" $.Values "component" . "seed_prod" "true") | nindent 4 */}} - {{- end }} \ No newline at end of file + {{- end }} + - name: commit-ops + taskRef: + name: git-commit + runAfter: + {{- range .Values.pipeline_components }} + - modify-ops-prod-iot-component-{{ .component_name }} + {{- end }} + workspaces: + - name: gitrepos + workspace: gitrepos + - name: config + workspace: config + params: + - name: subdirectory + value: ops + + - name: push-ops + taskRef: + name: github-push + runAfter: + - commit-ops + workspaces: + - name: gitrepos + workspace: gitrepos + params: + - name: subdirectory + value: ops + - name: PUSH_FLAGS + value: --all