cluster-api icon indicating copy to clipboard operation
cluster-api copied to clipboard

🐛 Verify that there is a release for the tag

Open Fedosin opened this issue 1 year ago • 3 comments

What this PR does / why we need it: Now we attempt to retrieve provider release data first via the go-proxy client. In case of failure, we would resort to direct polling from GitHub. However, the go-proxy client only lists existing git tags and does not return detailed information about github releases. This behavior leads to a failure in clustercl if there's no release for the latest tag.

To address this, we try to get a release for the tag first, and return the highest version with a corresponding release.

For the sake of performace we do only 3 attempts do find a release, and return an error after that.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged): Fixes #7889

/area clusterctl

Fedosin avatar Feb 29 '24 14:02 Fedosin

Thanks for trying to tackle this! The issue with this PR is it brings us back to a situation where we could be rate-limited by github. Using goproxy was introduced to avoid that rate-limiting. We definitely faced this issue in the CI as clusterctl makes multiple calls to github.

What do you think of instead trying the approach in #7889 (comment) i.e. falling back to an older version if the latest doesn't exist?

Ack to what @killianmuldoon wrote.

Note: setting GOPROXY=off allows to turn off the goproxy functionality.

chrischdi avatar Feb 29 '24 16:02 chrischdi

I did it this way: we get a list of versions, sort them and then iterate and try to get metadata.yaml file for each. If the file exists, we return the latest released version. I think it is a good approach, because we download this file anyway, and during the first attempt it will be cached.

Fedosin avatar Feb 29 '24 20:02 Fedosin

LGTM label has been added.

Git tree hash: d1184bc7d717b6daeeb5c62dc8e27b376d59eb27

k8s-ci-robot avatar Mar 26 '24 12:03 k8s-ci-robot

/assign @fabriziopandini @chrischdi Could be interesting to get in. To see if it works for the upcoming minor release

sbueringer avatar Apr 09 '24 16:04 sbueringer

Overall seems okay to me, but not very familiar with this area of our code

sbueringer avatar Apr 09 '24 17:04 sbueringer

👍 I also like the change, last nit.

I'm not a big fan of having that env variable deep down in the code, but passing it through everywhere also seems odd.

chrischdi avatar Apr 10 '24 06:04 chrischdi

Also please document the new env var in docs/book/src/clusterctl/overview.md

chrischdi avatar Apr 10 '24 06:04 chrischdi

👍 I also like the change, last nit.

I'm not a big fan of having that env variable deep down in the code, but passing it through everywhere also seems odd.

Agree. Do we really need this configurable? What use case are we trying to cover with this?

I would prefer not adding another config env var if not strictly necessary

sbueringer avatar Apr 10 '24 07:04 sbueringer

That config variable was requested by CAPA team and @richardcase. Recently they had a situation with 4 broken tags, and potentially there could be more. So, to handle such issues we always want to provide a workaround that allows users to set a bigger number of tags to search.

Fedosin avatar Apr 11 '24 12:04 Fedosin

That config variable was requested by CAPA team and @richardcase. Recently they had a situation with 4 broken tags, and potentially there could be more. So, to handle such issues we always want to provide a workaround that allows users to set a bigger number of tags to search.

In general I would like to try to keep the number of configuration options to a minimum. And to be honest environment variables are one of the worst ways to configure a CLI :).

Can we pick a value which is high enough for the cases that occur in 99% of the cases. Maybe 10? (@richardcase ?)

(If we pick 10, I assume the 10 is only fully used when the last 10 existing patch tags for a minor are broken, as soon as there was a successful release it's not relevant anymore, correct?)

sbueringer avatar Apr 11 '24 12:04 sbueringer

Imo 5 tags is more than enough. Normally there is only one broken tag, which is not yet released. In some cases there could be 2. Okay, I'll remove this configuration for now. We can always add it if necessary.

Fedosin avatar Apr 11 '24 12:04 Fedosin

Thank you very much for your work on this!

/lgtm

/assign @chrischdi @fabriziopandini

sbueringer avatar Apr 11 '24 13:04 sbueringer

/cherry-pick release-1.7

sbueringer avatar Apr 11 '24 13:04 sbueringer

LGTM label has been added.

Git tree hash: 3f130245e191bd8927e988d4e2bd62bbbaca1440

k8s-ci-robot avatar Apr 11 '24 13:04 k8s-ci-robot

@sbueringer: once the present PR merges, I will cherry-pick it on top of release-1.7 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.7

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.

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrischdi

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 avatar Apr 11 '24 15:04 k8s-ci-robot

@sbueringer: new pull request created: #10423

In response to this:

/cherry-pick release-1.7

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.

/cherry-pick release-1.6

sbueringer avatar Apr 12 '24 05:04 sbueringer

@sbueringer: #10220 failed to apply on top of branch "release-1.6":

Applying: fix: verify that there is a release for the tag
Using index info to reconstruct a base tree...
M	cmd/clusterctl/client/repository/repository_github_test.go
Falling back to patching base and 3-way merge...
Auto-merging cmd/clusterctl/client/repository/repository_github_test.go
CONFLICT (content): Merge conflict in cmd/clusterctl/client/repository/repository_github_test.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 fix: verify that there is a release for the tag
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-1.6

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.