-
Notifications
You must be signed in to change notification settings - Fork 69
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
Create a CLI for uploading and downloading blocks #760
Conversation
c2e16e5
to
2bd722d
Compare
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.
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
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.
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
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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.
You can omit this.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s = newstore(tsdbPath, objectConfig, objectKey) |
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.
s, err := newStore(...) | |
if err != nil { | |
logger.Log(..) | |
} |
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.
ctx, cancel := context.WithCancel(context.Backgroud()) | |
defer cancel() |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kingpin.MustParse(app.Parse(os.Args[1:])) |
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.
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 <kushalshukla110@gmail.com>
Signed-off-by: Kushal Shukla <kushalshukla110@gmail.com>
8a26921
to
79a3b3a
Compare
Signed-off-by: Kushal Shukla <kushalshukla110@gmail.com>
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.
few comments
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't do this; just use the instance-ssd
volume.
- name: config | ||
hostPath: | ||
path: /config-file |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
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.
No
06d8387
to
ad81105
Compare
2. changed upload-download function to extract key 3. updated bash.sh file Signed-off-by: Kushal Shukla <kushalshukla110@gmail.com>
ad81105
to
db44635
Compare
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.
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.
@@ -44,10 +44,35 @@ spec: | |||
- name: GITHUB_ORG | |||
value: "{{ .GITHUB_ORG }}" | |||
- name: GITHUB_REPO | |||
value: "{{ .GITHUB_REPO }}" | |||
value: "{{ .GITHUB_REPO }}" |
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.
spurious change
@@ -34,7 +34,7 @@ spec: | |||
runAsUser: 0 | |||
initContainers: | |||
- name: prometheus-builder | |||
image: docker.io/prominfra/prometheus-builder:master | |||
image: kushalshukla/builder |
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.
Guessing this one is built from the change in this PR.
tools/prometheus-builder/build.sh
Outdated
@@ -5,8 +5,7 @@ DIR="/go/src/github.com/prometheus/prometheus" | |||
if [[ -z $PR_NUMBER || -z $VOLUME_DIR || -z $GITHUB_ORG || -z $GITHUB_REPO ]]; then | |||
echo "ERROR:: environment variables not set correctly" | |||
exit 1; | |||
fi | |||
|
|||
fi |
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.
Spurious change - removal of blank line.
tools/prometheus-builder/build.sh
Outdated
MKDIR="/config" | ||
cp "$DIR/key.yml" "$MKDIR/key.yml" |
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.
This needs a comment at least.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <kushalshukla110@gmail.com>
77d1d9d
to
b8630f4
Compare
Signed-off-by: Kushal Shukla <kushalshukla110@gmail.com>
b8630f4
to
8232940
Compare
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.
Great, let's merge this and see how well it works.
This PR introduces a powerful 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