-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
feat(thanos): make use of the new function IterWithAttributes #14793
feat(thanos): make use of the new function IterWithAttributes #14793
Conversation
|
||
err := o.bucket.Iter(ctx, prefix, func(objectKey string) error { | ||
err := o.bucket.IterWithAttributes(ctx, prefix, func(attrs objstore.IterObjectAttributes) error { |
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.
let's also check if the provider supports UpdatedAt
option, if not we should make a follow-up Attributes call to fetch it given the callers of List
might use the ModifiedAt
field
attr, err := o.bucket.Attributes(ctx, objectKey) | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to get attributes for %s", objectKey) | ||
lastModified, ok := attrs.LastModified() |
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 we should fail if lastModified is not set, callers of List
might expect this to be set
} | ||
|
||
err := o.bucket.Iter(ctx, prefix, func(objectKey string) error { | ||
supportUpdatedAt := objstore.ValidateIterOptions(o.bucket.SupportedIterOptions(), objstore.WithUpdatedAt()) == nil |
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 don't like how this validation method turned out 😓 i think alternatively we could use
slices.Contains(o.bucket.SupportedIterOptions(), objstore.UpdatedAt)
} | ||
|
||
err := o.bucket.Iter(ctx, prefix, func(objectKey string) error { | ||
supportUpdatedAt := objstore.ValidateIterOptions(o.bucket.SupportedIterOptions(), objstore.WithUpdatedAt()) == nil |
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.
supportUpdatedAt := objstore.ValidateIterOptions(o.bucket.SupportedIterOptions(), objstore.WithUpdatedAt()) == nil | |
supportsUpdatedAt := objstore.ValidateIterOptions(o.bucket.SupportedIterOptions(), objstore.WithUpdatedAt()) == nil |
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.
@JoaoBraveCoding just a couple of nits
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.
lgtm! thanks @JoaoBraveCoding
What this PR does / why we need it:
With thanos-io/objstore#63 we now don't need to make an extra call to get the Attributes
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Checklist
CONTRIBUTING.md
guide (required)feat
PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.docs/sources/setup/upgrade/_index.md
deprecated-config.yaml
anddeleted-config.yaml
files respectively in thetools/deprecated-config-checker
directory. Example PR