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

Introduce an option to overwrite GitHub contexts of pending presubmit ProwJobs when merging batches in tide #135

Merged
merged 6 commits into from
Sep 30, 2024

Conversation

oliver-goetz
Copy link
Contributor

@oliver-goetz oliver-goetz commented Apr 25, 2024

Fixes #209

With this PR tide overwrites the context of pending ProwJobs when it merges a batch of PRs. It uses the status of the succeeded batch job with the same context. The feature is disabled by default and can be enabled via overwrite-pending-contexts context option.
When the context is overwritten, tide deletes any test report comments created by crier (ref) of this PR which might still exist. They contain previous failed runs of the contexts which have just been overwritten. It would be confusing to keep them in the PR.
Before, Github branch-protection rules could prevent merging PRs from a batch (see kubernetes/test-infra#32097 for details).

When a PR is merged the ProwJobs which are still running are canceled automatically by trigger plugin of hook, so there is no need to cancel them in tide.

This PR replaces kubernetes/test-infra#32416.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 25, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @oliver-goetz!

It looks like this is your first PR to kubernetes-sigs/prow 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/prow has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @oliver-goetz. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 25, 2024
Copy link

netlify bot commented Apr 25, 2024

Deploy Preview for k8s-prow ready!

Name Link
🔨 Latest commit bf0e9aa
🔍 Latest deploy log https://app.netlify.com/sites/k8s-prow/deploys/66f59c0d86af250008b84d5c
😎 Deploy Preview https://deploy-preview-135--k8s-prow.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 25, 2024

for _, pj := range pjs {
for _, pull := range pj.Spec.Refs.Pulls {
if pr, found := prNums[pull.Number]; found && pr.HeadRefOID == pull.SHA {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to also consider the ref for the target branch? Could we have some race like:

  1. trigger presubmits on target ref A
  2. trigger batch for same
  3. push to PR
  4. trigger presubmits for target ref B
  5. presubmits publish pending statuses
  6. batch finishes
  7. this code runs, overwriting presubmits
  8. batch would have been cancelled by the new push

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I see.
I restructured this function that it checks if all PRs of a batch job are valid before collecting it. The logic is similar to how batch PRs are accumulated (ref).
Now, the context of a batch job which contain invalid or missing PRs are not collected anymore.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 2, 2024
@jihoon-seo
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 7, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 15, 2024
@oliver-goetz
Copy link
Contributor Author

@stevekuznetsov could you check this PR again please? 🙂

@oliver-goetz
Copy link
Contributor Author

Now, any leftover test report comments will be deleted too, when the context was overwritten.
This avoids situations like shown in the screenshot where the context is marked as SUCCESS but there is still a comment with a link to a failed test.

Screenshot 2024-06-05 at 17 25 55

It might happen when the batch jobs succeed and there is a failing test in the trigger PR, which is restarted fast enough while the batch job is still running.

@oliver-goetz
Copy link
Contributor Author

friendly reminder, please review this PR 😄

@petr-muller
Copy link
Contributor

/cc

@oliver-goetz
Copy link
Contributor Author

ping 🔔
Could someone review this PR please.

@@ -265,6 +270,17 @@ func (gi *GitHubProvider) mergePRs(sp subpool, prs []CodeReviewCommon, dontUpdat
continue
}

// Overwrite context of pending presubmit prow jobs if enabled
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we ever plan to overwrite the context to something other than success? I would consider either make that explicit in the function name, or make it take in the override status?

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 don't think it makes sense to set the status to anything else than success in the tide context. I updated the name of the function.

prowJobsForPRs[pull.Number].successfulBatchJob[pj.Spec.Context] = pj
}
case prowapi.PresubmitJob:
if jobState != pendingState {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we also want to override failed presubmit runs if the batch job finishes with success?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If a presubmit run of a batch member fails, the batch jobs continue to run. However, the batch is removed from the merge pool, so it would never reach this point here.

@krzyzacy
Copy link
Contributor

@stevekuznetsov @petr-muller wanna skim through again as you are the original reviewers?

@petr-muller
Copy link
Contributor

Let's not block on me, I'll skim post-merge (eventually :D ) Thanks @krzyzacy for reviewing this one, it's great to see you back. And thanks @oliver-goetz for your submission and patience 🙇

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 30, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: oliver-goetz, petr-muller

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 30, 2024
@k8s-ci-robot k8s-ci-robot merged commit 8302b5c into kubernetes-sigs:main Sep 30, 2024
11 checks passed
@oliver-goetz oliver-goetz deleted the enh/tide-batch-merge branch October 1, 2024 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Branch protection rules prevent first PR of a merge-batch from being merged
6 participants