pankajastro commented on code in PR #30244:
URL: https://github.com/apache/airflow/pull/30244#discussion_r1153619289
##########
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:
for deferrable mode. In hook I'm waiting for status and in trigger we have
an attempt mechanism. below I have attached the log for fail case. currently,
I'm using the poll_interval param for `_attempt_interval`.
```
[2023-03-30, 17:47:24 UTC] {connection_wrapper.py:340} INFO - AWS Connection
(conn_id='aws_default', conn_type='redshift') credentials retrieved from extra.
[2023-03-30, 17:47:29 UTC] {redshift_cluster.py:96} INFO - Retrying in #30.0
seconds remaining attempts #9
[2023-03-30, 17:48:02 UTC] {redshift_cluster.py:96} INFO - Retrying in #30.0
seconds remaining attempts #8
[2023-03-30, 17:48:36 UTC] {redshift_cluster.py:96} INFO - Retrying in #30.0
seconds remaining attempts #7
[2023-03-30, 17:49:11 UTC] {redshift_cluster.py:96} INFO - Retrying in #30.0
seconds remaining attempts #6
[2023-03-30, 17:49:44 UTC] {redshift_cluster.py:96} INFO - Retrying in #30.0
seconds remaining attempts #5
```
--
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]