Skip to content

fix(helm): Avoid corrupting storage via a lock - #7322

Merged
bacongobbler merged 3 commits into
helm:masterfrom
cristiklein:fix/less-corruption-with-concurrent-executions
Jul 13, 2020
Merged

bacongobbler merged 3 commits into
helm:masterfrom
cristiklein:fix/less-corruption-with-concurrent-executions

Conversation

@cristiklein

Copy link
Copy Markdown

If two helm upgrades are executed at the exact same time, then one of
the invocations will fail with "already exists".

If one helm upgrade is executed and a second one is started while the
first is in pending-upgrade, then the second invocation will create a
new release. Effectively, two helm invocations will simultaneously
change the state of Kubernetes resources -- which is scary -- then two
releases will be in deployed state -- which can cause other issues.

This commit fixes the corrupted storage problem, by introducting a poor
person's lock. If the last release is in a pending state, then helm will
abort. If the last release is in a pending state, due to a previously
killed helm, then the user is expected to do helm rollback.

Closes #7274

Signed-off-by: Cristian Klein [email protected]

@helm-bot helm-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jan 1, 2020
@bacongobbler bacongobbler added the v3.x Issues and Pull Requests related to the major version v3 label Jan 8, 2020
cristiklein pushed a commit to cristiklein/helm that referenced this pull request Jan 8, 2020
Helm does not yet properly handle concurrent executions (see helm#7322),
and invoking Helm concurrently on the same release lead to corrupted storage.
Specifically, several Releases may be marked as DEPLOYED. This patch improved handling of such situations, by taking the latest
DEPLOYED Release. Eventually, the storage will clean itself out, after
the corrupted Releases are deleted due to --history-max.

This is a port to Helm v3 of helm#7319.

Signed-off-by: Cristian Klein <[email protected]>
cristiklein added a commit to cristiklein/helm that referenced this pull request Jan 8, 2020
If two `helm upgrade`s are executed at the exact same time, then one of
the invocations will fail with "already exists".

If one `helm upgrade` is executed and a second one is started while the
first is in `pending-upgrade`, then the second invocation will create a
new release. Effectively, two helm invocations will simultaneously
change the state of Kubernetes resources -- which is scary -- then two
releases will be in `deployed` state -- which can cause other issues.

This commit fixes the corrupted storage problem, by introducting a poor
person's lock. If the last release is in a pending state, then helm will
abort. If the last release is in a pending state, due to a previously
killed helm, then the user is expected to do `helm rollback`.

This is a port to Helm v2 of helm#7322.

Signed-off-by: Cristian Klein <[email protected]>
@helm-bot helm-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 8, 2020
cristiklein pushed a commit to cristiklein/helm that referenced this pull request Jan 8, 2020
If two `helm upgrade`s are executed at the exact same time, then one of
the invocations will fail with "already exists".

If one `helm upgrade` is executed and a second one is started while the
first is in `pending-upgrade`, then the second invocation will create a
new release. Effectively, two helm invocations will simultaneously
change the state of Kubernetes resources -- which is scary -- then two
releases will be in `deployed` state -- which can cause other issues.

This commit fixes the corrupted storage problem, by introducting a poor
person's lock. If the last release is in a pending state, then helm will
abort. If the last release is in a pending state, due to a previously
killed helm, then the user is expected to do `helm rollback`.

This is a port to Helm v2 of helm#7322.

Signed-off-by: Cristian Klein <[email protected]>
cristiklein pushed a commit to cristiklein/helm that referenced this pull request Jan 16, 2020
Helm does not yet properly handle concurrent executions (see helm#7322),
and invoking Helm concurrently on the same release lead to corrupted storage.
Specifically, several Releases may be marked as DEPLOYED. This patch improved handling of such situations, by taking the latest
DEPLOYED Release. Eventually, the storage will clean itself out, after
the corrupted Releases are deleted due to --history-max.

This is a port to Helm v3 of helm#7319.

Signed-off-by: Cristian Klein <[email protected]>
mattfarina pushed a commit that referenced this pull request Jan 28, 2020
Helm does not yet properly handle concurrent executions (see #7322),
and invoking Helm concurrently on the same release lead to corrupted storage.
Specifically, several Releases may be marked as DEPLOYED. This patch improved handling of such situations, by taking the latest
DEPLOYED Release. Eventually, the storage will clean itself out, after
the corrupted Releases are deleted due to --history-max.

This is a port to Helm v3 of #7319.

Signed-off-by: Cristian Klein <[email protected]>
(cherry picked from commit 1f0582c)
bamachrn pushed a commit to bamachrn/helm that referenced this pull request Feb 28, 2020
Helm does not yet properly handle concurrent executions (see helm#7322),
and invoking Helm concurrently on the same release lead to corrupted storage.
Specifically, several Releases may be marked as DEPLOYED. This patch improved handling of such situations, by taking the latest
DEPLOYED Release. Eventually, the storage will clean itself out, after
the corrupted Releases are deleted due to --history-max.

This is a port to Helm v3 of helm#7319.

Signed-off-by: Cristian Klein <[email protected]>
bamachrn pushed a commit to bamachrn/helm that referenced this pull request Feb 28, 2020
Helm does not yet properly handle concurrent executions (see helm#7322),
and invoking Helm concurrently on the same release lead to corrupted storage.
Specifically, several Releases may be marked as DEPLOYED. This patch improved handling of such situations, by taking the latest
DEPLOYED Release. Eventually, the storage will clean itself out, after
the corrupted Releases are deleted due to --history-max.

This is a port to Helm v3 of helm#7319.

Signed-off-by: Cristian Klein <[email protected]>
bamachrn pushed a commit to bamachrn/helm that referenced this pull request Feb 28, 2020
Helm does not yet properly handle concurrent executions (see helm#7322),
and invoking Helm concurrently on the same release lead to corrupted storage.
Specifically, several Releases may be marked as DEPLOYED. This patch improved handling of such situations, by taking the latest
DEPLOYED Release. Eventually, the storage will clean itself out, after
the corrupted Releases are deleted due to --history-max.

This is a port to Helm v3 of helm#7319.

Signed-off-by: Cristian Klein <[email protected]>
@bacongobbler
bacongobbler removed their request for review March 3, 2020 00:03
@cristiklein

Copy link
Copy Markdown
Author

I was wondering if this is still of interest to the Helm community.

@bacongobbler

Copy link
Copy Markdown
Member

Sorry for the delay.

My initial concern with this PR was that it may block cases like #4558 from self-resolving, but it looks like a helm rollback works for those cases, and this PR does not block those users from rolling back. I'd be happy to review this.

In the meantime, if you can rebase this PR to fix the merge conflicts that would be lovely.

@liuming-dev

Copy link
Copy Markdown
Contributor

Same issue to me

@bacongobbler bacongobbler added this to the 3.4.0 milestone Jul 7, 2020
@bridgetkromhout

Copy link
Copy Markdown
Member

Thanks, @cristiklein! We've got this merged in for Helm 2. Can you please fix the merge conflict on this Helm 3 version?

@cristiklein

Copy link
Copy Markdown
Author

Thanks @bridgetkromhout ! I'll do it on Monday when I have access to a proper keyboard.

Cristian Klein added 2 commits July 13, 2020 22:54
If two `helm upgrade`s are executed at the exact same time, then one of
the invocations will fail with "already exists".

If one `helm upgrade` is executed and a second one is started while the
first is in `pending-upgrade`, then the second invocation will create a
new release. Effectively, two helm invocations will simultaneously
change the state of Kubernetes resources -- which is scary -- then two
releases will be in `deployed` state -- which can cause other issues.

This commit fixes the corrupted storage problem, by introducting a poor
person's lock. If the last release is in a pending state, then helm will
abort. If the last release is in a pending state, due to a previously
killed helm, then the user is expected to do `helm rollback`.

Closes helm#7274

Signed-off-by: Cristian Klein <[email protected]>
@cristiklein
cristiklein force-pushed the fix/less-corruption-with-concurrent-executions branch from c01b4a8 to 20fb7ba Compare July 13, 2020 20:58
@cristiklein

Copy link
Copy Markdown
Author

@bridgetkromhout I rebased against master and updated a test. Let me know what you think.

@bacongobbler
bacongobbler merged commit 9c0fca9 into helm:master Jul 13, 2020
mattfarina pushed a commit that referenced this pull request Aug 12, 2020
If two `helm upgrade`s are executed at the exact same time, then one of
the invocations will fail with "already exists".

If one `helm upgrade` is executed and a second one is started while the
first is in `pending-upgrade`, then the second invocation will create a
new release. Effectively, two helm invocations will simultaneously
change the state of Kubernetes resources -- which is scary -- then two
releases will be in `deployed` state -- which can cause other issues.

This commit fixes the corrupted storage problem, by introducting a poor
person's lock. If the last release is in a pending state, then helm will
abort. If the last release is in a pending state, due to a previously
killed helm, then the user is expected to do `helm rollback`.

This is a port to Helm v2 of #7322.

Signed-off-by: Cristian Klein <[email protected]>
(cherry picked from commit c32c9a5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 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.

Multiple revisions in DEPLOYED state.

5 participants