Skip to content

Commit db44635

Browse files
1. Added key.yml
2. changed upload-download function to extract key 3. updated bash.sh file Signed-off-by: Kushal Shukla <[email protected]>
1 parent d01a5d7 commit db44635

File tree

6 files changed

+97
-50
lines changed

6 files changed

+97
-50
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: s3-secret
5+
namespace: prombench-{{ .PR_NUMBER }} # Replace with your actual namespace
6+
type: Opaque
7+
stringData:
8+
object-config.yml: |
9+
type: S3
10+
config:
11+
bucket: {{ .BUCKET_KEY }}
12+
endpoint: minio:9000
13+
access_key: {{ .ACCESS_KEY }}
14+
secret_key: {{ .SECRET_KEY }}
15+
insecure: true
16+

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

+46-21
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,34 @@ 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
51-
- name: config
52-
mountPath: /config
51+
- name: key
52+
mountPath: /config
5353
- name: data-downloader
5454
image: kushalshukla/writer
55-
imagePullPolicy: Always
55+
imagePullPolicy: Always
56+
env:
57+
- name: ACCESS_KEY
58+
value: "{{ .ACCESS_KEY }}"
59+
- name: SECRET_KEY
60+
value: "{{ .SECRET_KEY }}"
61+
- name: BUCKET_KEY
62+
value: "{{ .BUCKET_KEY }}"
5663
volumeMounts:
5764
- name: instance-ssd
5865
mountPath: /data
59-
- name: config
60-
mountPath: /mnc
66+
- name: s3-config
67+
mountPath: /config
68+
- name: key
69+
mountPath: /key
6170
args: [
6271
"download",
6372
"--tsdb-path=/data",
64-
"--objstore.config-file=/mnc/objectconfig.yml",
65-
"--key=gendata"
73+
"--objstore.config-file=/config/object-config.yml",
74+
"--key=/key/key.yml"
6675
]
6776
containers:
6877
- name: prometheus
@@ -104,9 +113,11 @@ spec:
104113
path: /mnt/disks/ssd0 #gke ssds
105114
- name: prometheus-executable
106115
emptyDir: {}
107-
- name: config
108-
hostPath:
109-
path: /config-file
116+
- name: s3-config # Define the Secret volume
117+
secret:
118+
secretName: s3-secret
119+
- name: key
120+
emptyDir: {}
110121
terminationGracePeriodSeconds: 300
111122
nodeSelector:
112123
node-name: prometheus-{{ .PR_NUMBER }}
@@ -175,30 +186,39 @@ spec:
175186
cd /repo1 && \
176187
git fetch origin pull/{{ .PR_NUMBER }}/head:pr-branch && \
177188
git checkout pr-branch && \
178-
cp objectconfig.yml /mnt/repo/objectconfig.yml && \
189+
cp key.yml /config/key.yml && \
179190
rm -rf /repo1
180191
volumeMounts:
181-
- name: config
182-
mountPath: /mnt/repo
192+
- name: key
193+
mountPath: /config
183194
- name: data-downloader
184195
image: kushalshukla/writer
185-
imagePullPolicy: Always
196+
imagePullPolicy: Always
197+
env:
198+
- name: ACCESS_KEY
199+
value: "{{ .ACCESS_KEY }}"
200+
- name: SECRET_KEY
201+
value: "{{ .SECRET_KEY }}"
202+
- name: BUCKET_KEY
203+
value: "{{ .BUCKET_KEY }}"
186204
volumeMounts:
187205
- name: instance-ssd
188206
mountPath: /data
189-
- name: config
190-
mountPath: /mnc
207+
- name: s3-config
208+
mountPath: /config
209+
- name: key
210+
mountPath: /key
191211
args: [
192212
"download",
193213
"--tsdb-path=/data",
194-
"--objstore.config-file=/mnc/objectconfig.yml",
195-
"--key=gendata"
214+
"--objstore.config-file=/config/object-config.yml",
215+
"--key=/key/key.yml"
196216
]
197217
containers:
198218
- name: prometheus
199219
image: quay.io/prometheus/prometheus:{{ .RELEASE }}
200220
imagePullPolicy: Always
201-
command: [ "/bin/prometheus"]
221+
command: [ "/bin/prometheus" ]
202222
args: [
203223
"--web.external-url=http://{{ .DOMAIN_NAME }}/{{ .PR_NUMBER }}/prometheus-release",
204224
"--storage.tsdb.path=/prometheus",
@@ -224,7 +244,12 @@ spec:
224244
path: /mnt/disks/ssd0
225245
- name: config
226246
hostPath:
227-
path: /object-config
247+
path: /object-config
248+
- name: s3-config # Define the Secret volume
249+
secret:
250+
secretName: s3-secret
251+
- name: key
252+
emptyDir: {}
228253
terminationGracePeriodSeconds: 300
229254
nodeSelector:
230255
node-name: prometheus-{{ .PR_NUMBER }}

tools/block-sync/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ The `download` command allows you to retrieve TSDB data from an object storage b
4141
The configuration file is essential for connecting to your object storage solution. Below are basic templates for different object storage systems.
4242

4343
```yaml
44-
type: s3
44+
type: s3, GCS , AZURE , etc.
4545
config:
4646
bucket: your-bucket-name
47-
endpoint: https://your-minio-endpoint.com
47+
endpoint: https://your-endpoint
4848
access_key: your-access-key
4949
secret_key: your-secret-key
5050
insecure: false # Set to true if using HTTP instead of HTTPS

tools/block-sync/upload_download.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"fmt"
1919
"log/slog"
2020
"os"
21+
"strings"
2122

2223
"github.com/go-kit/log"
2324
"github.com/thanos-io/objstore"
@@ -42,10 +43,23 @@ func newStore(tsdbPath, objectConfig, objectKey string, logger *slog.Logger) (*S
4243
if err != nil {
4344
return nil, fmt.Errorf("failed to create bucket existence:%w", err)
4445
}
46+
key, err := os.ReadFile(objectKey)
47+
if err != nil {
48+
return nil, fmt.Errorf("failed to read objectKey file: %w", err)
49+
}
50+
51+
content := strings.TrimSpace(string(key))
52+
var value string
53+
if strings.HasPrefix(content, "key:") {
54+
value = strings.TrimSpace(strings.TrimPrefix(content, "key:"))
55+
} else {
56+
return nil, fmt.Errorf("expected 'key:' prefix not found")
57+
}
58+
4559
return &Store{
4660
bucket: bucket,
4761
tsdbpath: tsdbPath,
48-
objectkey: objectKey,
62+
objectkey: value,
4963
objectconfig: objectConfig,
5064
bucketlogger: logger,
5165
}, nil

tools/load-generator/main.go

+16-23
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,10 @@ func NewQuerier(groupID int, target, prNumber string, qg QueryGroup) *Querier {
100100

101101
start := durationSeconds(qg.Start)
102102
end := durationSeconds(qg.End)
103-
fmt.Println(qtype, "HI from query ka type range or instant")
104-
nodePort := 30198
105-
url := fmt.Sprintf("http://%s:%d/%s/prometheus-%s/api/v1/query", domainName, nodePort, prNumber, target)
103+
104+
url := fmt.Sprintf("http://%s/%s/prometheus-%s/api/v1/query", domainName, prNumber, target)
106105
if qtype == "range" {
107-
url = fmt.Sprintf("http://%s:%d/%s/prometheus-%s/api/v1/query_range", domainName, nodePort, prNumber, target)
106+
url = fmt.Sprintf("http://%s/%s/prometheus-%s/api/v1/query_range", domainName, prNumber, target)
108107
}
109108

110109
return &Querier{
@@ -121,26 +120,28 @@ func NewQuerier(groupID int, target, prNumber string, qg QueryGroup) *Querier {
121120
}
122121
}
123122

124-
func (q *Querier) run(wg *sync.WaitGroup, baseTime *time.Time) {
123+
func (q *Querier) run(wg *sync.WaitGroup) {
125124
defer wg.Done()
126125
fmt.Printf("Running querier %s %s for %s\n", q.target, q.name, q.url)
127126
time.Sleep(20 * time.Second)
127+
128128
for {
129129
start := time.Now()
130130

131131
for _, query := range q.queries {
132-
q.query(query.Expr, baseTime)
132+
q.query(query.Expr)
133133
}
134-
*baseTime = baseTime.Add(2 * time.Minute)
134+
135135
wait := q.interval - time.Since(start)
136136
if wait > 0 {
137137
time.Sleep(wait)
138138
}
139139
}
140140
}
141141

142-
func (q *Querier) query(expr string, baseTime *time.Time) {
142+
func (q *Querier) query(expr string) {
143143
queryCount.WithLabelValues(q.target, q.name, expr, q.qtype).Inc()
144+
start := time.Now()
144145

145146
req, err := http.NewRequest("GET", q.url, nil)
146147
if err != nil {
@@ -152,12 +153,10 @@ func (q *Querier) query(expr string, baseTime *time.Time) {
152153
qParams := req.URL.Query()
153154
qParams.Set("query", expr)
154155
if q.qtype == "range" {
155-
qParams.Set("start", fmt.Sprintf("%d", int64(baseTime.Add(-q.start).Unix())))
156-
qParams.Set("end", fmt.Sprintf("%d", int64(baseTime.Add(-q.end).Unix())))
156+
qParams.Set("start", fmt.Sprintf("%d", int64(time.Now().Add(-q.start).Unix())))
157+
qParams.Set("end", fmt.Sprintf("%d", int64(time.Now().Add(-q.end).Unix())))
157158
qParams.Set("step", q.step)
158159
}
159-
fmt.Println(qParams["start"], "Hi from start Time")
160-
fmt.Println(qParams["end"], "Hi from end End Time")
161160
req.URL.RawQuery = qParams.Encode()
162161

163162
resp, err := http.DefaultClient.Do(req)
@@ -166,17 +165,11 @@ func (q *Querier) query(expr string, baseTime *time.Time) {
166165
queryFailCount.WithLabelValues(q.target, q.name, expr, q.qtype).Inc()
167166
return
168167
}
169-
// body, err := io.ReadAll(resp.Body)
170-
// if err != nil {
171-
// fmt.Println("Error reading response body:", err)
172-
// return
173-
// }
174-
// fmt.Println(baseTime, "Hi from baseTime")
175-
// fmt.Println("Response Body:", string(body))
176168
defer resp.Body.Close()
177169

178-
duration := time.Since(*baseTime)
170+
duration := time.Since(start)
179171
queryDuration.WithLabelValues(q.target, q.name, expr, q.qtype).Observe(duration.Seconds())
172+
180173
if resp.StatusCode == http.StatusNotFound {
181174
log.Printf("WARNING: GroupID#%d: Querier returned 404 for Prometheus instance %s.", q.groupID, q.url)
182175
q.numberOfErrors++
@@ -227,12 +220,12 @@ func main() {
227220
fmt.Println("Loaded configuration")
228221

229222
var wg sync.WaitGroup
230-
baseTime := time.Date(2024, time.October, 23, 15, 34, 32, 541000000, time.UTC)
223+
231224
for i, group := range config.Querier.Groups {
232225
wg.Add(1)
233-
go NewQuerier(i, "pr", prNumber, group).run(&wg, &baseTime)
226+
go NewQuerier(i, "pr", prNumber, group).run(&wg)
234227
wg.Add(1)
235-
go NewQuerier(i, "release", prNumber, group).run(&wg, &baseTime)
228+
go NewQuerier(i, "release", prNumber, group).run(&wg)
236229
}
237230

238231
prometheus.MustRegister(queryDuration, queryCount, queryFailCount)

tools/prometheus-builder/build.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ 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
9-
8+
fi
109
# Clone the repository with a shallow clone
1110
echo ">> Cloning repository $GITHUB_ORG/$GITHUB_REPO (shallow clone)"
1211
if ! git clone --depth 1 https://github.com/$GITHUB_ORG/$GITHUB_REPO.git $DIR; then
@@ -25,7 +24,7 @@ fi
2524
git checkout pr-branch
2625

2726
MKDIR="/config"
28-
cp "$DIR/objectconfig.yml" "$MKDIR/objectconfig.yml"
27+
cp "$DIR/key.yml" "$MKDIR/key.yml"
2928

3029
echo ">> Creating prometheus binaries"
3130
if ! make build PROMU_BINARIES="prometheus"; then

0 commit comments

Comments
 (0)