-
Notifications
You must be signed in to change notification settings - Fork 136
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
Wait for merge status to resolve. #265
Conversation
Since GitLab 12.8, the merge_status of a merge request updates asynchonously. This commit waits for merge_status to become 'can_be_merged', just after checking that the pipeline runs green. See here for more details: https://docs.gitlab.com/ee/api/merge_requests.html#get-single-mr
Yeah, this looks good to me, but er, indeed it's missing an actual caller for this function. |
Line 80 of |
Yes, of course; I have no idea how I didn't see that. I blame the heatwave here. Sorry. |
I haven't seen any failures at all on freedesktop.org since we deployed this. So it looks good and it seems like it works too. Thanks a lot @snim2! |
Could we get this merged 😬 ? We have the underlying problem, and it's pretty annoying. |
We could really use this change too please :) |
Since |
Hey, thanks for your contribution! This looks good at first glance. I'll check if we need to change something for the batching accordingly and get this merged. |
Hey, after look into this and the gitlab doc, I have a question. Is this PR just to fix the case that one MR will actually cannot be merged, but the marge didn't know. So we after we resolve the status, we can fail more explicitly? |
So, we need this because the API endpoint that tells Does that help? |
Okay, thanks. If that's the case, |
After checking https://gitlab.com/gitlab-org/gitlab/-/merge_requests/21026/diffs and https://gitlab.com/gitlab-org/gitlab/-/merge_requests/31890/diffs those 2 MRs that introduce the async When you call API to merge, it will always sync check the Also we didn't meet this issue on Smarkets. Though I don't know why you guys have this issue if those bad cases were not just legit merge conflicts. Thoughts? |
I'm not sure why you haven't seen those errors, that's interesting, and I can't think of a particular reason why we did have them, but maybe someone else on this PR has some ideas? |
Sorry I can't add more actionable information but I can corroborate what @snim2 and others in this PR have experienced. At times |
Okay, I can merge this PR as it will fix your issue. But I think the issue is not caused by the async I'll add some comments in the code to be aware in the future. |
It's definitely caused by the async |
@fooishbar But I think the status cached in redis won't affect the actual merge action. It's just stale in the GET API response which is ok. When you try to merge it, gitlab will always check the mergeability synchronously. You can check my previous comments.
This can be true, even the root cause is not the async |
At least from my observation, it did affect the merge action as well as the observed status. The other subtlety is that even if the merge action did bypass Redis and recalculate the status, job/pipeline completion is not synchronous wrt updating the MR status. A pipeline-status job gets queued in Sidekiq which will only later update the MR status, so even if the merge POST did always invalidate the status and recalculate, it is not mergeable until the Sidekiq job retires, so you need to poll anyway. |
Closes #263
This is a first go at a linear back-off to check whether an MR has
merge_status
set tocan_be_merged
(see the discussion on the #263).This probably needs quite a bit more work, in particular I'm aware that I haven't made any changes to
marge/batch_job.py
or added any tests. I was a bit confused by how mocking is implemented, so I'd be grateful for some pointers if you'd like more tests.