Skip to content

Commit c343f74

Browse files
authored
feat(monitoring): add job to auto update content for monitoring (#2750)
Signed-off-by: wuhuizuo <[email protected]> --------- Signed-off-by: wuhuizuo <[email protected]>
1 parent 68253ce commit c343f74

File tree

2 files changed

+153
-9
lines changed

2 files changed

+153
-9
lines changed

prow-jobs/kustomization.yaml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ configMapGenerator:
1010
- pingcap-community-postsubmits.yaml
1111
- pingcap-inc-enterprise-extensions-postsubmits.yaml
1212
- pingcap-inc-enterprise-extensions-presubmits.yaml
13+
- pingcap-monitoring-periodics.yaml
1314
- pingcap-qe-ci-presubmits.yaml
15+
- pingcap-tidb-engine-ext-latest-presubmits.yaml
16+
- pingcap-tidb-engine-release-6.1-latest-presubmits.yaml
1417
- pingcap-tidb-latest-periodics.yaml
1518
- pingcap-tidb-latest-postsubmits.yaml
1619
- pingcap-tidb-latest-presubmits-canary.yaml
@@ -19,8 +22,9 @@ configMapGenerator:
1922
- pingcap-tidb-release-6.2-presubmits.yaml
2023
- pingcap-tidb-release-6.3-presubmits.yaml
2124
- pingcap-tidb-release-6.4-presubmits.yaml
22-
- pingcap-tidb-release-6.5-presubmits.yaml
2325
- pingcap-tidb-release-6.5-fips-presubmits.yaml
26+
- pingcap-tidb-release-6.5-presubmits.yaml
27+
- pingcap-tidb-release-6.5-with-kv-timeout-feature-presubmits.yaml
2428
- pingcap-tidb-release-6.6-presubmits.yaml
2529
- pingcap-tidb-release-7.0-presubmits.yaml
2630
- pingcap-tidb-release-7.1-presubmits.yaml
@@ -33,6 +37,8 @@ configMapGenerator:
3337
- pingcap-tidb-test-release-6.0-presubmits.yaml
3438
- pingcap-tidb-test-release-6.1-presubmits.yaml
3539
- pingcap-tidb-test-release-6.2-presubmits.yaml
40+
- pingcap-tiflash-latest-postsubmits.yaml
41+
- pingcap-tiflash-latest-presubmits.yaml
3642
- pingcap-tiflow-latest-postsubmits.yaml
3743
- pingcap-tiflow-latest-presubmits-wip.yaml
3844
- pingcap-tiflow-latest-presubmits.yaml
@@ -41,22 +47,17 @@ configMapGenerator:
4147
- pingcap-tiflow-release-6.0-presubmits.yaml
4248
- pingcap-tiflow-release-6.1-presubmits.yaml
4349
- pingcap-tiflow-release-6.2-presubmits.yaml
44-
- pingcap-tiflow-release-6.5-presubmits.yaml
4550
- pingcap-tiflow-release-6.5-fips-presubmits.yaml
46-
- pingcap-tidb-release-6.5-with-kv-timeout-feature-presubmits.yaml
51+
- pingcap-tiflow-release-6.5-presubmits.yaml
4752
- pingcap-tiflow-release-7.1-presubmits.yaml
4853
- pingcap-tiflow-release-7.1.0-presubmits.yaml
4954
- pingcap-tiflow-release-7.2-presubmits.yaml
5055
- pingcap-tiflow-release-7.3-presubmits.yaml
5156
- pingcap-tiflow-release-7.4-presubmits.yaml
5257
- pingcap-tiflow-release-7.5-presubmits.yaml
5358
- pingcap-tiflow-release-7.6-presubmits.yaml
54-
- pingcap-tiproxy-latest-presubmits.yaml
5559
- pingcap-tiproxy-latest-postsubmits.yaml
56-
- pingcap-tiflash-latest-postsubmits.yaml
57-
- pingcap-tiflash-latest-presubmits.yaml
58-
- pingcap-tidb-engine-ext-latest-presubmits.yaml
59-
- pingcap-tidb-engine-release-6.1-latest-presubmits.yaml
60+
- pingcap-tiproxy-latest-presubmits.yaml
6061
- ti-community-infra-configs-periodics.yaml
6162
- ti-community-infra-configs-postsubmits.yaml
6263
- ti-community-infra-configs-presubmits.yaml
@@ -66,6 +67,6 @@ configMapGenerator:
6667
- tikv-migration-latest-presubmits.yaml
6768
- tikv-pd-latest-presubmits.yaml
6869
- tikv-pd-release-6.1-presubmits.yaml
69-
- tikv-pd-release-6.5-presubmits.yaml
7070
- tikv-pd-release-6.5-fips-presubmits.yaml
71+
- tikv-pd-release-6.5-presubmits.yaml
7172
- tikv-pd-release-7.1-presubmits.yaml
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# struct ref: https://pkg.go.dev/k8s.io/test-infra/prow/config#Periodic
2+
periodics:
3+
- name: periodic-update-pingcap-monitoring
4+
decorate: true # need add this.
5+
cron: "*/5 * * * *" # @hourly
6+
skip_report: true
7+
extra_refs: # Periodic job doesn't clone any repo by default, needs to be added explicitly
8+
- org: pingcap
9+
repo: monitoring
10+
base_ref: master
11+
skip_submodules: true
12+
clone_depth: 1
13+
spec:
14+
containers:
15+
- name: check
16+
image: golang:1.21.6
17+
command: [bash, -ce]
18+
env:
19+
- name: TARGET
20+
value: master
21+
resources:
22+
limits:
23+
memory: 4Gi
24+
cpu: "1"
25+
volumeMounts:
26+
- name: github-token
27+
mountPath: /etc/github
28+
readOnly: true
29+
args:
30+
- |
31+
go run ./cmd/monitoring.go --tag=$TARGET --config monitoring.yaml
32+
git add monitor-snapshot/$TARGET
33+
if git diff --cached --exit-code; then
34+
echo "🤷 No changes happened."
35+
exit 0
36+
fi
37+
38+
# commit and push the changes
39+
git config user.email "[email protected]"
40+
git config user.name "ti-chi-bot"
41+
42+
# install `gh` tool
43+
type -p curl >/dev/null || ( apt update && apt install curl -y)
44+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
45+
&& chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
46+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
47+
&& apt update \
48+
&& apt install gh -y
49+
50+
# login and setup git
51+
gh auth login --with-token < /etc/github/token
52+
gh auth setup-git
53+
54+
# commit and push the changes.
55+
head_branch="fix/${TARGET}/update-snapshot-files"
56+
git checkout -b "$head_branch"
57+
commit_msg="chore(monitor-snapshot/master): update files from upstreams"
58+
git commit -m "$commit_msg"
59+
git push origin "$head_branch"
60+
61+
# create pull request
62+
cat <<EOF > pr_body.txt
63+
Auto generated by bot periodics.
64+
EOF
65+
gh pr create \
66+
--base $TARGET \
67+
--head "$head_branch" \
68+
--fill \
69+
--body-file pr_body.txt
70+
volumes:
71+
- name: github-token
72+
secret:
73+
secretName: github-token
74+
- name: periodic-update-pingcap-monitoring-lts-7.5
75+
decorate: true # need add this.
76+
cron: "0 * * * *" # @hourly
77+
skip_report: true
78+
extra_refs: # Periodic job doesn't clone any repo by default, needs to be added explicitly
79+
- org: pingcap
80+
repo: monitoring
81+
base_ref: release-7.5
82+
skip_submodules: true
83+
clone_depth: 1
84+
spec:
85+
containers:
86+
- name: check
87+
image: golang:1.21.6
88+
command: [bash, -ce]
89+
env:
90+
- name: TARGET
91+
value: release-7.5
92+
resources:
93+
limits:
94+
memory: 4Gi
95+
cpu: "1"
96+
volumeMounts:
97+
- name: github-token
98+
mountPath: /etc/github
99+
readOnly: true
100+
args:
101+
- |
102+
go run ./cmd/monitoring.go --tag=$TARGET --config monitoring.yaml
103+
git add monitor-snapshot/$TARGET
104+
if git diff --cached --exit-code; then
105+
echo "🤷 No changes happened."
106+
exit 0
107+
fi
108+
109+
git config user.email "[email protected]"
110+
git config user.name "ti-chi-bot"
111+
112+
# install `gh` tool
113+
type -p curl >/dev/null || ( apt update && apt install curl -y)
114+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
115+
&& chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
116+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
117+
&& apt update \
118+
&& apt install gh -y
119+
120+
# login and setup git
121+
gh auth login --with-token < /etc/github/token
122+
gh auth setup-git
123+
124+
# commit and push the changes.
125+
head_branch="fix/${TARGET}/update-snapshot-files"
126+
git checkout -b "$head_branch"
127+
commit_msg="chore(monitor-snapshot/master): update files from upstreams"
128+
git commit -m "$commit_msg"
129+
git push origin "$head_branch"
130+
131+
# create pull request
132+
cat <<EOF > pr_body.txt
133+
Auto generated by bot periodics.
134+
EOF
135+
gh pr create \
136+
--base $TARGET \
137+
--head "$head_branch" \
138+
--fill \
139+
--body-file pr_body.txt
140+
volumes:
141+
- name: github-token
142+
secret:
143+
secretName: github-token

0 commit comments

Comments
 (0)