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

Increase ConflictException retries to 4 total #36337

Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion airflow/providers/amazon/aws/hooks/sagemaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ def stop_pipeline(
if check_interval is None:
check_interval = 10

for retries in (2, 1, 0):
for retries in reversed(range(5)):
try:
self.conn.stop_pipeline_execution(PipelineExecutionArn=pipeline_exec_arn)
except ClientError as ce:
Expand Down
6 changes: 4 additions & 2 deletions tests/providers/amazon/aws/hooks/test_sagemaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,8 @@ def test_stop_pipeline_retries_on_conflict(self, mock_conn):
operation_name="empty",
)
mock_conn().stop_pipeline_execution.side_effect = [
conflict_error,
conflict_error,
conflict_error,
conflict_error,
None,
Expand All @@ -819,7 +821,7 @@ def test_stop_pipeline_retries_on_conflict(self, mock_conn):
hook = SageMakerHook(aws_conn_id="aws_default")
hook.stop_pipeline(pipeline_exec_arn="test")

assert mock_conn().stop_pipeline_execution.call_count == 3
assert mock_conn().stop_pipeline_execution.call_count == 5

@patch("airflow.providers.amazon.aws.hooks.sagemaker.SageMakerHook.conn", new_callable=mock.PropertyMock)
def test_stop_pipeline_fails_if_all_retries_error(self, mock_conn):
Expand All @@ -833,7 +835,7 @@ def test_stop_pipeline_fails_if_all_retries_error(self, mock_conn):
with pytest.raises(ClientError) as raised_exception:
hook.stop_pipeline(pipeline_exec_arn="test")

assert mock_conn().stop_pipeline_execution.call_count == 3
assert mock_conn().stop_pipeline_execution.call_count == 5
assert raised_exception.value == conflict_error

@patch("airflow.providers.amazon.aws.hooks.sagemaker.SageMakerHook.conn", new_callable=mock.PropertyMock)
Expand Down