-
Notifications
You must be signed in to change notification settings - Fork 363
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
Task: Add IfAbsent to LinkPhysicalAddress #7480
Task: Add IfAbsent to LinkPhysicalAddress #7480
Conversation
Need 1 reviewer, thanks! |
♻️ PR Preview 4289191 has been successfully destroyed since this PR has been closed. 🤖 By surge-preview |
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.
Thanks!
api/swagger.yml
Outdated
if_absent: | ||
type: boolean | ||
default: false |
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 use the HTTP header If-Match elsewhere in this API, and I believe that we should continue to do the same and use the HTTP header If-None-Match here. The only legal value will be *
, of course.
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.
Done + removed deprecation for post object
@@ -1711,7 +1711,10 @@ func (g *Graveler) Set(ctx context.Context, repository *RepositoryRecord, branch | |||
|
|||
// verify the key not found | |||
_, err := g.Get(ctx, repository, Ref(branchID), key) | |||
if err == nil || !errors.Is(err, ErrNotFound) { | |||
if err == nil { // Entry found, return precondition failed |
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 changes behaviour of regular putObject, doesn't it?
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 was a bug
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.
Please confirm with one of the authors of the original feature -- we've historically had this feature with this behaviour and the opposite successful behaviour. So I worry someone might depend on it.
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.
Thanks!
- This is a minor version bump of course, so let's also document it in the CHANGELOG as upcoming, or otherwise mark.
@@ -1711,7 +1711,10 @@ func (g *Graveler) Set(ctx context.Context, repository *RepositoryRecord, branch | |||
|
|||
// verify the key not found | |||
_, err := g.Get(ctx, repository, Ref(branchID), key) | |||
if err == nil || !errors.Is(err, ErrNotFound) { | |||
if err == nil { // Entry found, return precondition failed |
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.
Please confirm with one of the authors of the original feature -- we've historically had this feature with this behaviour and the opposite successful behaviour. So I worry someone might depend on it.
api/swagger.yml
Outdated
required: false | ||
schema: | ||
type: string | ||
pattern: '^\*$' # Currently, only "*" is supported |
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.
Please avoid this: server limitations should be enforced on the server not on the client. Suppose I update my server to a version that also supports ETag. This is the only thing that prevents me from using an old client version.
I know the previous implementation also did this. I now believe that it was also wrong. But back then we didn't try hard enough to keep old clients compatible where possible.
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.
Will remove pattern and add validation on server
Co-authored-by: Ariel Shaqed (Scolnicov) <[email protected]>
@@ -4164,6 +4173,10 @@ paths: | |||
application/json: | |||
schema: | |||
$ref: "#/components/schemas/StagingMetadata" | |||
|
|||
parameters: | |||
- $ref: "#/components/parameters/IfNonMatch" |
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.
- $ref: "#/components/parameters/IfNonMatch" | |
- $ref: "#/components/parameters/IfNoneMatch" |
@@ -69,6 +69,15 @@ components: | |||
description: delimiter used to group common prefixes by | |||
schema: | |||
type: string | |||
|
|||
IfNonMatch: |
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.
IfNonMatch: | |
IfNoneMatch: |
@@ -1,5 +1,10 @@ | |||
# Changelog | |||
|
|||
# Unreleased | |||
|
|||
- Task: Add If-Non-Match to LinkPhysicalAddress (#7480) |
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.
- Task: Add If-Non-Match to LinkPhysicalAddress (#7480) | |
- Task: Add If-None-Match to LinkPhysicalAddress (#7480) |
# Unreleased | ||
|
||
- Task: Add If-Non-Match to LinkPhysicalAddress (#7480) | ||
Removes deprecation of If-Non-Match from upload object |
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.
Removes deprecation of If-Non-Match from upload object | |
Removes deprecation of If-None-Match from upload object |
|
||
parameters: | ||
- $ref: "#/components/parameters/IfNonMatch" | ||
|
||
responses: |
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 you need to add 412 response for that?
@@ -4397,24 +4410,14 @@ paths: | |||
format: binary | |||
|
|||
parameters: | |||
- $ref: "#/components/parameters/IfNonMatch" |
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.
Making sure this isn't a breaking change for clients
@@ -3007,6 +3022,68 @@ func TestController_LinkPhysicalAddressHandler(t *testing.T) { | |||
} | |||
}) | |||
|
|||
t.Run("link physical address twice if non match", func(t *testing.T) { |
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 test!
Closes #7479
Change Description
THIS PR REINTRODUCES SET IF-NON-MATCH to the upload object API
Background
Add IfAbsent to support LinkPhysicalAddress failure if path already exists
Testing Details
Added unit test
Breaking Change?
No