diff --git a/make_argocd_fly/application.py b/make_argocd_fly/application.py index 9442ecf..a06dd5c 100644 --- a/make_argocd_fly/application.py +++ b/make_argocd_fly/application.py @@ -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")