-
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
fix: Transform ObjectExistsWithSize
into GetAttributes
#14329
Conversation
- We're not correctly returning the size of the file when there's no error
82cdd4b
to
dcc914e
Compare
ObjectExistsWithSize
s3 implementation not returning size correctlyObjectExistsWithSize
into ObjectSize
ObjectExistsWithSize
into ObjectSize
ObjectExistsWithSize
into GetAttributes
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.
Small nits, overall lgtm! Thank you for this!
if err != nil { | ||
return false, err | ||
} | ||
return true, 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.
To make it consistent across the different implementations
if err != nil { | |
return false, err | |
} | |
return true, nil | |
return err == nil, err |
if err != nil { | ||
return false, err | ||
} | ||
return true, 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.
To make it consistent across the different implementations
if err != nil { | |
return false, err | |
} | |
return true, nil | |
return err == nil, err |
if err != nil { | ||
return false, err | ||
} | ||
return true, 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.
To make it consistent across the different implementations
if err != nil { | |
return false, err | |
} | |
return true, nil | |
} | |
return err == nil, err |
if err != nil { | ||
return false, err | ||
} | ||
return true, 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.
To make it consistent across the different implementations
if err != nil { | |
return false, err | |
} | |
return true, nil | |
return err == nil, 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.
That's super fair but I found a problem with the approach I was following so I had to rewrite everything. I should only return an error if the error isn't NotFound
. Not all clients support it which is ok but some of them support it so the rewrite was necessary to keep the old behavior.
return b.objectAttributes(ctx, objectKey, "azure.GetAttributes") | ||
} | ||
|
||
func (b *BlobStorage) objectAttributes(ctx context.Context, objectKey, source string) (client.ObjectAttributes, 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.
nit: IIUC using a different source
is just going to create a different metric? Does it make sense to separate calls to this function into separate metrics?
My suggestion would be to just drop the source
parameter, if I'm understanding the code correctly
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.
Yes, the idea is to allow disambiguation between GetAttributes
and ObjectExists
where it is possible to do it. Loki isn't using GetAttributes
so this shouldn't cause any problems but if you're using Loki's API for doing something, having this separation will help your application separating what is leading the object storage requests.
What this PR does / why we need it:
ObjectExistsWithSize
API intoGetAttributes
to conform with the existing Thanos API.ObjectSize
false, nil
toObjectExists
when the only error seen is aNotFound
. If someone callsObjectExists
it should returnfalse, nil
to aNotExist
error, instead offalse, err
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
production/helm/loki/Chart.yaml
and updateproduction/helm/loki/CHANGELOG.md
andproduction/helm/loki/README.md
. Example PRdeprecated-config.yaml
anddeleted-config.yaml
files respectively in thetools/deprecated-config-checker
directory. Example PR