[backport v2.10.0] Use semver.coerce()
to get valid kubernetes version
#12533
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an automated request to port PR #12532 by @rak-phillip
Original PR body:
Summary
Fixes #12531
Occurred changes and/or fixed issues
This uses
semver.coerce()
to get a valid semantic version for the original Kubernetes version inCruAks.vue
. The form could fail to render if the Kubernetes version is not a valid semver andsemver.coerce()
will correctly evaluate to a semantic version.Technical notes summary
In the production example, 1.29 is used for the Kubernetes version:
1.29 is a valid Kubernetes version and will default to the latest release1 (1.29.10 at the time of writing).
1.29 is stored in
aksConfig.kubernetesVersion
; this is not a validsemver
, so an unhandled exception is thrown and the page fails to render correctly.It's entirely possible that
current-cluster-controllers-version
is the incorrect value to use for this case, but it was the only one that I found that evaluates to a valid semver with the expected kubernetes version of 1.29.10.Areas or cases that should be tested
Areas which could experience regressions
We are changing the Kubernetes version used for the AKS form. If this annotation doesn't exist for any reason, we will experience the same behavior that's described in the issue. We can consider adding some sort of failure mode if the original Kubernetes isn't present or a valid semver. We can also consider adding some sort of fallback value in the event that it fails.
Checklist
Footnotes
https://kubernetes.io/releases/#release-v1-29 ↩