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

Add "allow-empty" flag to Merge #7798

Merged
merged 7 commits into from
May 29, 2024
Merged

Conversation

itaigilo
Copy link
Contributor

Closes #7797.

Change Description

Add allow_no_changes flag to branch merge API, to allow merge merging two branches with the same content.

Background

Currently, when trying to merge two branches with the same content, an "no changes" error is thrown.

New Feature

Add the flag to the API,
And implement support for it in lakectl and in the python-wrapper (in addition to the auto-generated clients).

This change should be fully backwards-compatible.

@itaigilo itaigilo added the include-changelog PR description should be included in next release changelog label May 23, 2024
@itaigilo itaigilo self-assigned this May 23, 2024
@itaigilo itaigilo marked this pull request as draft May 23, 2024 06:40
Copy link

E2E Test Results - DynamoDB Local - Local Block Adapter

13 passed

@N-o-Z
Copy link
Member

N-o-Z commented May 23, 2024

@itaigilo You've added the parameter in swagger but did not add the logic in lakeFS.
What will be the default behavior? Is it going to be different from the current behavior? I thought the original bug was that we were able to perform a merge when there were not changes.
I feel like this PR is too small, I'd like to see the usage of the parameter before review

@itaigilo
Copy link
Contributor Author

itaigilo commented May 23, 2024

@N-o-Z this is only a tiny draft, meant to outline the suggested change in the API (before implementing it).
It's basically instead of a spec (according to @arielshaqed 's suggestion) -
The implementation will follow soon.

@N-o-Z
Copy link
Member

N-o-Z commented May 23, 2024

@N-o-Z as noted in Slack, this is only a tiny draft, meant to outline the suggested change in the API (before implementing it). It's basically instead of a spec (according to @arielshaqed 's suggestion) - The implementation will follow soon.

Thanks, IMHO I think the in this instance it's redundant.
The changes themselves in the server are minor, and providing the entire context even as draft is a relatively small effort and provides much more value

@itaigilo itaigilo changed the title Add allow_no_changes flag to swagger.yml [WIP] Add allow_no_changes flag to swagger.yml May 23, 2024
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!

It's great that you sent this PR out for a round of comments. Please also post a link to it on lakeFS Slack #dev channel: The People Must Know, and they may have opinions...

Only required change is to document what "force" will do once we already have this flag.

api/swagger.yml Outdated
@@ -645,6 +645,10 @@ components:
force:
type: boolean
default: false
allow_no_changes:
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. I guess we will need to document the flag above, too! In particular, what happens if I set force but not allow_no_changes? In order to keep the minor version guarantee, I think that the merge has to fail. This will not be clear to users not aware of the history we are now creating.

    So I insist on documenting what force does (sorry, it should have been done before), and I think that it should be documented as not allowing an empty merge.

  2. I believe that this flag should be called allow_empty. It is already called allow_empty for commit and for revert. I don't want to learn another term, and I don't like boolean flags whose names are negative.

Copy link

github-actions bot commented May 27, 2024

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

🤖 By surge-preview

Message: apiutil.Ptr("Merge branch2 to branch1"),
})
testutil.MustDo(t, "perform merge with no changes", err)
if mergeResp.JSON400 == nil || !strings.HasSuffix(mergeResp.JSON400.Message, graveler.ErrNoChanges.Error()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a better way to check this error message?

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately not for a test at the controller level, this is more of a component test than a unit test. You could unit-test the exact error in TestGravelerMerge (in graveler_v2_test.go, "v2" for Historical Reasons). But I'm not sure it's worth the effort.

@itaigilo itaigilo marked this pull request as ready for review May 28, 2024 08:10
@itaigilo itaigilo requested a review from arielshaqed May 28, 2024 08:10
@itaigilo itaigilo changed the title [WIP] Add allow_no_changes flag to swagger.yml Add allow_no_changes flag to swagger.yml May 28, 2024
@itaigilo itaigilo changed the title Add allow_no_changes flag to swagger.yml Add "allow-empty" flag to Merge May 28, 2024
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 clear and tested code.

Neat that the majority of changed lines are just a cleanup.

Message: apiutil.Ptr("Merge branch2 to branch1"),
})
testutil.MustDo(t, "perform merge with no changes", err)
if mergeResp.JSON400 == nil || !strings.HasSuffix(mergeResp.JSON400.Message, graveler.ErrNoChanges.Error()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately not for a test at the controller level, this is more of a component test than a unit test. You could unit-test the exact error in TestGravelerMerge (in graveler_v2_test.go, "v2" for Historical Reasons). But I'm not sure it's worth the effort.

N-o-Z
N-o-Z previously requested changes May 28, 2024
Copy link
Member

@N-o-Z N-o-Z left a comment

Choose a reason for hiding this comment

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

Blocking for the following questions:

  1. What is the current behavior when trying to merge a branch with no changes?
  2. What will be the default behavior after the change?

@N-o-Z N-o-Z dismissed their stale review May 28, 2024 18:22

cleared in description

@N-o-Z
Copy link
Member

N-o-Z commented May 28, 2024

Blocking for the following questions:

  1. What is the current behavior when trying to merge a branch with no changes?
  2. What will be the default behavior after the change?

Noticed it was answered in the updated description

@itaigilo itaigilo merged commit c0b0d60 into master May 29, 2024
37 checks passed
@itaigilo itaigilo deleted the feature/allow-merge-with-no-changes branch May 29, 2024 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 flag for allowing to merge branches with the same content
3 participants