-
Notifications
You must be signed in to change notification settings - Fork 111
feat(tikv/migration): migrate CI artifacts from fileserver to OCI registry #4272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a4dff08
4de60e6
a51df4d
37a2c45
21ce4b2
4e1f83f
28235e5
0175ffe
4f85537
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,11 @@ final GIT_FULL_REPO_NAME = 'tikv/migration' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final GIT_CREDENTIALS_ID = 'github-sre-bot-ssh' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final POD_TEMPLATE_FILE = 'pipelines/tikv/migration/latest/pod-pull_integration_kafka_test.yaml' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final REFS = readJSON(text: params.JOB_SPEC).refs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final OCI_TAG_TIDB = component.computeArtifactOciTagFromPR('tidb', REFS.base_ref, REFS.pulls[0].title, 'master') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final OCI_TAG_TIKV = component.computeArtifactOciTagFromPR('tikv', REFS.base_ref, REFS.pulls[0].title, 'master') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final OCI_TAG_PD = component.computeArtifactOciTagFromPR('pd', REFS.base_ref, REFS.pulls[0].title, 'master') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final OCI_TAG_ETCD = 'v3.5.15' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final OCI_TAG_YCSB = 'v1.0.3' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pipeline { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| agent { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -18,7 +23,11 @@ pipeline { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| environment { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FILE_SERVER_URL = 'http://fileserver.pingcap.net' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // OCI artifact registry: hub-zot.pingcap.net/mirrors/hub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // tidb-server: hub-zot.pingcap.net/mirrors/hub/pingcap/tidb/package:<tag>_linux_amd64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // tikv-server: hub-zot.pingcap.net/mirrors/hub/tikv/tikv/package:<tag>_linux_amd64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // pd-server: hub-zot.pingcap.net/mirrors/hub/tikv/pd/package:<tag>_linux_amd64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OCI_ARTIFACT_HOST = 'hub-zot.pingcap.net/mirrors/hub' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| timeout(time: 65, unit: 'MINUTES') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -66,10 +75,26 @@ pipeline { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| steps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dir('migration') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cache(path: "./cdc", includes: '**/*', key: "ws/${BUILD_TAG}/tikvcdc") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| container("utils") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sh label: 'download test binaries via OCI', script: """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p ./cdc/scripts/bin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd ./cdc/scripts/bin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ${WORKSPACE}/scripts/artifacts/download_pingcap_oci_artifact.sh \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --tidb=${OCI_TAG_TIDB} \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --tikv=${OCI_TAG_TIKV} \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --pd=${OCI_TAG_PD} \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --pd-ctl=${OCI_TAG_PD} \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --etcdctl=${OCI_TAG_ETCD} \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --ycsb=${OCI_TAG_YCSB} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+82
to
+88
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| chmod +x tidb-server tikv-server pd-server pd-ctl etcdctl go-ycsb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd ../../ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| touch prepare_test_binaries | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ls -alh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+79
to
+93
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sh label: 'download test binaries via OCI', script: """ | |
| mkdir -p ./cdc/scripts/bin | |
| cd ./cdc/scripts/bin | |
| ${WORKSPACE}/scripts/artifacts/download_pingcap_oci_artifact.sh \ | |
| --tidb=${OCI_TAG_TIDB} \ | |
| --tikv=${OCI_TAG_TIKV} \ | |
| --pd=${OCI_TAG_PD} \ | |
| --pd-ctl=${OCI_TAG_PD} \ | |
| --etcdctl=${OCI_TAG_ETCD} \ | |
| --ycsb=${OCI_TAG_YCSB} | |
| chmod +x tidb-server tikv-server pd-server pd-ctl etcdctl go-ycsb | |
| cd ../../ | |
| touch prepare_test_binaries | |
| ls -alh | |
| """ | |
| retry(2) { | |
| sh label: 'download test binaries via OCI', script: """ | |
| mkdir -p ./cdc/scripts/bin | |
| cd ./cdc/scripts/bin | |
| ${WORKSPACE}/scripts/artifacts/download_pingcap_oci_artifact.sh \ | |
| --tidb=${OCI_TAG_TIDB} \ | |
| --tikv=${OCI_TAG_TIKV} \ | |
| --pd=${OCI_TAG_PD} \ | |
| --pd-ctl=${OCI_TAG_PD} \ | |
| --etcdctl=${OCI_TAG_ETCD} \ | |
| --ycsb=${OCI_TAG_YCSB} | |
| chmod +x tidb-server tikv-server pd-server pd-ctl etcdctl go-ycsb | |
| cd ../../ | |
| touch prepare_test_binaries | |
| ls -alh | |
| """ | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,11 @@ final GIT_FULL_REPO_NAME = 'tikv/migration' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final GIT_CREDENTIALS_ID = 'github-sre-bot-ssh' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final POD_TEMPLATE_FILE = 'pipelines/tikv/migration/latest/pod-pull_integration_test.yaml' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final REFS = readJSON(text: params.JOB_SPEC).refs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final OCI_TAG_TIDB = component.computeArtifactOciTagFromPR('tidb', REFS.base_ref, REFS.pulls[0].title, 'master') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final OCI_TAG_TIKV = component.computeArtifactOciTagFromPR('tikv', REFS.base_ref, REFS.pulls[0].title, 'master') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final OCI_TAG_PD = component.computeArtifactOciTagFromPR('pd', REFS.base_ref, REFS.pulls[0].title, 'master') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final OCI_TAG_ETCD = 'v3.5.15' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final OCI_TAG_YCSB = 'v1.0.3' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pipeline { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| agent { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -18,7 +23,11 @@ pipeline { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| environment { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FILE_SERVER_URL = 'http://fileserver.pingcap.net' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // OCI artifact registry: hub-zot.pingcap.net/mirrors/hub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // tidb-server: hub-zot.pingcap.net/mirrors/hub/pingcap/tidb/package:<tag>_linux_amd64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // tikv-server: hub-zot.pingcap.net/mirrors/hub/tikv/tikv/package:<tag>_linux_amd64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // pd-server: hub-zot.pingcap.net/mirrors/hub/tikv/pd/package:<tag>_linux_amd64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OCI_ARTIFACT_HOST = 'hub-zot.pingcap.net/mirrors/hub' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OCI_ARTIFACT_HOST = 'hub-zot.pingcap.net/mirrors/hub' | |
| OCI_ARTIFACT_HOST = 'hub-zot.pingcap.net/mirrors/hub' | |
| // Community / third-party artifacts (e.g. etcdctl, ycsb) via the same mirror | |
| OCI_ARTIFACT_HOST_COMMUNITY = 'hub-zot.pingcap.net/mirrors/hub' |
Copilot
AI
Mar 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sh step builds a shell command line where --tidb=${OCI_TAG_TIDB}, --tikv=${OCI_TAG_TIKV}, and other flags interpolate values derived from the PR title into an unquoted shell context. Because OCI_TAG_* values come from component.computeArtifactOciTagFromPR, which can be influenced via the PR title and allows shell metacharacters like ;, an attacker can craft a PR title such that the resulting tag injects arbitrary commands executed in the CI container. Treat OCI_TAG_* as untrusted: strictly validate/whitelist allowed characters for tags and ensure they are passed as safely quoted arguments (or via an array/parameter mechanism) so no shell metacharacters can break out of the intended argument.
Copilot
AI
Mar 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OCI download step is doing network fetches but isn’t wrapped in retry(...), unlike similar pipelines in this repo. Consider adding a small retry around the download script invocation to reduce CI flakiness from transient registry/network errors.
| sh label: 'download test binaries via OCI', script: """ | |
| mkdir -p ./cdc/scripts/bin | |
| cd ./cdc/scripts/bin | |
| ${WORKSPACE}/scripts/artifacts/download_pingcap_oci_artifact.sh \ | |
| --tidb=${OCI_TAG_TIDB} \ | |
| --tikv=${OCI_TAG_TIKV} \ | |
| --pd=${OCI_TAG_PD} \ | |
| --pd-ctl=${OCI_TAG_PD} \ | |
| --etcdctl=${OCI_TAG_ETCD} \ | |
| --ycsb=${OCI_TAG_YCSB} | |
| chmod +x tidb-server tikv-server pd-server pd-ctl etcdctl go-ycsb | |
| cd ../../ | |
| touch prepare_test_binaries | |
| ls -alh | |
| """ | |
| retry(3) { | |
| sh label: 'download test binaries via OCI', script: """ | |
| mkdir -p ./cdc/scripts/bin | |
| cd ./cdc/scripts/bin | |
| ${WORKSPACE}/scripts/artifacts/download_pingcap_oci_artifact.sh \ | |
| --tidb=${OCI_TAG_TIDB} \ | |
| --tikv=${OCI_TAG_TIKV} \ | |
| --pd=${OCI_TAG_PD} \ | |
| --pd-ctl=${OCI_TAG_PD} \ | |
| --etcdctl=${OCI_TAG_ETCD} \ | |
| --ycsb=${OCI_TAG_YCSB} | |
| chmod +x tidb-server tikv-server pd-server pd-ctl etcdctl go-ycsb | |
| cd ../../ | |
| touch prepare_test_binaries | |
| ls -alh | |
| """ | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,27 @@ | ||
| global_definitions: | ||
| brancher: &brancher | ||
| branches: | ||
| - ^main$ | ||
| - ^cdc-release-.*$ | ||
| - ^br-release-.*$ | ||
| jenkins_job: &jenkins_job | ||
| agent: jenkins | ||
| labels: | ||
| master: "0" | ||
| decorate: false | ||
|
|
||
| # struct ref: https://pkg.go.dev/sigs.k8s.io/prow/pkg/config#Presubmit | ||
| presubmits: | ||
| tikv/migration: | ||
| - name: tikv/migration/pull_integration_test | ||
| agent: jenkins | ||
| labels: | ||
| master: "0" | ||
| decorate: false # need add this. | ||
| - <<: [*brancher, *jenkins_job] | ||
| name: tikv/migration/pull_integration_test | ||
| always_run: true | ||
| context: pull-integration-test | ||
| trigger: "(?m)^/test (?:.*? )?pull-integration-test(?: .*?)?$" | ||
| rerun_command: "/test pull-integration-test" | ||
| branches: | ||
| - ^main$ | ||
| - ^cdc-release-.*$ | ||
| - ^br-release-.*$ | ||
| - name: tikv/migration/pull_integration_kafka_test | ||
| agent: jenkins | ||
| labels: | ||
| master: "0" | ||
| decorate: false # need add this. | ||
| - <<: [*brancher, *jenkins_job] | ||
| name: tikv/migration/pull_integration_kafka_test | ||
| always_run: true | ||
| context: pull-integration-kafka-test | ||
| trigger: "(?m)^/test (?:.*? )?pull-integration-kafka-test(?: .*?)?$" | ||
| rerun_command: "/test pull-integration-kafka-test" | ||
| branches: | ||
| - ^main$ | ||
| - ^cdc-release-.*$ | ||
| - ^br-release-.*$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
download_pingcap_oci_artifact.shusesOCI_ARTIFACT_HOST_COMMUNITY(defaulting tous-docker.pkg.dev/.../hub) for third-party artifacts like--etcdctland--ycsb. If these jobs are intended to pull all artifacts via the hub-zot mirror, also setOCI_ARTIFACT_HOST_COMMUNITY(or export it just for the script invocation) to the mirror registry; otherwise these downloads will still hit the community registry.