pankajkoti commented on code in PR #36416: URL: https://github.com/apache/airflow/pull/36416#discussion_r1436423521
########## airflow/providers/amazon/aws/operators/redshift_cluster.py: ########## @@ -535,19 +535,29 @@ def execute(self, context: Context): time.sleep(self._attempt_interval) else: raise error + if self.deferrable: - self.defer( - trigger=RedshiftResumeClusterTrigger( - cluster_identifier=self.cluster_identifier, - waiter_delay=self.poll_interval, - waiter_max_attempts=self.max_attempts, - aws_conn_id=self.aws_conn_id, - ), - method_name="execute_complete", - # timeout is set to ensure that if a trigger dies, the timeout does not restart - # 60 seconds is added to allow the trigger to exit gracefully (i.e. yield TriggerEvent) - timeout=timedelta(seconds=self.max_attempts * self.poll_interval + 60), - ) + cluster_state = redshift_hook.cluster_status(cluster_identifier=self.cluster_identifier) + if cluster_state == "available": + self.log.info("Resumed cluster successfully") + elif cluster_state == "deleting": + raise AirflowException( + "Unable to resume cluster since cluster is currently in status: %s", cluster_state + ) + else: Review Comment: Since there are so many cluster states possible as per https://docs.aws.amazon.com/redshift/latest/mgmt/working-with-clusters.html#rs-mgmt-cluster-status, I think we could explicitly have an elif check here (probably on `paused`) to check the cluster is in resumable state and have a broader else clause to raise an exception instead -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org