vincbeck commented on code in PR #77225:
URL: https://github.com/apache/airflow/pull/77225#discussion_r4615856163
##########
providers/amazon/src/airflow/providers/amazon/aws/operators/bedrock.py:
##########
@@ -1505,7 +1515,27 @@ def execute(self, context: Context) -> None:
"guardrailVersion": self.guardrail_version,
}
)
- self.hook.conn.delete_guardrail(**kwargs)
+ attempt = 1
Review Comment:
Can you use tenacity like `build_resource_in_use_retry_args` in
`aws/utils/__init__.py` does? Also, `DeleteGuardrail` documents
`ResourceInUseException` and `ConflictException`, should we retry on these as
well?
##########
providers/amazon/src/airflow/providers/amazon/aws/operators/bedrock.py:
##########
@@ -1505,7 +1515,27 @@ def execute(self, context: Context) -> None:
"guardrailVersion": self.guardrail_version,
}
)
- self.hook.conn.delete_guardrail(**kwargs)
+ attempt = 1
+ while True:
+ try:
+ self.hook.conn.delete_guardrail(**kwargs)
+ break
+ except ClientError as e:
+ error = e.response["Error"]
+ # Bedrock reports a guardrail in a transitional status as a
ValidationException, the
+ # code it also uses for invalid input, so only the message
tells the two apart.
+ is_in_transition = error["Code"] == "ValidationException" and (
Review Comment:
Why not check the guardrail status with `get_guardrail` and wait until it is
no longer `CREATING`, `UPDATING` or `VERSIONING` before deleting? Matching on
the message breaks silently if AWS rewords 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]