@@ -61,11 +61,14 @@ def get_db_snapshot_state(self, snapshot_id: str) -> str:
6161 :return: Returns the status of the DB snapshot as a string (eg. "available")
6262 :raises AirflowNotFoundException: If the DB instance snapshot does not exist.
6363 """
64+ self .log .debug ("Retrieving state for DB snapshot %s" , snapshot_id )
6465 try :
6566 response = self .conn .describe_db_snapshots (DBSnapshotIdentifier = snapshot_id )
6667 except self .conn .exceptions .DBSnapshotNotFoundFault as e :
67- raise AirflowNotFoundException (e )
68- return response ["DBSnapshots" ][0 ]["Status" ].lower ()
68+ raise AirflowNotFoundException (e ) from e
69+ state = response ["DBSnapshots" ][0 ]["Status" ].lower ()
70+ self .log .debug ("DB snapshot %s state: %s" , snapshot_id , state )
71+ return state
6972
7073 def wait_for_db_snapshot_state (
7174 self , snapshot_id : str , target_state : str , check_interval : int = 30 , max_attempts : int = 40
@@ -107,11 +110,14 @@ def get_db_cluster_snapshot_state(self, snapshot_id: str) -> str:
107110 :return: Returns the status of the DB cluster snapshot as a string (eg. "available")
108111 :raises AirflowNotFoundException: If the DB cluster snapshot does not exist.
109112 """
113+ self .log .debug ("Retrieving state for DB cluster snapshot %s" , snapshot_id )
110114 try :
111115 response = self .conn .describe_db_cluster_snapshots (DBClusterSnapshotIdentifier = snapshot_id )
112116 except self .conn .exceptions .DBClusterSnapshotNotFoundFault as e :
113- raise AirflowNotFoundException (e )
114- return response ["DBClusterSnapshots" ][0 ]["Status" ].lower ()
117+ raise AirflowNotFoundException (e ) from e
118+ state = response ["DBClusterSnapshots" ][0 ]["Status" ].lower ()
119+ self .log .debug ("DB cluster snapshot %s state: %s" , snapshot_id , state )
120+ return state
115121
116122 def wait_for_db_cluster_snapshot_state (
117123 self , snapshot_id : str , target_state : str , check_interval : int = 30 , max_attempts : int = 40
@@ -153,13 +159,16 @@ def get_export_task_state(self, export_task_id: str) -> str:
153159 :return: Returns the status of the snapshot export task as a string (eg. "canceled")
154160 :raises AirflowNotFoundException: If the export task does not exist.
155161 """
162+ self .log .debug ("Retrieving state for export task %s" , export_task_id )
156163 try :
157164 response = self .conn .describe_export_tasks (ExportTaskIdentifier = export_task_id )
158165 except self .conn .exceptions .ClientError as e :
159166 if e .response ["Error" ]["Code" ] in ("ExportTaskNotFound" , "ExportTaskNotFoundFault" ):
160- raise AirflowNotFoundException (e )
161- raise e
162- return response ["ExportTasks" ][0 ]["Status" ].lower ()
167+ raise AirflowNotFoundException (e ) from e
168+ raise
169+ state = response ["ExportTasks" ][0 ]["Status" ].lower ()
170+ self .log .debug ("Export task %s state: %s" , export_task_id , state )
171+ return state
163172
164173 def wait_for_export_task_state (
165174 self , export_task_id : str , target_state : str , check_interval : int = 30 , max_attempts : int = 40
@@ -194,13 +203,16 @@ def get_event_subscription_state(self, subscription_name: str) -> str:
194203 :return: Returns the status of the event subscription as a string (eg. "active")
195204 :raises AirflowNotFoundException: If the event subscription does not exist.
196205 """
206+ self .log .debug ("Retrieving state for event subscription %s" , subscription_name )
197207 try :
198208 response = self .conn .describe_event_subscriptions (SubscriptionName = subscription_name )
199209 except self .conn .exceptions .ClientError as e :
200210 if e .response ["Error" ]["Code" ] in ("SubscriptionNotFoundFault" , "SubscriptionNotFound" ):
201- raise AirflowNotFoundException (e )
202- raise e
203- return response ["EventSubscriptionsList" ][0 ]["Status" ].lower ()
211+ raise AirflowNotFoundException (e ) from e
212+ raise
213+ state = response ["EventSubscriptionsList" ][0 ]["Status" ].lower ()
214+ self .log .debug ("Event subscription %s state: %s" , subscription_name , state )
215+ return state
204216
205217 def wait_for_event_subscription_state (
206218 self , subscription_name : str , target_state : str , check_interval : int = 30 , max_attempts : int = 40
@@ -235,11 +247,14 @@ def get_db_instance_state(self, db_instance_id: str) -> str:
235247 :return: Returns the status of the DB instance as a string (eg. "available")
236248 :raises AirflowNotFoundException: If the DB instance does not exist.
237249 """
250+ self .log .debug ("Retrieving state for DB instance %s" , db_instance_id )
238251 try :
239252 response = self .conn .describe_db_instances (DBInstanceIdentifier = db_instance_id )
240253 except self .conn .exceptions .DBInstanceNotFoundFault as e :
241- raise AirflowNotFoundException (e )
242- return response ["DBInstances" ][0 ]["DBInstanceStatus" ].lower ()
254+ raise AirflowNotFoundException (e ) from e
255+ state = response ["DBInstances" ][0 ]["DBInstanceStatus" ].lower ()
256+ self .log .debug ("DB instance %s state: %s" , db_instance_id , state )
257+ return state
243258
244259 def wait_for_db_instance_state (
245260 self , db_instance_id : str , target_state : str , check_interval : int = 30 , max_attempts : int = 40
@@ -286,11 +301,14 @@ def get_db_cluster_state(self, db_cluster_id: str) -> str:
286301 :return: Returns the status of the DB cluster as a string (eg. "available")
287302 :raises AirflowNotFoundException: If the DB cluster does not exist.
288303 """
304+ self .log .debug ("Retrieving state for DB cluster %s" , db_cluster_id )
289305 try :
290306 response = self .conn .describe_db_clusters (DBClusterIdentifier = db_cluster_id )
291307 except self .conn .exceptions .DBClusterNotFoundFault as e :
292- raise AirflowNotFoundException (e )
293- return response ["DBClusters" ][0 ]["Status" ].lower ()
308+ raise AirflowNotFoundException (e ) from e
309+ state = response ["DBClusters" ][0 ]["Status" ].lower ()
310+ self .log .debug ("DB cluster %s state: %s" , db_cluster_id , state )
311+ return state
294312
295313 def wait_for_db_cluster_state (
296314 self , db_cluster_id : str , target_state : str , check_interval : int = 30 , max_attempts : int = 40
0 commit comments