pankajastro commented on code in PR #30244:
URL: https://github.com/apache/airflow/pull/30244#discussion_r1217037100
##########
airflow/providers/amazon/aws/triggers/redshift_cluster.py:
##########
@@ -357,3 +357,78 @@ async def run(self):
)
else:
yield TriggerEvent({"status": "success", "message": "Cluster
resumed"})
+
+
+class RedshiftDeleteClusterTrigger(BaseTrigger):
+ """
+ Trigger for RedshiftDeleteClusterOperator
+
+ :param cluster_identifier: A unique identifier for the cluster.
+ :param max_attempts: The maximum number of attempts to be made.
+ :param aws_conn_id: The Airflow connection used for AWS credentials.
+ :param poll_interval: The amount of time in seconds to wait between
attempts.
+ """
+
+ def __init__(
+ self,
+ cluster_identifier: str,
+ max_attempts: int = 30,
+ aws_conn_id: str = "aws_default",
+ poll_interval: int = 30,
+ ):
+ super().__init__()
+ self.cluster_identifier = cluster_identifier
+ self.max_attempts = max_attempts
+ self.aws_conn_id = aws_conn_id
+ self.poll_interval = poll_interval
+
+ def serialize(self) -> tuple[str, dict[str, Any]]:
+ return (
+
"airflow.providers.amazon.aws.triggers.redshift_cluster.RedshiftDeleteClusterTrigger",
+ {
+ "cluster_identifier": self.cluster_identifier,
+ "max_attempts": self.max_attempts,
+ "aws_conn_id": self.aws_conn_id,
+ "poll_interval": self.poll_interval,
+ },
+ )
+
+ @cached_property
+ def hook(self):
+ return RedshiftHook(aws_conn_id=self.aws_conn_id)
+
+ async def run(self) -> AsyncIterator[TriggerEvent]:
+ async with self.hook.async_conn as client:
+ attempt = 0
+ waiter = client.get_waiter("cluster_deleted")
+ while attempt < self.max_attempts:
+ attempt = attempt + 1
+ try:
+ await waiter.wait(
+ ClusterIdentifier=self.cluster_identifier,
+ WaiterConfig={
+ "Delay": self.poll_interval,
+ "MaxAttempts": 1,
Review Comment:
I feel when we are waiting in the trigger loop then it would be helpful for
a user if we log some message otherwise users are not aware of what happening
in the background. Unfourtunently boto waiter does not provide a way of doing
some logging so we decided this workaround you can find some discussion on PR
https://github.com/apache/airflow/pull/30853 about it.
--
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]