diff --git a/apps/prod/tekton/configs/tasks/kustomization.yaml b/apps/prod/tekton/configs/tasks/kustomization.yaml index e0a72c97a..035c763c6 100644 --- a/apps/prod/tekton/configs/tasks/kustomization.yaml +++ b/apps/prod/tekton/configs/tasks/kustomization.yaml @@ -36,9 +36,10 @@ resources: - pingcap-git-clone-ext.yaml - pingcap-upload-enterprise-plugins.yaml - pingcap-upload-offline-package.yaml + - publish-tiup-from-oci-artifact-v2.yaml - publish-tiup-from-oci-artifact.yaml - release/create-pr-to-add-release-anchor-commit.yaml - release/create-pr-to-bump-tikv-version.yaml - release/pingcap-create-github-releases.yaml - restore-cache-with-ks3.yaml - - save-cache-with-ks3.yaml + - save-cache-with-ks3.yaml \ No newline at end of file diff --git a/apps/prod/tekton/configs/tasks/publish-tiup-from-oci-artifact-v2.yaml b/apps/prod/tekton/configs/tasks/publish-tiup-from-oci-artifact-v2.yaml new file mode 100644 index 000000000..aa47e9d2c --- /dev/null +++ b/apps/prod/tekton/configs/tasks/publish-tiup-from-oci-artifact-v2.yaml @@ -0,0 +1,53 @@ +apiVersion: tekton.dev/v1beta1 +kind: Task +metadata: + name: publish-tiup-from-oci-artifact-v2 +spec: + description: | + The working flow: + 1. fetch the manifect config + 2. get the `.tiup` filed from the config. + 3. loop to publish to tiup mirror. + params: + - name: artifact-url + description: | + The full url of the pushed image, contain the tag part. + It will parse the repo from it. + - name: publisher-url + description: Staging is http://publisher-staging-mirror.apps.svc, product is http://publisher-prod-mirror.apps.svc. + default: http://publisher-staging-mirror.apps.svc + - name: force-version + description: > + Force set the version. + Default is the artifact version read from `org.opencontainers.image.version` of the manifest config. + default: "" + results: + - name: request-ids + type: array + steps: + - name: request-and-wait + image: ghcr.io/pingcap-qe/ee-apps/publisher:v2024.10.14-4-ga7470b6 + script: | + #!/usr/bin/env bash + set -eo pipefail + + # send event + /app/publisher-cli --url $(params.publisher-url) tiup request-to-publish --body '{ "artifact_url": "$(params.artifact-url)" }' | tee $(results.request-ids.path) + + # wait for request statuses + for request_id in $(jq -r '.[]' $(results.request-ids.path)); do + echo "🔍 query for request id: ${request_id} ..." + while true; do + status=$(/app/publisher-cli --url $(params.publisher-url) tiup query-publishing-status --request-id "$request_id" | jq -r .) + if [ "$status" = "failed" ]; then + echo "❌ $status" + exit 1 + elif [ "$status" = "success" ]; then + echo "✅ $status" + break + else + echo "⌛️ $status" + sleep 10 + fi + done + done diff --git a/apps/prod/tekton/configs/triggers/templates/_/push-oci-artifact-to-tiup.yaml b/apps/prod/tekton/configs/triggers/templates/_/push-oci-artifact-to-tiup.yaml index 60dcb468d..c14055582 100644 --- a/apps/prod/tekton/configs/triggers/templates/_/push-oci-artifact-to-tiup.yaml +++ b/apps/prod/tekton/configs/triggers/templates/_/push-oci-artifact-to-tiup.yaml @@ -17,37 +17,12 @@ spec: server: staging spec: taskRef: - name: publish-tiup-from-oci-artifact + name: publish-tiup-from-oci-artifact-v2 params: - name: artifact-url value: "$(tt.params.image_url)" - - name: nightly - value: "true" - - name: tiup-mirror - value: http://tiup.pingcap.net:8988 - workspaces: - - name: lock-tiup - persistentVolumeClaim: - claimName: pvc-lock-tiup-staging - - name: dockerconfig - secret: - secretName: hub-pingcap-net-ee - - name: tiup-keys - secret: - secretName: tiup-credentials-staging - podTemplate: - affinity: - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: "tekton.dev/task" - operator: In - values: [publish-tiup-from-oci-artifact] - - key: server - operator: In - values: [staging] - topologyKey: "kubernetes.io/hostname" + - name: publisher-url + value: http://publisher-staging-mirror.apps.svc - apiVersion: tekton.dev/v1beta1 kind: TaskRun metadata: @@ -107,35 +82,12 @@ spec: server: staging spec: taskRef: - name: publish-tiup-from-oci-artifact + name: publish-tiup-from-oci-artifact-v2 params: - name: artifact-url value: "$(tt.params.image_url)" - - name: tiup-mirror - value: http://tiup.pingcap.net:8988 - workspaces: - - name: lock-tiup - persistentVolumeClaim: - claimName: pvc-lock-tiup-staging - - name: dockerconfig - secret: - secretName: hub-pingcap-net-ee - - name: tiup-keys - secret: - secretName: tiup-credentials-staging - podTemplate: - affinity: - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: "tekton.dev/task" - operator: In - values: [publish-tiup-from-oci-artifact] - - key: server - operator: In - values: [staging] - topologyKey: "kubernetes.io/hostname" + - name: publisher-url + value: http://publisher-staging-mirror.apps.svc --- apiVersion: triggers.tekton.dev/v1beta1 kind: TriggerTemplate @@ -156,36 +108,13 @@ spec: server: staging spec: taskRef: - name: publish-tiup-from-oci-artifact + name: publish-tiup-from-oci-artifact-v2 timeout: 2h params: - name: artifact-url value: "$(tt.params.image_url)" - - name: tiup-mirror - value: http://tiup.pingcap.net:8988 - workspaces: - - name: lock-tiup - persistentVolumeClaim: - claimName: pvc-lock-tiup-staging - - name: dockerconfig - secret: - secretName: hub-pingcap-net-ee - - name: tiup-keys - secret: - secretName: tiup-credentials-staging - podTemplate: - affinity: - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: "tekton.dev/task" - operator: In - values: [publish-tiup-from-oci-artifact] - - key: server - operator: In - values: [staging] - topologyKey: "kubernetes.io/hostname" + - name: publisher-url + value: http://publisher-staging-mirror.apps.svc - apiVersion: tekton.dev/v1beta1 kind: TaskRun metadata: @@ -194,33 +123,10 @@ spec: server: prod spec: taskRef: - name: publish-tiup-from-oci-artifact + name: publish-tiup-from-oci-artifact-v2 timeout: 2h params: - name: artifact-url value: "$(tt.params.image_url)" - - name: tiup-mirror - value: http://tiup.pingcap.net:8987 - workspaces: - - name: lock-tiup - persistentVolumeClaim: - claimName: pvc-lock-tiup-prod - - name: dockerconfig - secret: - secretName: hub-pingcap-net-ee - - name: tiup-keys - secret: - secretName: tiup-credentials-prod - podTemplate: - affinity: - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: "tekton.dev/task" - operator: In - values: [publish-tiup-from-oci-artifact] - - key: server - operator: In - values: [prod] - topologyKey: "kubernetes.io/hostname" + - name: publisher-url + value: http://publisher-prod-mirror.apps.svc