Skip to content

Fixes #3338: Implement "atomic" upgrade/install - #5143

Merged
thomastaylor312 merged 6 commits into
helm:masterfrom
cleac:master
Jan 28, 2019
Merged

thomastaylor312 merged 6 commits into
helm:masterfrom
cleac:master

Conversation

@cleac

@cleac cleac commented Jan 9, 2019 •

Copy link
Copy Markdown

What this PR does / why we need it:

Add possibility to put "--safe" argument to install and upgrade command that restores the state of cluster in case of failed install/upgrade attempt.

This resolves the problem of non-atomic upgrade process in helm and removes need to write scripts to handle failed deployments. Also, closes #3338.

Special notes for your reviewer:

This is a proposal for such functionality, so I haven't any documentation and unit tests yet. However I've tested this functionality by hands on living cluster.

Also, I am not a professional Go developer, so if there are ways to improve implementation with fluent Go cunstructions, I would be glad for suggestions.

If applicable:

  • this PR contains documentation
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

@helm-bot helm-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 9, 2019
@thomastaylor312
thomastaylor312 self-requested a review January 18, 2019 22:25
@thomastaylor312 thomastaylor312 added in progress bug Categorizes issue or PR as related to a bug. labels Jan 18, 2019
@thomastaylor312

Copy link
Copy Markdown
Contributor

@cleac Thanks for this PR! I hadn't followed along with the original issue and it is a holiday in the US this coming Monday, so give me a bit to go through this and review. I'll review the code right now and then do more testing with it to make sure it is good to go

Comment thread cmd/helm/install.go Resolved

@thomastaylor312 thomastaylor312 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is looking great. Just a few small fixes and if you could add some simple unit tests for the flag in install_test.go and upgrade_test.go while you are there, that would be great!

I'll be doing some manual validation of this as well in the meantime

Comment thread cmd/helm/install.go Resolved
@thomastaylor312 thomastaylor312 added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. feature and removed bug Categorizes issue or PR as related to a bug. labels Jan 18, 2019
@thomastaylor312

Copy link
Copy Markdown
Contributor

Just a note that I relabeled this a feature to match the issue it is closing. Although the current behavior is clunky/painful, it isn't a bug. So this will be a nice add!

Comment thread cmd/helm/install.go Resolved
@thomastaylor312

Copy link
Copy Markdown
Contributor

Ok, so it is looking like things are working after I tested. My only suggestion would be to print something when the purge is successful on install. Right now I get the friendly message of Rollback was a success! Happy Helming! for a failed upgrade rollback, but I don't get a message for a successful purge.

@thomastaylor312 thomastaylor312 added this to the 2.13.0 milestone Jan 18, 2019
@helm-bot helm-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 23, 2019
@helm-bot helm-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 23, 2019
@helm-bot helm-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 23, 2019
@thomastaylor312

Copy link
Copy Markdown
Contributor

@cleac Looks like the build failed due to docs

cleac added 4 commits January 27, 2019 11:39
Add possibility to put "--safe" argument to install and
upgrade command that restores the state of cluster in
case of failed install/upgrade attempt

Signed-off-by: Alexander Nesterenko <[email protected]>
Signed-off-by: Alexander Nesterenko <[email protected]>
…nding, what it does

Signed-off-by: Alexander Nesterenko <[email protected]>
Signed-off-by: Alexander Nesterenko <[email protected]>

@thomastaylor312 thomastaylor312 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One small change on the documentation for each command and then this should be good to go! Thanks for all the work on it

Comment thread cmd/helm/install.go Resolved
@helm-bot helm-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 28, 2019

@technosophos technosophos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Code LGTM.

@thomastaylor312

Copy link
Copy Markdown
Contributor

Thanks for all the work on this @cleac!

@thomastaylor312
thomastaylor312 merged commit 240e539 into helm:master Jan 28, 2019
@cleac

cleac commented Jan 29, 2019 •

Copy link
Copy Markdown
Author

@thomastaylor312 @technosophos thanks much for review ^_^

@jkroepke

jkroepke commented Feb 1, 2019 •

Copy link
Copy Markdown

/cc @nce

