ramitkataria commented on code in PR #77225:
URL: https://github.com/apache/airflow/pull/77225#discussion_r4622088290
##########
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:
I tested this against Bedrock. Only a delete right after
CreateGuardrailVersion is rejected (3 of 3, always this ValidationException),
and a retry about 100 ms later succeeds. Deletes right after create and update
went through.
GetGuardrail does report VERSIONING during that window, so a status wait
works when nothing else
touches the guardrail. #76646 covers that case by waiting in the operators
that make the change.
This PR is for a guardrail changed outside the task. It can enter VERSIONING
between GetGuardrail
and DeleteGuardrail, so the rejected delete has to be handled anyway. A
status check on top would
add a GetGuardrail call and the `bedrock:GetGuardrail` permission to every
delete.
If AWS rewords the message, the task will fail with the Bedrock error, same
as without this PR
--
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]