Lee-W commented on code in PR #36416:
URL: https://github.com/apache/airflow/pull/36416#discussion_r1436405148


##########
airflow/providers/amazon/aws/operators/redshift_cluster.py:
##########
@@ -535,19 +535,27 @@ 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 == "paused":
+                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),
+                )
+
+            self.log.warning(

Review Comment:
   Yep, we should do something similar. I revised this logic a bit to keep it 
in sync with the waiters in my latest change.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to