Skip to content

feat(helm): add recreate upgrade (rollback) strategy - #7431

Closed
dastrobu wants to merge 1 commit into
helm:mainfrom
dastrobu:7082-helm-upgrade-recreate
Closed

dastrobu wants to merge 1 commit into
helm:mainfrom
dastrobu:7082-helm-upgrade-recreate

Conversation

@dastrobu

@dastrobu dastrobu commented Jan 18, 2020 •

Copy link
Copy Markdown
Contributor

An additional optional flag --recreate can be passed on upgrade (or rollback) of a release.
In combination with the --force flag the following strategies are employed when updating a resource (which can be directly compared to kubectl):

helm                        kubectl          action                         on 'invalid' or 'conflict'
--------------------------------------------------------------------------------------------------------------

upgrade                     apply            PATCH                          fail

upgrade --force             replace          PUT                            fail

upgrade --recreate          apply --force    PATCH                          DELETE -> GET (poll) -> POST

upgrade --recreate --force  replace --force  DELETE -> GET (poll) ->  POST  fail

The 'on error' column should be interpreted as follows. The server responds with 'invalid' e.g. if a certain resource contains an immutable field, which cannot be patched or updated by a PUT. In theses cases it can be helpful to delete the resource and recreate it. Examples for theses cases are:

  • roleRef in RoleBinding
  • spec.clusterIP in Service
  • parameters in StorageClass

Closes #7082.

@helm-bot helm-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 18, 2020
@bacongobbler

Copy link
Copy Markdown
Member

Hi @dastrobu. Would you mind looking into the failing tests?

Comment thread pkg/kube/client.go Resolved
@dastrobu

dastrobu commented Jan 23, 2020 •

Copy link
Copy Markdown
Contributor Author

@bacongobbler thanks for looking at the code already. As mentioned in the pr description this pr is still WIP. I just wanted to implement the feature quickly to play around with it and get feedback if we should implement it like that.
I interpret your comments that you would encourage implementing the feature that way.

I am aware of the API change, see my TODO comment in interface.go#L48. However I don't have a good idea to do it non-breaking. Hints would be welcome.
Ideas:

  1. add parameters recreate bool, timeout time.Duration -> breaking
  2. add new interface method UpdateRecreeate -> breaking (and ugly)
  3. add a new extended Interface kube.InterfaceV2, add field to Configuration and use KubeClientV2 if present and KubeClient otherwise. I guess this would be non breaking but also not very nice and complicated.

Any better ideas?

from: Semantic Versioning

Go libraries inside of pkg/ SHOULD remain backward compatible

I would appreciate some advice how to do it non breaking without cluttering the code base too much or if we should consider it an acceptable API change.

If we would change method signatures from

Update(original, target ResourceList, force bool) (*Result, error)

to

Update(original, target ResourceList, options UpdateOptions) (*Result, error)

it would have been easier to add more optional flags. But this is also not possible without a breaking API change.

Of course I will look into failing tests and add new tests where appropriate (maybe next week).

@hickeyma hickeyma added wip work in progress feature v3.x Issues and Pull Requests related to the major version v3 labels Jan 23, 2020
@bacongobbler

Copy link
Copy Markdown
Member

Hints would be welcome.

You could try adding RecreateOnUpdate and UpdateTimeout to the Client object, updating those values during prepareUpgrade and prepareRollback.

Comment thread pkg/kube/client.go Resolved
@bacongobbler

Copy link
Copy Markdown
Member

this is looking really close, by the way. Nice work!

@dastrobu
dastrobu force-pushed the 7082-helm-upgrade-recreate branch from 5e3bf42 to 3aa36ba Compare January 29, 2020 18:14
@bacongobbler bacongobbler added this to the 3.1.0 milestone Jan 29, 2020
@bacongobbler

Copy link
Copy Markdown
Member

hey @dastrobu. We discussed during today's dev call that we are looking at a Helm 3.1 RC in the next week or so. Are you going to have the time to work on this in that timeframe?

@dastrobu

Copy link
Copy Markdown
Contributor Author

@bacongobbler I plan to work on this today, so PR should be ready for review on Monday hopefully. Would be great to see this feature in 3.1.

@dastrobu

