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

Revert proposed change state to open on merge failure #5564

Merged
merged 2 commits into from
Jan 28, 2025

Conversation

ogenstad
Copy link
Contributor

@ogenstad ogenstad commented Jan 24, 2025

If we merge a proposed change and there's an error we previously didn't revert the state back to "open" from "merging", this PR corrects this behaviour. Previously we did revert this if a user tried to merge a proposed change with data conflicts without providing a resolution to all conflicts.

Fixes #5563

Note: Today we could reach this state where the proposed change was stuck in the "merging" state if there was a data conflict and the user tried to resolve the conflict using the old way and do it within the Checks tab. I'm not certain how to create a scenario where we end up here? I.e if we want to create a test that hits this path. Does anyone have any ideas about that?

@github-actions github-actions bot added the group/backend Issue related to the backend (API Server, Git Agent) label Jan 24, 2025
Copy link

codspeed-hq bot commented Jan 24, 2025

CodSpeed Performance Report

Merging #5564 will not alter performance

Comparing pog-proposed-change-merge-state-IFC-1157 (cd9d598) with stable (7e98238)

Summary

✅ 10 untouched benchmarks

@ogenstad ogenstad marked this pull request as ready for review January 24, 2025 14:14
@ogenstad ogenstad requested a review from a team January 24, 2025 14:14
@ajtmccarty
Copy link
Contributor

I'm not certain how to create a scenario where we end up here? I.e if we want to create a test that hits this path. Does anyone have any ideas about that?

Could you have a test that creates a proposed change for a branch with a data conflict and try to merge it?

@ogenstad
Copy link
Contributor Author

Could you have a test that creates a proposed change for a branch with a data conflict and try to merge it?

The thing is that we already have a test like that here: https://github.com/opsmill/infrahub/blob/infrahub-v1.1.4/backend/tests/integration/proposed_change/test_proposed_change_conflict.py#L149-L152 The problem in this case was that the current logic also checks for resolutions on the check object itself and we're going to remove that so I don't see the point of adding a test for when the resolution is solved that way. So we'd need something else to cause the failure. Do you have any other thoughts as to what could cause a failure? Otherwise I'll merge this as is for now.

@ajtmccarty
Copy link
Contributor

Do you have any other thoughts as to what could cause a failure? Otherwise I'll merge this as is for now.

Hmm. Not really. Maybe you could patch merge_branch? We don't do a lot of patching in our unit tests, but it might be appropriate here b/c we are trying to enter a failure state that should normally be prevented

If we merge a proposed change and there's an error we previously didn't
revert the state back to "open" from "merging", this PR corrects this
behaviour. Previously we did revert this if a user tried to merge a
proposed change with data conflicts without providing a resolution to
all conflicts.

Fixes #5563
@ogenstad ogenstad force-pushed the pog-proposed-change-merge-state-IFC-1157 branch from cf15dfe to 2c6627c Compare January 27, 2025 14:10
@ogenstad
Copy link
Contributor Author

Hmm. Not really. Maybe you could patch merge_branch? We don't do a lot of patching in our unit tests, but it might be appropriate here b/c we are trying to enter a failure state that should normally be prevented

I added a test please take another look.

Copy link
Contributor

@ajtmccarty ajtmccarty left a comment

Choose a reason for hiding this comment

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

LGTM

branch1 = await client.branch.create(branch_name="failing_branch")
steve = await Node.init(schema=TestKind.PERSON, db=db, branch=branch1.name)
await steve.new(db=db, name="Steve", height=178)
await steve.save(db=db)
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure if you still need this fixture

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's mostly just following the current convention where we have some test setup that is happening within a fixture. It's following what we are doing in the other tests. But I can move this code do the actual test instead if that's what you mean as we typically don't reuse these fixtures?

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant that I don't think this fixture is actually used in the test_merge_failure test b/c that test seems to use the conflict_free branch and not the failing_branch branch created here. But I could be missing something

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah ok I see the confusion. I managed to change the name of the proposed change to "failing_branch", where I should really have named it "failing_branch". I think it's probably cleaner if I swap that part out so the branches doesn't interact with each other.

@ogenstad ogenstad force-pushed the pog-proposed-change-merge-state-IFC-1157 branch from 2c6627c to cd9d598 Compare January 27, 2025 16:02
@ogenstad ogenstad merged commit 5986df6 into stable Jan 28, 2025
36 checks passed
@ogenstad ogenstad deleted the pog-proposed-change-merge-state-IFC-1157 branch January 28, 2025 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
group/backend Issue related to the backend (API Server, Git Agent)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: failed merge can leave Proposed Change in a bad state
3 participants