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

🐛 Verify that there is a release for the tag #10220

Merged
merged 1 commit into from
Apr 11, 2024

Conversation

Fedosin
Copy link
Contributor

@Fedosin Fedosin commented Feb 29, 2024

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 performance we do only 5 attempts to 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

@k8s-ci-robot k8s-ci-robot added area/clusterctl Issues or PRs related to clusterctl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 29, 2024
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 29, 2024
Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

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

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?

@chrischdi
Copy link
Member

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.

@Fedosin Fedosin changed the title 🐛 Don't use go-proxy client to fetch info about releases 🐛 Verify that there is a release for the tag Feb 29, 2024
@Fedosin
Copy link
Contributor Author

Fedosin commented Feb 29, 2024

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 Fedosin force-pushed the fix_latest_release branch 2 times, most recently from 77039e0 to d05920c Compare March 7, 2024 22:56
Copy link
Member

@Danil-Grigorev Danil-Grigorev left a comment

Choose a reason for hiding this comment

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

One nit, otherwise looks solid to me.


return latestPrereleaseTag, nil
// Limit the number of searchable versions by 3.
versionCandidates = versionCandidates[:min(3, len(versionCandidates))]
Copy link
Member

Choose a reason for hiding this comment

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

I think this should act as a fallback scenario. Latest version is in a partial state, fallback to previous latest.

Copy link
Contributor

Choose a reason for hiding this comment

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

@richardcase might have some more context in relation to #7889 (comment) which could impact the desired size here.

In general though I'm fine with the number being larger - providers should be able to test separately to figure out if their releases are accessible.

Copy link
Member

Choose a reason for hiding this comment

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

With the recent failed CAPA releases we went from v2.3.1 to v2.3.5....so we had 3 failed releases.

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 bumped the number to 5. I expect it is enough for everyone :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also for extreme cases now it's possible to customize the value with CAPI_CLUSTERCTL_MAX_VERSION_CANDIDATES env variable

Copy link
Member

@Danil-Grigorev Danil-Grigorev left a comment

Choose a reason for hiding this comment

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

/lgtm

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

LGTM label has been added.

Git tree hash: d1184bc7d717b6daeeb5c62dc8e27b376d59eb27

@sbueringer
Copy link
Member

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

@sbueringer
Copy link
Member

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

@chrischdi
Copy link
Member

👍 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
Copy link
Member

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

@sbueringer
Copy link
Member

sbueringer commented Apr 10, 2024

👍 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

@Fedosin
Copy link
Contributor Author

Fedosin commented Apr 11, 2024

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.

@sbueringer
Copy link
Member

sbueringer commented Apr 11, 2024

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?)

@Fedosin
Copy link
Contributor Author

Fedosin commented Apr 11, 2024

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.

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 performance we do only 5 attempts to find a release,
and return an error after that.
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 11, 2024
@sbueringer
Copy link
Member

Thank you very much for your work on this!

/lgtm

/assign @chrischdi @fabriziopandini

@sbueringer
Copy link
Member

/cherry-pick release-1.7

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

LGTM label has been added.

Git tree hash: 3f130245e191bd8927e988d4e2bd62bbbaca1440

@k8s-infra-cherrypick-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.

Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

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

/approve

Thanks for contributing this!

@k8s-ci-robot
Copy link
Contributor

[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 k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 11, 2024
@k8s-ci-robot k8s-ci-robot merged commit 0cb503c into kubernetes-sigs:main Apr 11, 2024
20 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.8 milestone Apr 11, 2024
@k8s-infra-cherrypick-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.

@sbueringer
Copy link
Member

/cherry-pick release-1.6

@k8s-infra-cherrypick-robot

@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.

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. area/clusterctl Issues or PRs related to clusterctl 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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

clusterctl tries to download latest tag when no release exists.
9 participants