Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AWS RDS hook's DB instance state check #34773

Merged
merged 3 commits into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions airflow/providers/amazon/aws/hooks/rds.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ def get_db_snapshot_state(self, snapshot_id: str) -> str:
"""
try:
response = self.conn.describe_db_snapshots(DBSnapshotIdentifier=snapshot_id)
except self.conn.exceptions.ClientError as e:
if e.response["Error"]["Code"] == "DBSnapshotNotFound":
raise AirflowNotFoundException(e)
raise e
except self.conn.exceptions.DBSnapshotNotFoundFault as e:
raise AirflowNotFoundException(e)
return response["DBSnapshots"][0]["Status"].lower()

def wait_for_db_snapshot_state(
Expand Down Expand Up @@ -109,10 +107,8 @@ def get_db_cluster_snapshot_state(self, snapshot_id: str) -> str:
"""
try:
response = self.conn.describe_db_cluster_snapshots(DBClusterSnapshotIdentifier=snapshot_id)
except self.conn.exceptions.ClientError as e:
if e.response["Error"]["Code"] == "DBClusterSnapshotNotFoundFault":
raise AirflowNotFoundException(e)
raise e
except self.conn.exceptions.DBClusterSnapshotNotFoundFault as e:
raise AirflowNotFoundException(e)
return response["DBClusterSnapshots"][0]["Status"].lower()

def wait_for_db_cluster_snapshot_state(
Expand Down Expand Up @@ -239,10 +235,8 @@ def get_db_instance_state(self, db_instance_id: str) -> str:
"""
try:
response = self.conn.describe_db_instances(DBInstanceIdentifier=db_instance_id)
except self.conn.exceptions.ClientError as e:
if e.response["Error"]["Code"] == "DBInstanceNotFoundFault":
raise AirflowNotFoundException(e)
raise e
except self.conn.exceptions.DBInstanceNotFoundFault as e:
raise AirflowNotFoundException(e)
return response["DBInstances"][0]["DBInstanceStatus"].lower()

def wait_for_db_instance_state(
Expand Down Expand Up @@ -292,10 +286,8 @@ def get_db_cluster_state(self, db_cluster_id: str) -> str:
"""
try:
response = self.conn.describe_db_clusters(DBClusterIdentifier=db_cluster_id)
except self.conn.exceptions.ClientError as e:
if e.response["Error"]["Code"] == "DBClusterNotFoundFault":
raise AirflowNotFoundException(e)
raise e
except self.conn.exceptions.DBClusterNotFoundFault as e:
raise AirflowNotFoundException(e)
return response["DBClusters"][0]["Status"].lower()

def wait_for_db_cluster_state(
Expand Down