Skip to content

Commit

Permalink
refactor(apps/prod/tekton/configs): use delicated publisher to fast t…
Browse files Browse the repository at this point in the history
…iup publishing

Signed-off-by: wuhuizuo <[email protected]>
  • Loading branch information
wuhuizuo committed Oct 28, 2024
1 parent 4ee2c8c commit 6f21dc2
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 107 deletions.
3 changes: 2 additions & 1 deletion apps/prod/tekton/configs/tasks/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- 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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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

0 comments on commit 6f21dc2

Please sign in to comment.