Copy link
Copy Markdown
Contributor Author

Hints would be welcome.

You could try adding RecreateOnUpdate and UpdateTimeout to the Client object, updating those values during prepareUpgrade and prepareRollback.

The problem I see is that prepareUpgrade and prepareRollback do not have access to the Client object, these methods can only use the kube.Interface which is passed around in the action.Configuration object. So I am not sure how this could work
I will try to create an extended kube.InterfaceV2 defining the extended API in a portable way. I wouldn't call this solution beautiful, but it will be non breaking and will also provide access to the new flag via the go API.
Any better ideas are still welcome.

@dastrobu
dastrobu force-pushed the 7082-helm-upgrade-recreate branch from 3aa36ba to 508a864 Compare January 31, 2020 18:15
@helm-bot helm-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 31, 2020
@dastrobu
dastrobu force-pushed the 7082-helm-upgrade-recreate branch from 508a864 to fdd7369 Compare January 31, 2020 18:30
@dastrobu dastrobu changed the title WIP: feat(helm): add recreate update (rollback) strategy feat(helm): add recreate upgrade (rollback) strategy Jan 31, 2020
@dastrobu
dastrobu requested a review from bacongobbler January 31, 2020 18:49
@bacongobbler

Copy link
Copy Markdown
Member

Thanks for looking into possible solutions. This is going to take a bit more time to review, so we'll have to reschedule this for 3.2.

@knrt10

knrt10 commented Feb 3, 2021

Copy link
Copy Markdown
Contributor

We have rebased this PR solving merge conflicts on top of v3.5.1. You can find the reference here https://github.com/kinvolk/helm/tree/knrt10/v3.5.1-rollback

@jkroepke

Copy link
Copy Markdown

@knrt10 do you want to create a new PR here?

@invidian

Copy link
Copy Markdown

@knrt10 do you want to create a new PR here?

@jkroepke created #9836.

@jkroepke

Copy link
Copy Markdown

@invidian thats nice. One question here. The helm maintainer spents already a lot of time to review the code here. Did you do just a rebase of the existing code or does your new pull request already gain some benefits from the existing reviews here?

@invidian

Copy link
Copy Markdown

@invidian thats nice. One question here. The helm maintainer spents already a lot of time to review the code here. Did you do just a rebase of the existing code or does your new pull request already gain some benefits from the existing reviews here?

I only did a rebase. I don't see any review comments here and I don't really have time to go trough all the 70+ comments here and addressing them. I only published the rebase efforts, so they don't get lost. Perhaps resetting number of comments on the PR will also help to get it merged? Or maybe maintainers would have time to look and push some fixes to it if it's not significant?

@bacongobbler

Copy link
Copy Markdown
Member

I don't see any review comments here

Four of the current Helm core maintainers have reviewed the code and weighed in here.

and I don't really have time to go trough all the 70+ comments here and addressing them.

Part of the review process is to discuss a feature's motivation, explain its technical details, and describe how to test, maintain, and teach this new feature. It is important to read and consider those comments in future work. If you're going to ask maintainers to review your code, please be respectful of other's time and make sure to read prior feedback - core maintainers and community members alike.

I'm going to close your PR because a rebase is not going to fix the issues laid out in earlier discussions.

@jkroepke

jkroepke commented Jun 30, 2021 •

Copy link
Copy Markdown

@bacongobbler

I would recommend to close this pull request, too. This is PR is staled for almost one year.

In addition, I would strongly appreciate it that one of the maintainer take this topic and provide a complain solution. This is PR is a dead end.

@bacongobbler

Copy link
Copy Markdown
Member

@dastrobu has expressed continued interest in this matter. For that reason I'm happy to keep it open for further discussion. Should he decide he's no longer interested in pursuing this feature, he can close this PR.

@jkroepke

Copy link
Copy Markdown

