diff --git a/loading_pipeline/lib/tasks/dataproc/create_dataproc_cluster.py b/loading_pipeline/lib/tasks/dataproc/create_dataproc_cluster.py index 33785a8d1e..dc77765d41 100644 --- a/loading_pipeline/lib/tasks/dataproc/create_dataproc_cluster.py +++ b/loading_pipeline/lib/tasks/dataproc/create_dataproc_cluster.py @@ -223,6 +223,13 @@ def get_running_cluster(self): if cluster.status.state in FAILURE_STATUSES: msg = f'Cluster {cluster.cluster_name} entered {cluster.status.state.name} state' logger.error(msg) + self.client.delete_cluster( + request={ + 'project_id': Env.GCLOUD_PROJECT, + 'region': Env.GCLOUD_REGION, + 'cluster_name': cluster.cluster_name, + }, + ) raise RuntimeError(msg) logger.info('Waiting for cluster spinup') time.sleep(3)