Skip to content

Commit

Permalink
fix: Do not upgrade helmrelease in pending status
Browse files Browse the repository at this point in the history
  • Loading branch information
okozachenko1203 authored and mnaser committed Jun 30, 2023
1 parent c99d020 commit 81bb06c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions magnum_cluster_api/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@ def __call__(self):
raise


class GetStatusReleaseCommand(ReleaseCommand):
COMMAND = ["status"]

def __call__(self):
try:
return super().__call__(
"--namespace",
self.namespace,
self.release_name,
)
except processutils.ProcessExecutionError as e:
if "release: not found" in e.stderr:
raise exceptions.HelmReleaseNotFound(self.release_name)
else:
raise


class UpgradeReleaseCommand(ReleaseCommand):
COMMAND = ["upgrade"]

Expand All @@ -70,6 +87,16 @@ def __init__(self, namespace, release_name, chart_ref, values={}):
self.values = values

def __call__(self):
try:
status = GetStatusReleaseCommand(
namespace=self.namespace,
release_name=self.release_name,
)()

if "STATUS: pending" in status.stdout:
return "Other task is in progress"
except exceptions.HelmReleaseNotFound:
pass
return super().__call__(
self.chart_ref,
"--install",
Expand Down

0 comments on commit 81bb06c

Please sign in to comment.