Skip to content

Commit

Permalink
Fix for picking the right helm chart version during release cut (#8196)
Browse files Browse the repository at this point in the history
# Description

To find the correct helm chart version in our code, we search for the
release major value but wildcard the patch value. We need to update the
versioning logic during the Helm install to handle a few different
cases:
1. If there is a pre-release version (i.e. -rc1, -rc2, etc), we want to
find a helm chart version that is an exact match
2. If there is a full release version, we want to find a helm chart
version that matches the release value but wildcards the patch value (in
case we have a patch release)
3. For dev builds, the release version will always be `0.42.42-dev` so
this value should be hardcoded as the version.


## Type of change

<!--

Please select **one** of the following options that describes your
change and delete the others. Clearly identifying the type of change you
are making will help us review your PR faster, and is used in authoring
release notes.

If you are making a bug fix or functionality change to Radius and do not
have an associated issue link please create one now.

-->

- This pull request fixes a bug in Radius and has an approved issue
(issue link required).
- This pull request adds or changes features of Radius and has an
approved issue (issue link required).
- This pull request is a minor refactor, code cleanup, test improvement,
or other maintenance task and doesn't change the functionality of Radius
(issue link optional).

<!--

Please update the following to link the associated issue. This is
required for some kinds of changes (see above).

-->

Fixes: #8195

## Contributor checklist
Please verify that the PR meets the following requirements, where
applicable:

- [ ] An overview of proposed schema changes is included in a linked
GitHub issue.
- [ ] A design document PR is created in the [design-notes
repository](https://github.com/radius-project/design-notes/), if new
APIs are being introduced.
- [ ] If applicable, design document has been reviewed and approved by
Radius maintainers/approvers.
- [ ] A PR for the [samples
repository](https://github.com/radius-project/samples) is created, if
existing samples are affected by the changes in this PR.
- [ ] A PR for the [documentation
repository](https://github.com/radius-project/docs) is created, if the
changes in this PR affect the documentation or any user facing updates
are made.
- [ ] A PR for the [recipes
repository](https://github.com/radius-project/recipes) is created, if
existing recipes are affected by the changes in this PR.

---------

Signed-off-by: Vishwanath Hiremath <[email protected]>
  • Loading branch information
vishwahiremat authored Jan 7, 2025
1 parent 763db89 commit 5832dea
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ require (
cloud.google.com/go/iam v1.1.8 // indirect
cloud.google.com/go/storage v1.42.0 // indirect
dario.cat/mergo v1.0.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/Microsoft/hcsshim v0.12.4 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ
github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs=
Expand Down
9 changes: 8 additions & 1 deletion pkg/cli/helm/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"helm.sh/helm/v3/pkg/storage/driver"
"k8s.io/cli-runtime/pkg/genericclioptions"

"github.com/Masterminds/semver"
"github.com/radius-project/radius/pkg/version"
)

Expand All @@ -51,7 +52,13 @@ func NewDefaultClusterOptions() ClusterOptions {
// If this is an edge build, we'll use the latest available.
chartVersion := version.ChartVersion()
if !version.IsEdgeChannel() {
chartVersion = fmt.Sprintf("~%s", version.ChartVersion())
// When the chart version is the final release, we should use the ~ operator to ensure we fetch the latest patch version.
// For the pre release, we should use the exact version.
ver, _ := semver.NewVersion(chartVersion)
preRelease := ver.Prerelease()
if preRelease == "" {
chartVersion = fmt.Sprintf("~%s", version.ChartVersion())
}
}

return ClusterOptions{
Expand Down

0 comments on commit 5832dea

Please sign in to comment.