syedahsn commented on code in PR #30244:
URL: https://github.com/apache/airflow/pull/30244#discussion_r1148168854
##########
airflow/providers/amazon/aws/operators/redshift_cluster.py:
##########
@@ -603,28 +605,62 @@ def __init__(
self._attempts = 10
self._attempt_interval = 15
self.redshift_hook = RedshiftHook(aws_conn_id=aws_conn_id)
+ self.aws_conn_id = aws_conn_id
+ self.deferrable = deferrable
def execute(self, context: Context):
- while self._attempts >= 1:
- try:
- self.redshift_hook.delete_cluster(
+ if self.deferrable:
+ self.defer(
+ timeout=self.execution_timeout,
+ trigger=RedshiftClusterTrigger(
+ task_id=self.task_id,
+ poll_interval=self.poll_interval,
+ aws_conn_id=self.aws_conn_id,
cluster_identifier=self.cluster_identifier,
+ operation_type="delete_cluster",
skip_final_cluster_snapshot=self.skip_final_cluster_snapshot,
final_cluster_snapshot_identifier=self.final_cluster_snapshot_identifier,
- )
- break
- except
self.redshift_hook.get_conn().exceptions.InvalidClusterStateFault:
- self._attempts = self._attempts - 1
+ attempts=self._attempts,
+ ),
+ method_name="execute_complete",
+ )
+ else:
+ while self._attempts >= 1:
Review Comment:
This mechanism was [added](https://github.com/apache/airflow/pull/27820) to
solve issues where the cluster would fail to delete when an operation was
running in the cluster. In deferrable mode, the execution would switch to the
Trigger, which doesn't implement this retry behavior.
--
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]