Skip to content

Commit

Permalink
Merge pull request #70 from Karandash8/56-retry-kustomize-helm-chart-…
Browse files Browse the repository at this point in the history
…pull-if-it-failed

Retry kustomize execution
  • Loading branch information
Karandash8 authored Jul 9, 2024
2 parents d958b49 + 5d14bb4 commit 894f498
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions make_argocd_fly/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,22 @@ def __init__(self, app_name: str, env_name: str, app_viewer: ResourceViewer = No

log.debug('Created application {} of type {} for environment {}'.format(app_name, __class__.__name__, env_name))

async def _run_kustomize(self, dir_path: str) -> str:
proc = await asyncio.create_subprocess_shell(
'kustomize build --enable-helm {}'.format(dir_path),
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE)

stdout, stderr = await proc.communicate()

if stderr:
log.error('Kustomize error: {}'.format(stderr))
raise Exception
async def _run_kustomize(self, dir_path: str, retries: int = 3) -> str:
for attempt in range(retries):
proc = await asyncio.create_subprocess_shell(
'kustomize build --enable-helm {}'.format(dir_path),
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE)

stdout, stderr = await proc.communicate()

if stderr:
log.error('Kustomize error: {}'.format(stderr))
log.info('Retrying {}/{}'.format(attempt + 1, retries))
continue
break
else:
raise Exception('Kustomize run failed')

return stdout.decode("utf-8")

Expand Down

0 comments on commit 894f498

Please sign in to comment.