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

Task: Add IfAbsent to LinkPhysicalAddress #7480

Merged
merged 5 commits into from
Feb 20, 2024

Conversation

N-o-Z
Copy link
Member

@N-o-Z N-o-Z commented Feb 20, 2024

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

@N-o-Z N-o-Z added area/API Improvements or additions to the API include-changelog PR description should be included in next release changelog labels Feb 20, 2024
@N-o-Z N-o-Z self-assigned this Feb 20, 2024
@N-o-Z
Copy link
Member Author

N-o-Z commented Feb 20, 2024

Need 1 reviewer, thanks!

Copy link

github-actions bot commented Feb 20, 2024

♻️ PR Preview 4289191 has been successfully destroyed since this PR has been closed.

🤖 By surge-preview

Copy link

E2E Test Results - DynamoDB Local - Local Block Adapter

10 passed

Copy link
Contributor

@arielshaqed arielshaqed left a 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
Comment on lines 1302 to 1304
if_absent:
type: boolean
default: false
Copy link
Contributor

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.

Copy link
Member Author

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
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was a bug

Copy link
Contributor

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.

https://hyrumslaw.com FTL.

@N-o-Z N-o-Z requested a review from arielshaqed February 20, 2024 12:01
Copy link
Contributor

@arielshaqed arielshaqed left a 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
Copy link
Contributor

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.

https://hyrumslaw.com FTL.

api/swagger.yml Outdated Show resolved Hide resolved
api/swagger.yml Outdated
required: false
schema:
type: string
pattern: '^\*$' # Currently, only "*" is supported
Copy link
Contributor

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.

Copy link
Member Author

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

N-o-Z and others added 3 commits February 20, 2024 15:58
@@ -4164,6 +4173,10 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/StagingMetadata"

parameters:
- $ref: "#/components/parameters/IfNonMatch"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- $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:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
IfNonMatch:
IfNoneMatch:

@N-o-Z N-o-Z merged commit d81a950 into master Feb 20, 2024
36 of 37 checks passed
@N-o-Z N-o-Z deleted the task/add-ifabsent-to-link-physical-address-7479 branch February 20, 2024 16:31
@@ -1,5 +1,10 @@
# Changelog

# Unreleased

- Task: Add If-Non-Match to LinkPhysicalAddress (#7480)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- 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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Removes deprecation of If-Non-Match from upload object
Removes deprecation of If-None-Match from upload object


parameters:
- $ref: "#/components/parameters/IfNonMatch"

responses:
Copy link
Contributor

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"
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Great test!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/API Improvements or additions to the API include-changelog PR description should be included in next release changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add IfAbsent support to LinkPhysicalAddress API
3 participants