kubernetes-sigs / prow

Prow is a Kubernetes based CI/CD system developed to serve the Kubernetes community. This repository contains Prow source code and Hugo sources for Prow documentation site.
https://docs.prow.k8s.io
Apache License 2.0
112 stars 90 forks source link

Fix panic in gerrit client ChangeExist #222

Closed nathanperkins closed 1 month ago

nathanperkins commented 1 month ago

The old code assumed that when err != nil, the resp is still populated, which isn't true in all branches. This causes a panic which can occur every 6 hours

We add a resp != nil check to protect against this panic.

Also, add a unit test and fake gerritChange with errors which would catch this panic. I confirmed that removing the change triggers the test failure.

k8s-ci-robot commented 1 month ago

Welcome @nathanperkins!

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. :smiley:

k8s-ci-robot commented 1 month ago

Hi @nathanperkins. 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](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
netlify[bot] commented 1 month ago

Deploy Preview for k8s-prow ready!

Name Link
Latest commit 2cf41185284119b22631ca78a4e30e6a629f1670
Latest deploy log https://app.netlify.com/sites/k8s-prow/deploys/66b3fb4d325de70008f4ff31
Deploy Preview https://deploy-preview-222--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 commented 1 month ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cjwagner, nathanperkins

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: - ~~[pkg/gerrit/OWNERS](https://github.com/kubernetes-sigs/prow/blob/main/pkg/gerrit/OWNERS)~~ [cjwagner] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment