Skip to content

Commit 540fc28

Browse files
Signed-off-by: Kushal Shukla <[email protected]>
Key changes 1. removed multiline command and put it in script on prometheus-builder image. 2. configure this in prometheus deployment. 3. added download.sh script which will download the data if key present , else skip the downloading process and move to next container.
1 parent db44635 commit 540fc28

File tree

6 files changed

+82
-33
lines changed

6 files changed

+82
-33
lines changed

prombench/manifests/prombench/benchmark/3b_prometheus-test_deployment.yaml

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ spec:
4444
- name: GITHUB_ORG
4545
value: "{{ .GITHUB_ORG }}"
4646
- name: GITHUB_REPO
47-
value: "{{ .GITHUB_REPO }}"
47+
value: "{{ .GITHUB_REPO }}"
4848
volumeMounts:
4949
- name: prometheus-executable
5050
mountPath: /prometheus-builder
@@ -66,13 +66,7 @@ spec:
6666
- name: s3-config
6767
mountPath: /config
6868
- name: key
69-
mountPath: /key
70-
args: [
71-
"download",
72-
"--tsdb-path=/data",
73-
"--objstore.config-file=/config/object-config.yml",
74-
"--key=/key/key.yml"
75-
]
69+
mountPath: /key
7670
containers:
7771
- name: prometheus
7872
image: quay.io/prometheus/busybox:latest
@@ -117,7 +111,7 @@ spec:
117111
secret:
118112
secretName: s3-secret
119113
- name: key
120-
emptyDir: {}
114+
emptyDir: {}
121115
terminationGracePeriodSeconds: 300
122116
nodeSelector:
123117
node-name: prometheus-{{ .PR_NUMBER }}
@@ -175,19 +169,17 @@ spec:
175169
securityContext:
176170
runAsUser: 0
177171
initContainers:
178-
- name: git-fetcher
179-
image: alpine/git
180-
command:
181-
- /bin/sh
182-
- -c
183-
- |
184-
apk add --no-cache bash && \
185-
git clone --depth 1 https://github.com/{{ .GITHUB_ORG }}/{{ .GITHUB_REPO }}.git /repo1 && \
186-
cd /repo1 && \
187-
git fetch origin pull/{{ .PR_NUMBER }}/head:pr-branch && \
188-
git checkout pr-branch && \
189-
cp key.yml /config/key.yml && \
190-
rm -rf /repo1
172+
- name: download-key
173+
image: kushalshukla/builder
174+
imagePullPolicy: Always
175+
command: [ "/download-key/key.sh" ]
176+
env:
177+
- name: PR_NUMBER
178+
value: "{{ .PR_NUMBER }}"
179+
- name: GITHUB_ORG
180+
value: "{{ .GITHUB_ORG }}"
181+
- name: GITHUB_REPO
182+
value: "{{ .GITHUB_REPO }}"
191183
volumeMounts:
192184
- name: key
193185
mountPath: /config
@@ -207,13 +199,7 @@ spec:
207199
- name: s3-config
208200
mountPath: /config
209201
- name: key
210-
mountPath: /key
211-
args: [
212-
"download",
213-
"--tsdb-path=/data",
214-
"--objstore.config-file=/config/object-config.yml",
215-
"--key=/key/key.yml"
216-
]
202+
mountPath: /key
217203
containers:
218204
- name: prometheus
219205
image: quay.io/prometheus/prometheus:{{ .RELEASE }}

tools/block-sync/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ RUN apk --no-cache add libc6-compat
55

66
COPY ./block-sync /bin/block-sync
77

8+
# Copy the download.sh script into the container's /scripts directory
9+
COPY ./download.sh /scripts/download.sh
10+
11+
# Ensure that the download.sh script is executable
12+
RUN chmod +x /scripts/download.sh
13+
814
RUN chmod +x /bin/block-sync
915

10-
ENTRYPOINT ["/bin/block-sync"]
16+
ENTRYPOINT [ "/scripts/download.sh" ]

