release-sdk icon indicating copy to clipboard operation
release-sdk copied to clipboard

update cloneOrOpenRepo to verify matching remote before updating repo.

Open DannyBrito opened this issue 1 year ago • 12 comments

What type of PR is this?

What this PR does / why we need it:

This PR adds verification of matching remote within repo to be updated/clone in function updateRepo If repo URL from the repo to be clone or updated matches any remote in repo will proceed as normal, otherwise will return a new ErrNoMatchingRemote error This will be helpful for better handling, in scenario where the given repoPath exists but this doesn't have a remote pointing to target repo to clone or update. This issue can be seen in https://github.com/kubernetes/release/issues/3444

cc: @jeremyrickard

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?


DannyBrito avatar Feb 07 '24 18:02 DannyBrito

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: DannyBrito Once this PR has been reviewed and has the lgtm label, please assign palnabarun for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 avatar Feb 07 '24 18:02 k8s-ci-robot

Welcome @DannyBrito!

It looks like this is your first PR to kubernetes-sigs/release-sdk 🎉. 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/release-sdk 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 avatar Feb 07 '24 18:02 k8s-ci-robot

Hi @DannyBrito. 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 avatar Feb 07 '24 18:02 k8s-ci-robot

/ok-to-test

jeremyrickard avatar Feb 07 '24 20:02 jeremyrickard

/retest

DannyBrito avatar Feb 07 '24 22:02 DannyBrito

Thank you for the contribution @DannyBrito!

This verification will work fine for repos cloned using our tooling, however, we might run into issues with repos cloned manually or using other tooling (which is supported by the release-notes tool). For example, both of these remote URLs are valid:

[email protected]:kubernetes-sigs/boskos.git # this format is generated by our tooling
[email protected]:kubernetes-sigs/boskos     # there's no .git suffix

repoURL is mostly like to follow the first format (with the .git suffix), but the actual remote URL might use a different format and still be valid. There are also some tricks around HTTPs-based remote URLs, e.g. URLs with and without authentication token in them (see https://stackoverflow.com/a/18936804 for an example).

We could try to do some pattern matching, but that still sounds kind of risky in my opinion. Maybe we should consider if we can fix this directly in the release-notes tool. I talked with @jeremyrickard about this, and we could randomize the repo-path flag, which is not going to fix the issue, but is considered a good enough mitigation. We're also open to ideas if this PR can be modified to accommodate different remote URL formats.

xmudrii avatar Feb 07 '24 22:02 xmudrii

@DannyBrito do you want to go ahead and update release-notes to just randomize the repo-path if not specified? that will provide a good impact while we figure out if we should continue with this path.

jeremyrickard avatar Feb 07 '24 22:02 jeremyrickard

we could randomize the repo-path flag, which is not going to fix the issue, but is considered a good enough mitigation.

With that we break one beneficial use case: Being able to run the tool multiple times (without specifying the repo path) on a single repo while only pulling on the first run. For k/k this was particularly helpful because the repo is huge and pulling takes quite some time.

saschagrunert avatar Feb 08 '24 08:02 saschagrunert

@saschagrunert What about instead of completely randomizing the directory name, we build it based on org and repo, e.g. kubernetes-kubernetes-repo or kubernetes-sigs-promo-tools-repo? The directory name will be slightly longer, but we would keep the benefit that you mentioned.

xmudrii avatar Feb 08 '24 10:02 xmudrii

@xmudrii that would be great and I think it will work pretty well!

saschagrunert avatar Feb 08 '24 11:02 saschagrunert

I think @xmudrii 's suggestion would be great. @DannyBrito do you want to try that out?

jeremyrickard avatar Feb 08 '24 15:02 jeremyrickard

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar May 08 '24 16:05 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle rotten
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Jun 07 '24 16:06 k8s-triage-robot

PR needs rebase.

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-sigs/prow repository.

k8s-ci-robot avatar Jul 05 '24 17:07 k8s-ci-robot