@bacongobbler I see, but there is no open review anymore, I saw that @mattfarina (#7431 (comment)) and you (#7431 (comment)) do a general non in-code review and @dastrobu wrote answers to the review points here.

By going through the comments, I would agree. I do not see any opened/unanswered reviews here or I could not see them, too. Maybe I do not understand them.

A summary the opened key point would help some motivated people, too.

@dastrobu

Copy link
Copy Markdown
Contributor Author

I am still motivated to work on a feature, solving #7082. As @jkroepke pointed out, code review is not the issue with this PR. There are conceptual concerns (#7431 (comment)), which is why I proposed an alternative approach in #9174. Unfortunately, I did not receive much feedback on this alternative yet, which is why I paused working on this as long as there is no clear path, to get one of the proposals merged.

@joejulian

Copy link
Copy Markdown
Contributor

Are you still interested, @dastrobu, another year later? I think I agree that an annotation seems more "correct" (for some definition of correct). Perhaps the very idea of what should be an annotation and what should be a flag should be decided in a hip.

@joejulian

Copy link
Copy Markdown
Contributor

Closing this as abandoned.

@joejulian joejulian closed this Aug 1, 2023
dastrobu added a commit to dastrobu/helm that referenced this pull request Dec 14, 2023
Add annotation handling of new annotation helm.sh/update-policy with values recreate-on-conflict and recreate-on-invalid values to better deal with the following cases.
The server responds with 'invalid' e.g. if a certain resource contains an immutable field, which cannot be patched or updated by a PUT. In theses cases it can be helpful to delete the resource and recreate it. Examples for theses cases are:

 * roleRef in RoleBinding
 * spec.clusterIP in Service
 * parameters in StorageClass

If a chart developer has made sure that recreating a resource is safe, the annotation can be added to a resource template. Alternatively a user may add the annotation manually to an existing resource to allow Helm to recreate a certain resource.

Adding the new annotation in general by default or changing the default behaviour of Helm is not a good idea, since deletion and recreation of certain resources can lead to an unwanted or undefined state as described in detail in helm#7431 (comment):

"[...] selectively deleting/re-creating volume-backed resources (Secrets, Services, ConfigMaps, PVCs) without touching the Deployment. If a Persistent Volume Claim is deleted and re-created, there is a risk that an application (Deployment) consuming that Persistent Volume Claim will not receive the new volume's mount point. The same can be said for Secrets, Configmaps, Services, and other resources which are deployed and relied upon by another resource. Environment variables populated in a Deployment from a Service won't be updated until the Pods are destroyed."

Closes helm#7082.

Signed-off-by: Daniel Strobusch <[email protected]>
dastrobu added a commit to dastrobu/helm that referenced this pull request Dec 14, 2023
Add annotation handling of new annotation helm.sh/update-policy with values recreate-on-conflict and recreate-on-invalid values to better deal with the following cases.
The server responds with 'invalid' e.g. if a certain resource contains an immutable field, which cannot be patched or updated by a PUT. In theses cases it can be helpful to delete the resource and recreate it. Examples for theses cases are:

 * roleRef in RoleBinding
 * spec.clusterIP in Service
 * parameters in StorageClass

If a chart developer has made sure that recreating a resource is safe, the annotation can be added to a resource template. Alternatively a user may add the annotation manually to an existing resource to allow Helm to recreate a certain resource.

Adding the new annotation in general by default or changing the default behaviour of Helm is not a good idea, since deletion and recreation of certain resources can lead to an unwanted or undefined state as described in detail in helm#7431 (comment):

"[...] selectively deleting/re-creating volume-backed resources (Secrets, Services, ConfigMaps, PVCs) without touching the Deployment. If a Persistent Volume Claim is deleted and re-created, there is a risk that an application (Deployment) consuming that Persistent Volume Claim will not receive the new volume's mount point. The same can be said for Secrets, Configmaps, Services, and other resources which are deployed and relied upon by another resource. Environment variables populated in a Deployment from a Service won't be updated until the Pods are destroyed."

Closes helm#7082.

Signed-off-by: Daniel Strobusch <[email protected]>
dastrobu added a commit to dastrobu/helm that referenced this pull request Dec 14, 2023
Add annotation handling of new annotation helm.sh/update-policy with values recreate-on-conflict and recreate-on-invalid values to better deal with the following cases.
The server responds with 'invalid' e.g. if a certain resource contains an immutable field, which cannot be patched or updated by a PUT. In theses cases it can be helpful to delete the resource and recreate it. Examples for theses cases are:

 * roleRef in RoleBinding
 * spec.clusterIP in Service
 * parameters in StorageClass

If a chart developer has made sure that recreating a resource is safe, the annotation can be added to a resource template. Alternatively a user may add the annotation manually to an existing resource to allow Helm to recreate a certain resource.

Adding the new annotation in general by default or changing the default behaviour of Helm is not a good idea, since deletion and recreation of certain resources can lead to an unwanted or undefined state as described in detail in helm#7431 (comment):

"[...] selectively deleting/re-creating volume-backed resources (Secrets, Services, ConfigMaps, PVCs) without touching the Deployment. If a Persistent Volume Claim is deleted and re-created, there is a risk that an application (Deployment) consuming that Persistent Volume Claim will not receive the new volume's mount point. The same can be said for Secrets, Configmaps, Services, and other resources which are deployed and relied upon by another resource. Environment variables populated in a Deployment from a Service won't be updated until the Pods are destroyed."

Closes helm#7082.

Signed-off-by: Daniel Strobusch <[email protected]>
dastrobu added a commit to dastrobu/helm that referenced this pull request Dec 14, 2023
Add annotation handling of new annotation helm.sh/update-policy with values recreate-on-conflict and recreate-on-invalid values to better deal with the following cases.
The server responds with 'invalid' e.g. if a certain resource contains an immutable field, which cannot be patched or updated by a PUT. In theses cases it can be helpful to delete the resource and recreate it. Examples for theses cases are:

 * roleRef in RoleBinding
 * spec.clusterIP in Service
 * parameters in StorageClass

If a chart developer has made sure that recreating a resource is safe, the annotation can be added to a resource template. Alternatively a user may add the annotation manually to an existing resource to allow Helm to recreate a certain resource.

Adding the new annotation in general by default or changing the default behaviour of Helm is not a good idea, since deletion and recreation of certain resources can lead to an unwanted or undefined state as described in detail in helm#7431 (comment):

"[...] selectively deleting/re-creating volume-backed resources (Secrets, Services, ConfigMaps, PVCs) without touching the Deployment. If a Persistent Volume Claim is deleted and re-created, there is a risk that an application (Deployment) consuming that Persistent Volume Claim will not receive the new volume's mount point. The same can be said for Secrets, Configmaps, Services, and other resources which are deployed and relied upon by another resource. Environment variables populated in a Deployment from a Service won't be updated until the Pods are destroyed."

Closes helm#7082.

Signed-off-by: Daniel Strobusch <[email protected]>
dastrobu added a commit to dastrobu/helm that referenced this pull request Dec 14, 2023
Add annotation handling of new annotation helm.sh/update-policy with values recreate-on-conflict and recreate-on-invalid values to better deal with the following cases.
The server responds with 'invalid' e.g. if a certain resource contains an immutable field, which cannot be patched or updated by a PUT. In theses cases it can be helpful to delete the resource and recreate it. Examples for theses cases are:

 * roleRef in RoleBinding
 * spec.clusterIP in Service
 * parameters in StorageClass

If a chart developer has made sure that recreating a resource is safe, the annotation can be added to a resource template. Alternatively a user may add the annotation manually to an existing resource to allow Helm to recreate a certain resource.

Adding the new annotation in general by default or changing the default behaviour of Helm is not a good idea, since deletion and recreation of certain resources can lead to an unwanted or undefined state as described in detail in helm#7431 (comment):

"[...] selectively deleting/re-creating volume-backed resources (Secrets, Services, ConfigMaps, PVCs) without touching the Deployment. If a Persistent Volume Claim is deleted and re-created, there is a risk that an application (Deployment) consuming that Persistent Volume Claim will not receive the new volume's mount point. The same can be said for Secrets, Configmaps, Services, and other resources which are deployed and relied upon by another resource. Environment variables populated in a Deployment from a Service won't be updated until the Pods are destroyed."

Closes helm#7082.

Signed-off-by: Daniel Strobusch <[email protected]>
dastrobu added a commit to dastrobu/helm that referenced this pull request Dec 17, 2023
Add annotation handling of new annotation helm.sh/update-policy with values recreate-on-conflict and recreate-on-invalid values to better deal with the following cases.
The server responds with 'invalid' e.g. if a certain resource contains an immutable field, which cannot be patched or updated by a PUT. In theses cases it can be helpful to delete the resource and recreate it. Examples for theses cases are:

 * roleRef in RoleBinding
 * spec.clusterIP in Service
 * parameters in StorageClass

If a chart developer has made sure that recreating a resource is safe, the annotation can be added to a resource template. Alternatively a user may add the annotation manually to an existing resource to allow Helm to recreate a certain resource.

Adding the new annotation in general by default or changing the default behaviour of Helm is not a good idea, since deletion and recreation of certain resources can lead to an unwanted or undefined state as described in detail in helm#7431 (comment):

"[...] selectively deleting/re-creating volume-backed resources (Secrets, Services, ConfigMaps, PVCs) without touching the Deployment. If a Persistent Volume Claim is deleted and re-created, there is a risk that an application (Deployment) consuming that Persistent Volume Claim will not receive the new volume's mount point. The same can be said for Secrets, Configmaps, Services, and other resources which are deployed and relied upon by another resource. Environment variables populated in a Deployment from a Service won't be updated until the Pods are destroyed."

Closes helm#7082.

Signed-off-by: Daniel Strobusch <[email protected]>
dastrobu added a commit to dastrobu/helm that referenced this pull request Dec 17, 2023
Add annotation handling of new annotation helm.sh/update-policy with values recreate-on-conflict and recreate-on-invalid values to better deal with the following cases.
The server responds with 'invalid' e.g. if a certain resource contains an immutable field, which cannot be patched or updated by a PUT. In theses cases it can be helpful to delete the resource and recreate it. Examples for theses cases are:

 * roleRef in RoleBinding
 * spec.clusterIP in Service
 * parameters in StorageClass

If a chart developer has made sure that recreating a resource is safe, the annotation can be added to a resource template. Alternatively a user may add the annotation manually to an existing resource to allow Helm to recreate a certain resource.

Adding the new annotation in general by default or changing the default behaviour of Helm is not a good idea, since deletion and recreation of certain resources can lead to an unwanted or undefined state as described in detail in helm#7431 (comment):

"[...] selectively deleting/re-creating volume-backed resources (Secrets, Services, ConfigMaps, PVCs) without touching the Deployment. If a Persistent Volume Claim is deleted and re-created, there is a risk that an application (Deployment) consuming that Persistent Volume Claim will not receive the new volume's mount point. The same can be said for Secrets, Configmaps, Services, and other resources which are deployed and relied upon by another resource. Environment variables populated in a Deployment from a Service won't be updated until the Pods are destroyed."

Closes helm#7082.

Signed-off-by: Daniel Strobusch <[email protected]>
dastrobu added a commit to dastrobu/helm that referenced this pull request Dec 17, 2023
Add annotation handling of new annotation helm.sh/update-policy with values recreate-on-conflict and recreate-on-invalid values to better deal with the following cases.
The server responds with 'invalid' e.g. if a certain resource contains an immutable field, which cannot be patched or updated by a PUT. In theses cases it can be helpful to delete the resource and recreate it. Examples for theses cases are:

 * roleRef in RoleBinding
 * spec.clusterIP in Service
 * parameters in StorageClass

If a chart developer has made sure that recreating a resource is safe, the annotation can be added to a resource template. Alternatively a user may add the annotation manually to an existing resource to allow Helm to recreate a certain resource.

Adding the new annotation in general by default or changing the default behaviour of Helm is not a good idea, since deletion and recreation of certain resources can lead to an unwanted or undefined state as described in detail in helm#7431 (comment):

"[...] selectively deleting/re-creating volume-backed resources (Secrets, Services, ConfigMaps, PVCs) without touching the Deployment. If a Persistent Volume Claim is deleted and re-created, there is a risk that an application (Deployment) consuming that Persistent Volume Claim will not receive the new volume's mount point. The same can be said for Secrets, Configmaps, Services, and other resources which are deployed and relied upon by another resource. Environment variables populated in a Deployment from a Service won't be updated until the Pods are destroyed."

Closes helm#7082.

Signed-off-by: Daniel Strobusch <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. v3.x Issues and Pull Requests related to the major version v3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

proposal: handle immutable resources on update