Skip to content

Commit

Permalink
Fix endless loop of defer in cloud_build (#32387)
Browse files Browse the repository at this point in the history
  • Loading branch information
tnk-ysk committed Jul 6, 2023
1 parent e4757d6 commit becfb3c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions airflow/providers/google/cloud/triggers/cloud_build.py
Expand Up @@ -95,6 +95,7 @@ async def run(self) -> AsyncIterator[TriggerEvent]: # type: ignore[override]
"message": "Build completed",
}
)
return
elif cloud_build_instance._pb.status in (
Build.Status.WORKING,
Build.Status.PENDING,
Expand All @@ -111,14 +112,17 @@ async def run(self) -> AsyncIterator[TriggerEvent]: # type: ignore[override]
Build.Status.EXPIRED,
):
yield TriggerEvent({"status": "error", "message": cloud_build_instance.status_detail})
return
else:
yield TriggerEvent(
{"status": "error", "message": "Unidentified status of Cloud Build instance"}
)
return

except Exception as e:
self.log.exception("Exception occurred while checking for Cloud Build completion")
yield TriggerEvent({"status": "error", "message": str(e)})
return

def _get_async_hook(self) -> CloudBuildAsyncHook:
return CloudBuildAsyncHook(gcp_conn_id=self.gcp_conn_id)

0 comments on commit becfb3c

Please sign in to comment.