Skip to content
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

Storage advisor #3

Merged
merged 10 commits into from
Jan 15, 2024
Merged

Storage advisor #3

merged 10 commits into from
Jan 15, 2024

Conversation

dmgburg
Copy link
Contributor

@dmgburg dmgburg commented Jan 2, 2024

No description provided.

@dmgburg dmgburg requested a review from vprus January 2, 2024 19:00
Copy link
Collaborator

@vprus vprus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks; I think it's generally solid, but I would appreciate a few tweaks - in particular around logging.


FROM ubuntu AS bin

COPY eu-central-1-bundle.crt /usr/local/share/ca-certificates/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we don't need this one - it's only necessary if we're talking to AWS RDS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed


ctx := context.TODO()
cfg, err := config.LoadDefaultConfig(ctx)
cfg.Region = "eu-central-1"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should not hardcode region.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to flags but I don't see a reason to host it anywhere outside of eu-1

cfg, err := config.LoadDefaultConfig(ctx)
cfg.Region = "eu-central-1"
if err != nil {
log.Println("Error:", err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is server-side code, I'd recommend we use zerolog for all logging. It produces json structured output, which is way easier to handle. Also, it has a fatal level, which we can use instead of explicit return or os.exit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

select {
case sig := <-sigchan:
log.Printf("Caught signal %v: terminating\n", sig)
run = false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's more of stylistic comment - but maybe "while true" look with "break" will be a bit cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}
defer reader.Close()

err = uploadToS3(cfg, ctx, reader, *bucketName, objectKey)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can use S3 CopyObject functionality here? I am not sure if that works with pre-signed URLs, but it if does, it will be more efficient than downloading and uploading.

@@ -0,0 +1,124 @@
-----BEGIN CERTIFICATE-----
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And then we don't need this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@dmgburg dmgburg requested a review from vprus January 3, 2024 19:57
@dmgburg
Copy link
Contributor Author

dmgburg commented Jan 10, 2024

Copy link
Collaborator

@vprus vprus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good enough to me; let's merge.

@vprus vprus merged commit 725556d into main Jan 15, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants