Create a CLI for uploading and downloading blocks#760
Create a CLI for uploading and downloading blocks#760bboreham merged 11 commits intoprometheus:masterfrom
Conversation
c2e16e5 to
2bd722d
Compare
bboreham
left a comment
There was a problem hiding this comment.
I see 'upload'; will you be downloading data at some point?
yes @bboreham I have to implement both upload and download functionality. |
b2a0dcb to
25bcf19
Compare
kakkoyun
left a comment
There was a problem hiding this comment.
It's a good start. Let's keep up the good work.
|
@kushalShukla-web Also, we should work on the PR title and the description. Please also sign your commits https://github.com/prometheus/test-infra/pull/760/checks?check_run_id=30633470860 |
15d50a2 to
bb712d2
Compare
93ab7c4 to
ffb9fdd
Compare
kakkoyun
left a comment
There was a problem hiding this comment.
It's going in a good direction. Thanks a lot. I have commented. We need to clean up the architecture.
We should also work on the naming and documentation. We miss the README as well.
Check this out https://go.dev/blog/package-names
| config := c.ObjectConfig | ||
| configBytes, err := os.ReadFile(config) | ||
| if err != nil { | ||
| panic(fmt.Errorf("failed to read config file: %v", err)) |
There was a problem hiding this comment.
This function returns an error. Why do we panic? Let's just return the error.
tools/object-storage/obj.go
Outdated
| app := kingpin.New(filepath.Base(os.Args[0]), "Tool for storing TSDB data to object storage") | ||
| app.HelpFlag.Short('h') | ||
|
|
||
| s := newstore() |
There was a problem hiding this comment.
This constructor should get the flag variable. Why do we have a store in an inconsistent state?
| } | ||
| fmt.Println(exists) | ||
|
|
||
| err = objstore.UploadDir(context.Background(), log.NewNopLogger(), bucket, c.TsdbPath, commitDir) |
There was a problem hiding this comment.
We should give a proper logger to the buckets.
| } | ||
| commitDir := c.ObjectKey | ||
|
|
||
| bucket, err := client.NewBucket(log.NewNopLogger(), configBytes, "example") |
There was a problem hiding this comment.
| bucket, err := client.NewBucket(log.NewNopLogger(), configBytes, "example") | |
| bucket, err := client.NewBucket(log.NewNopLogger(), configBytes, "block-sync") |
We could use a proper component name.
| if err != nil { | ||
| panic(err) | ||
| } | ||
| exists, err := bucket.Exists(context.Background(), "example") |
There was a problem hiding this comment.
example is wrong here, no? This should be a parent directory we get as a command line argument.
| panic(fmt.Errorf("failed to read config file: %v", err)) | ||
| } | ||
| commitDir := c.ObjectKey | ||
| bucket, err := client.NewBucket(log.NewNopLogger(), configBytes, "example") |
There was a problem hiding this comment.
Again we should use a proper component name.
b6cb4e7 to
c9d5111
Compare
tools/blockSyncer/obj.go
Outdated
| app.HelpFlag.Short('h') | ||
|
|
||
| var tsdbPath, objectConfig, objectKey string | ||
| var s *Store |
tools/blockSyncer/obj.go
Outdated
| objstore.Flag("tsdb-path", "Path for The TSDB data in prometheus").Required().StringVar(&tsdbPath) | ||
| objstore.Flag("objstore.config-file", "Path for The Config file").Required().StringVar(&objectConfig) | ||
| objstore.Flag("key", "Path for the Key where to store block data").Required().StringVar(&objectKey) | ||
|
|
There was a problem hiding this comment.
| s = newstore(tsdbPath, objectConfig, objectKey) |
There was a problem hiding this comment.
| s, err := newStore(...) | |
| if err != nil { | |
| logger.Log(..) | |
| } |
There was a problem hiding this comment.
| ctx, cancel := context.WithCancel(context.Backgroud()) | |
| defer cancel() |
There was a problem hiding this comment.
| ctx, stop := signal.NotifyContext(ctx, os.Interrupt) | |
| defer stop() |
tools/blockSyncer/obj.go
Outdated
| objstore.Flag("tsdb-path", "Path for The TSDB data in prometheus").Required().StringVar(&tsdbPath) | ||
| objstore.Flag("objstore.config-file", "Path for The Config file").Required().StringVar(&objectConfig) | ||
| objstore.Flag("key", "Path for the Key where to store block data").Required().StringVar(&objectKey) | ||
|
|
There was a problem hiding this comment.
| kingpin.MustParse(app.Parse(os.Args[1:])) |
There was a problem hiding this comment.
I think if we move this to line 34, it will not be able to recognize the download and upload functions because these lines are declared below.
f9f13a2 to
5840472
Compare
5840472 to
b596e31
Compare
|
Is this something that would be useful in |
|
Ah this is for old data in prombench, cool. |
Signed-off-by: Kushal Shukla <[email protected]>
8a26921 to
79a3b3a
Compare
Signed-off-by: Kushal Shukla <[email protected]>
| cd /repo1 && \ | ||
| git fetch origin pull/{{ .PR_NUMBER }}/head:pr-branch && \ | ||
| git checkout pr-branch && \ | ||
| cp objectconfig.yml /mnt/repo/objectconfig.yml && \ |
There was a problem hiding this comment.
This is where you would be combining password etc from some Secret?
prombench/manifests/prombench/benchmark/3b_prometheus-test_deployment.yaml
Outdated
Show resolved
Hide resolved
| - name: config | ||
| hostPath: | ||
| path: /object-config |
There was a problem hiding this comment.
Don't do this; just use the instance-ssd volume.
| - name: config | ||
| hostPath: | ||
| path: /config-file |
There was a problem hiding this comment.
Don't do this; just use the instance-ssd volume.
tools/block-sync/README.md
Outdated
| The configuration file is essential for connecting to your object storage solution. Below are basic templates for different object storage systems. | ||
|
|
||
| ```yaml | ||
| type: s3 |
There was a problem hiding this comment.
Are other types available? E.g. GCS?
tools/load-generator/main.go
Outdated
| defer resp.Body.Close() | ||
|
|
||
| duration := time.Since(start) | ||
| duration := time.Since(*baseTime) |
06d8387 to
ad81105
Compare
2. changed upload-download function to extract key 3. updated bash.sh file Signed-off-by: Kushal Shukla <[email protected]>
ad81105 to
db44635
Compare
bboreham
left a comment
There was a problem hiding this comment.
We've discussed this PR on video-call and on Slack; I'm repeating a couple of points here:
- Make this PR just the CLI program; pull out the yamls and scripting to another PR.
- Get the images updated in one PR, then change the yamls that use them. We can't merge a change to use your privately-built image.
| value: "{{ .GITHUB_ORG }}" | ||
| - name: GITHUB_REPO | ||
| value: "{{ .GITHUB_REPO }}" | ||
| value: "{{ .GITHUB_REPO }}" |
| initContainers: | ||
| - name: prometheus-builder | ||
| image: docker.io/prominfra/prometheus-builder:master | ||
| image: kushalshukla/builder |
There was a problem hiding this comment.
Guessing this one is built from the change in this PR.
tools/prometheus-builder/build.sh
Outdated
| exit 1; | ||
| fi | ||
|
|
||
| fi |
There was a problem hiding this comment.
Spurious change - removal of blank line.
tools/prometheus-builder/build.sh
Outdated
| MKDIR="/config" | ||
| cp "$DIR/key.yml" "$MKDIR/key.yml" |
| apk add --no-cache bash && \ | ||
| git clone --depth 1 https://github.com/{{ .GITHUB_ORG }}/{{ .GITHUB_REPO }}.git /repo1 && \ | ||
| cd /repo1 && \ | ||
| git fetch origin pull/{{ .PR_NUMBER }}/head:pr-branch && \ | ||
| git checkout pr-branch && \ | ||
| cp key.yml /config/key.yml && \ | ||
| rm -rf /repo1 |
There was a problem hiding this comment.
This multi-line command is getting unwieldly. Pull it out to a .sh file.
| type: Opaque | ||
| stringData: | ||
| object-config.yml: | | ||
| type: S3 |
There was a problem hiding this comment.
This is going to be configured differently for each installation - s3 is good for local installs using Minio, but when run at Google Cloud it needs to say gcs.
I suggest you take this Secret out of the PR and instead put instructions in the docs, e.g. here, for the person who installs Prombench to set it up.
| kind: Secret | ||
| metadata: | ||
| name: s3-secret | ||
| namespace: prombench-{{ .PR_NUMBER }} # Replace with your actual namespace |
There was a problem hiding this comment.
I see you put the Secret in the namespace for the PR, but I see the same bucket being used across many runs.
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.
3459af4 to
540fc28
Compare
|
One thing that could be added (not vital right now) is to be able to upload several blocks. Example: I can specify one block, e.g. 01JC3J7CCY83F1EZGCBMEPG2RY, but I can't specify two. |
…t.yaml. 2. Added a section for secretes in kind.md file Signed-off-by: Kushal Shukla <[email protected]>
77d1d9d to
b8630f4
Compare
Signed-off-by: Kushal Shukla <[email protected]>
b8630f4 to
8232940
Compare
bboreham
left a comment
There was a problem hiding this comment.
Great, let's merge this and see how well it works.
Create a CLI for uploading and downloading blocks
This PR introduces a CLI tool for seamless block uploading and downloading. The initial implementation leverages an object storage as the storage backend, with the potential for other storage backends in the future.
Structured logging is a key feature of this PR, made possible by the utilization of the log/slog package. This enables easier traceability and debugging during storage operations.
Test plan