Support helm release upgrade on helm chart name change - #1447
Conversation
| // opt-in from v1.5.2 | ||
| DefaultToRetryOnFailure: false, | ||
| // UninstallOnChartNameChange | ||
| // opt-in from v1.5.4 |
There was a problem hiding this comment.
The chance of this going into a patch release is unlikely, this should thus indicate 1.6.0.
| targetReleaseNamespace = "release namespace" | ||
| targetReleaseName = "release name" | ||
| targetChartName = "chart name" | ||
| TargetChartName = "chart name" |
There was a problem hiding this comment.
This list of constants was always meant to be a descriptive reason (factored out to a const for code readability), not an identifier. Additionally, only exposing one of them creates a weak contract. I would prefer a solution where:
- All identifiers are public
- Identifiers do not contain spaces
|
Some additional thoughts:
|
|
How about having this setting on resource level rather than a global feature flag? |
Hi @artem-nefedov Are you suggesting some on the CRD? e.g. maybe adding something to the 'Uninstall' element of 'HelmRelease'? |
|
Hi @hiddeco I dont think Helm itself supports changing the helm release name, namespace or storage namespace and, as you state yourself, this might require an uninstall anyway. The proposed scope of chart name changes only I believe is consistent with what Helm supports. I'd be concerned about the complexity of implementing this for other changes particularly if there isnt anybody looking for it. Having said that, I am happy to work on it if you feel its the way to go, but I would need your advice on how it should be implemented. In relation to the default |
Sorry for the delayed reply. Yes, I meant something like this, only rather than 'Uninstall', I think the better place is 'Upgrade'. For example: spec:
upgrade:
chartNameChangePolicy: InPlaceUpdate # or "Reinstall" (default) |
|
Hi @hiddeco |
|
I would be okay with: spec:
upgrade:
onChartNameChange: InPlaceUpdate # or "Reinstall" (default)(or |
I think we have a tendency to use |
|
That would also work for me. In any case, I am fine with allowing this to be defined at HelmRelease object level. |
14b2719 to
cc70c6e
Compare
| Reinstall: Reinstall the Helm release, uninstalling the existing Helm release. | ||
|
|
||
| InPlaceUpdate: Update the Helm release in place. | ||
| type: string |
There was a problem hiding this comment.
should have enum with allowed values
| // Update the Helm release in place. | ||
| InPlaceUpdate ChartNameChangeStrategy = "InPlaceUpdate" | ||
| // Reinstall the Helm release, uninstalling the existing Helm release | ||
| Reinstall ChartNameChangeStrategy = "Reinstall" |
There was a problem hiding this comment.
consider prefixing names with a type
|
Hi @artem-nefedov @hiddeco |
| // previous release target first. If we did not do this, the installation would | ||
| // fail due to resources already existing. | ||
| if reason, changed := action.ReleaseTargetChanged(obj, loadedChart.Name()); changed { | ||
| if reason, changed := action.ReleaseTargetChanged(obj, loadedChart.Name()); changed && (reason != action.TargetChartName || obj.Spec.Upgrade.ChartNameChangeStrategy == v2.ChartNameChangeStrategyReinstall) { |
There was a problem hiding this comment.
This condition explicitly checks for "Reinstall", but I don't understand where default value is supposed to be set as "Reinstall".
Is there a test to confirm the default behavior?
There was a problem hiding this comment.
My bad, the setting of the default value got lost when I switched from feature gate to resource level setting. Added back in now and test to validate
| TargetStorageNamespace = "storageNamespace" | ||
| TargetReleaseNamespace = "releaseNamespace" | ||
| TargetReleaseName = "releaseName" | ||
| TargetChartName = "chartName" |
There was a problem hiding this comment.
It looks like those are also used as a part of human-readable log message, so I don't know if it is correct to change the format.
The maintainers can decide.
I don't see any more obvious problems with the PR.
There was a problem hiding this comment.
Well pointed, I think we can just make the symbols public so the calling code can use them, but since they are used in a log I think we need to keep the literals as they are.
22a93a4 to
255f7c2
Compare
|
Hi @hiddeco, @matheuscscp |
There was a problem hiding this comment.
@MichaelMorrisEst Please add a few tests here: https://github.com/fluxcd/helm-controller/blob/main/.github/workflows/e2e.yaml
| // Update the Helm release in place. | ||
| ChartNameChangeStrategyInPlaceUpdate ChartNameChangeStrategy = "InPlaceUpdate" | ||
| // Reinstall the Helm release, uninstalling the existing Helm release | ||
| ChartNameChangeStrategyReinstall ChartNameChangeStrategy = "Reinstall" |
There was a problem hiding this comment.
The Go standard for comments on symbols is starting the comment with the symbol name and add full stop (.) at the end.
| TargetStorageNamespace = "storageNamespace" | ||
| TargetReleaseNamespace = "releaseNamespace" | ||
| TargetReleaseName = "releaseName" | ||
| TargetChartName = "chartName" |
There was a problem hiding this comment.
Well pointed, I think we can just make the symbols public so the calling code can use them, but since they are used in a log I think we need to keep the literals as they are.
Hi @matheuscscp In order to add tests there I would need a renamed version of podinfo chart somewhere. Do you think it would be ok to add something to the pofinfo repo (or create a new repo?), or do you see some other approach? |
@MichaelMorrisEst You can do it like the CRD tests at the end, they run from a chart managed in this repo. |
399bdd9 to
ccc8caf
Compare
|
Hi @matheuscscp do you have any further comments? |
|
Thanks @matheuscscp for taking the time to review. Do you think it will be possible to get this merged in time to be included in the upcoming Flux 2.9 release? |
|
Depends on another maintainer stamping the PR |
|
Hi @stefanprodan @hiddeco if you could spare some time to review it would be much appreciated. It would be great to get this in Flux 2.9 if possible. |
|
Please rebase with upstream main branch and force push. |
This re-introduces support that was lost going from 2.1.x -> 2.2.x but controls the behaviour through a feature gate so either the previous or current behaviour (default) can be achieved Signed-off-by: MichaelMorris <michael.morris@est.tech>
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Signed-off-by: MichaelMorris <michael.morris@est.tech>
The newly added tests to e2e depend on local helm charts being installed, which is done in "Bootstrap Tests Using Local Helm Chart". However a condition exists on that step and on the already existing test cases that depend on it because that step cannot be run on a PR from a fork as the fork branch wont exist in the base repo. Therefore the same condition needs to be placed on the newly added tests that also depend on that step. Signed-off-by: MichaelMorris <michael.morris@est.tech>
Signed-off-by: MichaelMorris <michael.morris@est.tech>
0155184 to
95f303b
Compare
stefanprodan
left a comment
There was a problem hiding this comment.
LGTM
Thanks @MichaelMorrisEst 🏅
Summary
Closes #870
Proposes to add a new property in the 'upgrade' element of the HelmRelease CRD.
The new property shall have two allowed values: "InPlaceUpdate" and "Reinstall"
When the value "Reinstall" is specified, or when no value is specified, the current behaviour of uninstalling a Helm Release when the Helm chart name is changed shall remain unchanged. This results in a new Helm Release install.
When the value "InPlaceUpdate" is specified, the Helm Release will not be uninstalled when the Helm chart name is changed. This results in a Helm upgrade being performed. This was the behaviour before Flux 2.2.0
This re-introduces support that was lost going from Flux 2.1.x -> 2.2.x but controls the behaviour through the HelmRelease custom resource so either the previous (<2.2.x) behaviour or current behaviour can be achieved
Changes
chartNameChangeStrategyproperty to the 'Upgrade' struct in helmrelease_types.go and ensure the default "Reinstall" is used if no value is specifiedaction.targetChartNameto enable it to be referenced in the HelmRelease controllerOriginal proposal
The original proposal when the PR was submitted was to introduce a feature gate to control the behaviour. Following discussions in the comments below the implementation changed to use the custom resource instead. The above description has been updated to reflect the new implementation