tools/block-sync/download.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
KEY_FILE="/key/key.yml"
4+
5+
if [[ -f "$KEY_FILE" ]]; then
6+
echo "Found key.yml, proceeding with download..."
7+
/bin/block-sync download --tsdb-path=/data --objstore.config-file=/config/object-config.yml --key=$KEY_FILE
8+
else
9+
echo "key.yml not found, skipping download."
10+
exit 0
11+
fi

tools/prometheus-builder/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ RUN mkdir -p /go/src/github.com
44

55
COPY ./build.sh /go/src/github.com/build.sh
66

7+
COPY ./key.sh /download-key/key.sh
8+
79
RUN chmod +x /go/src/github.com/build.sh
810

911
ENTRYPOINT ["/go/src/github.com/build.sh"]

tools/prometheus-builder/build.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ DIR="/go/src/github.com/prometheus/prometheus"
55
if [[ -z $PR_NUMBER || -z $VOLUME_DIR || -z $GITHUB_ORG || -z $GITHUB_REPO ]]; then
66
echo "ERROR:: environment variables not set correctly"
77
exit 1;
8-
fi
8+
fi
9+
910
# Clone the repository with a shallow clone
1011
echo ">> Cloning repository $GITHUB_ORG/$GITHUB_REPO (shallow clone)"
1112
if ! git clone --depth 1 https://github.com/$GITHUB_ORG/$GITHUB_REPO.git $DIR; then
@@ -23,8 +24,16 @@ fi
2324

2425
git checkout pr-branch
2526

27+
# Here, MKDIR is specified in the volumeMount section of the prometheus-builder init container,
28+
# where it will copy the key.yml file from the Prometheus directory to the volume section of the
29+
# emptyDir. This file will later be used by the data-downloader init container.
2630
MKDIR="/config"
27-
cp "$DIR/key.yml" "$MKDIR/key.yml"
31+
if [ -f "$DIR/key.yml" ]; then
32+
echo "File exists."
33+
cp "$DIR/key.yml" "$MKDIR/key.yml"
34+
else
35+
echo "File does not exist."
36+
fi
2837

2938
echo ">> Creating prometheus binaries"
3039
if ! make build PROMU_BINARIES="prometheus"; then
@@ -33,4 +42,4 @@ if ! make build PROMU_BINARIES="prometheus"; then
3342
fi
3443

3544
echo ">> Copy files to volume"
36-
cp prometheus $VOLUME_DIR/prometheus
45+
cp prometheus $VOLUME_DIR/prometheus

tools/prometheus-builder/key.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
DIR="/go/src/github.com/prometheus/prometheus"
4+
5+
if [[ -z $PR_NUMBER || -z $GITHUB_ORG || -z $GITHUB_REPO ]]; then
6+
echo "ERROR:: environment variables not set correctly"
7+
exit 1;
8+
fi
9+
# Clone the repository with a shallow clone
10+
echo ">> Cloning repository $GITHUB_ORG/$GITHUB_REPO (shallow clone)"
11+
if ! git clone --depth 1 https://github.com/$GITHUB_ORG/$GITHUB_REPO.git $DIR; then
12+
echo "ERROR:: Cloning of repo $GITHUB_ORG/$GITHUB_REPO failed"
13+
exit 1;
14+
fi
15+
16+
cd $DIR || exit 1
17+
18+
echo ">> Fetching Pull Request $GITHUB_ORG/$GITHUB_REPO/pull/$PR_NUMBER"
19+
if ! git fetch origin pull/$PR_NUMBER/head:pr-branch; then
20+
echo "ERROR:: Fetching of PR $PR_NUMBER failed"
21+
exit 1;
22+
fi
23+
24+
git checkout pr-branch
25+
26+
# Here, MKDIR is specified in the volumeMount section of the download-key init container, where it
27+
# will copy the key.yml file from the Prometheus directory to the volume section of the emptyDir.
28+
# This file will later be used by the data-downloader init container.
29+
MKDIR="/config"
30+
if [ -f "$DIR/key.yml" ]; then
31+
echo "File exists."
32+
cp "$DIR/key.yml" "$MKDIR/key.yml"
33+
else
34+
echo "File does not exist."
35+
fi

0 commit comments

Comments
 (0)