@thomastaylor312 @technosophos does this fix #1193 ?

@thomastaylor312

thomastaylor312 commented Feb 1, 2019 •

Copy link
Copy Markdown
Contributor

@jkroepke I think it helps work around it based on what I am reading, but I don't know if it fully solves the issue

Comment thread cmd/helm/upgrade.go
timeout: u.timeout,
wait: u.wait,
description: "",
revision: releaseHistory.Releases[0].Version,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How will this work if helm upgrade --install --atomic is used and there is no previous release? Doesn't it need to purge like the install command in that case?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Erm... If the --install is passed and there are no previous versions, it invokes helm install ... command, while all the parameters are passed to it. You are looking at pretty different place 😄

@jkroepke

jkroepke commented Feb 4, 2019

Copy link
Copy Markdown

/cc @nce

@thomastaylor312 @technosophos One more. Is this a workaround for #4871, too? It would be pretty awesome since it breaks the CI, too.

@distorhead

Copy link
Copy Markdown
Contributor

@jkroepke No it does not solve the case, which is described in the PR #4871.

4871 is about a bug inside of the install/upgrade operation internals. This operation can break own invariant, which is a bad thing.

This pr 5143 is about automatically running rollback operation (which is the same install/upgrade operation, but reversed), but it does not change the internals of this operation.

Read details and code in the #4871.

@bacongobbler bacongobbler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

While the majority of the PR looks good here, I think there are several questionable design flaws that need to be addressed, namely how the --atomic flag chooses the release it needs to roll back to as well as the inclusion of enabling the --wait flag. I'll follow up with a PR.

See #5377 for some early feedback on this issue as well.

Comment thread cmd/helm/install.go Resolved
Comment thread cmd/helm/upgrade.go Resolved
Comment thread cmd/helm/upgrade.go
timeout: u.timeout,
wait: u.wait,
description: "",
revision: releaseHistory.Releases[0].Version,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why are we relying on the latest release version here? The latest released version is not always the version that was last deployed and in a healthy state. We need to roll back to the last good state we were in prior to the upgrade.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For those landing here, @bacongobbler is working to address this case in this PR

@bacongobbler

bacongobbler commented Mar 4, 2019 •

Copy link
Copy Markdown
Member

After taking a good look at the code, I can see why it doesn't address @distorhead's issues as well: it's not a truly atomic rollback; it just calls helm rollback and hopes for the best. Resources that are created as part of the failed release are not cleaned up, which #4871 attempts to fix up.

@distorhead if you want to roll your changes into the --atomic flag, that would be a good change to have in this feature. If you don't want to take on that work, I'd be happy to move it forward. Just let me know. :)

eraac pushed a commit to eraac/helm that referenced this pull request Mar 21, 2019
Fixes helm#3338: Implement "atomic" upgrade/install
Signed-off-by: Kevin Labesse <[email protected]>
@distorhead

Copy link
Copy Markdown
Contributor

After taking a good look at the code, I can see why it doesn't address @distorhead's issues as well: it's not a truly atomic rollback; it just calls helm rollback and hopes for the best. Resources that are created as part of the failed release are not cleaned up, which #4871 attempts to fix up.

@distorhead if you want to roll your changes into the --atomic flag, that would be a good change to have in this feature. If you don't want to take on that work, I'd be happy to move it forward. Just let me know. :)

@bacongobbler Sorry, missed your comment. Created PR #5579 to add cleanup-on-fail option support when running rollback operation due to upgrade failure when using atomic.

@thomastaylor312 thomastaylor312 added Needs v3 backport Label PRs for v4/main, which are still applicable to v3 so need a separate backport PR and removed in progress labels Jul 8, 2019
@thomastaylor312 thomastaylor312 added v3 port complete For completed v2->v3 ports and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 8, 2019
@gjenkins8 gjenkins8 removed the Needs v3 backport Label PRs for v4/main, which are still applicable to v3 so need a separate backport PR label Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature size/M Denotes a PR that changes 30-99 lines, ignoring generated files. v3 port complete For completed v2->v3 ports

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Helm doesn't cleanup on unsuccessful deployments

10 participants