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

Factor out object read/write from BucketAlertStore into ProtobufStore. #3998

Closed
wants to merge 1 commit into from

Conversation

stevesg
Copy link
Contributor

@stevesg stevesg commented Mar 23, 2021

What this PR does:
Factor out object read/write from BucketAlertStore into ProtobufStore. The BucketAlertStore is 90% of what I need for persisting the notifications/silences state, so it seems wasteful to copy/paste it.


// ProtobufStore is used to read/write protobuf messages to object storage backend. It is implemented
// using the Thanos objstore.Bucket interface
type ProtobufStore struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Naming suggestions welcome.

@@ -0,0 +1,95 @@
package bucketclient
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume there's a better place to put this file, perhaps somewhere in pkg/storage or pkg/util, just tell me where and I'll move it.

Copy link
Contributor

Choose a reason for hiding this comment

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

As far as it will be used only here, I would keep it here. We can move it around when required. Right now, it doesn't look necessary.

@stevesg stevesg marked this pull request as ready for review March 23, 2021 10:46
@stevesg stevesg force-pushed the alert-store-refactor branch 3 times, most recently from 610f8e0 to d075287 Compare March 23, 2021 19:51
Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

Thanks for working on this refactoring.

I left a couple of comments but then I stopped reviewing it cause I had a doubt. The structure of the alertmanager config in the bucket is alerts/<user id> where alerts/<user id> is the object key storing the alertmanager config for <user id>.

We're not used to have this pattern for the storage, while we typically have alerts/<user id>/<object name> structure. When we designed the state persistence, we agreed on using this latter structure, but I've the feeling it will clash with this refactoring, because ProtobufStore is designed around the alertmanager structure which is a special case.

I would like to better understand how you plan to use ProtobufStore for the state persistence before continuing with the review. Thanks!

@@ -0,0 +1,95 @@
package bucketclient
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as it will be used only here, I would keep it here. We can move it around when required. Right now, it doesn't look necessary.

}

// Set writes the content for an entry in the store for a particular user.
func (s *ProtobufStore) Set(ctx context.Context, userID string, msg proto.Message) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about calling it Upload() to keep it specular to the underlying objstore.Bucket function name?

@stevesg stevesg force-pushed the alert-store-refactor branch from d075287 to d6d47bf Compare March 25, 2021 10:04
@stevesg
Copy link
Contributor Author

stevesg commented Mar 26, 2021

After talking to @pracucci, I like the idea of adding the interfaces onto the existing AlertStore instead. This will save a some of plumbing (passing in a new store or the configuration required for the store), and makes sense if we want to store them in the form alerts/<user id>/<object name> alongside the existing configuration state.

I've move this to draft for now - no need to review further.

@stevesg stevesg marked this pull request as draft March 26, 2021 08:45
@stevesg
Copy link
Contributor Author

stevesg commented Mar 26, 2021

Closing this in preference of #4020

@stevesg stevesg closed this Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants