Skip to content

Commit

Permalink
Switch Cloud Formation waiters to WaiterConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
joguSD committed Sep 12, 2017
1 parent 1cdb9f9 commit a3fdac6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-CloudFormation-69529.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "CloudFormation",
"description": "CloudFormation will no longer fail for deploys that take longer than 10 minutes. Fixes `#2754 <https://github.com/aws/aws-cli/issues/2754>`__"
}
12 changes: 8 additions & 4 deletions awscli/customizations/cloudformation/deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ def wait_for_changeset(self, changeset_id, stack_name):
# Wait for changeset to be created
waiter = self._client.get_waiter("change_set_create_complete")
# Poll every 5 seconds. Changeset creation should be fast
waiter.config.delay = 5
waiter_config = {'Delay': 5}
try:
waiter.wait(ChangeSetName=changeset_id, StackName=stack_name)
waiter.wait(ChangeSetName=changeset_id, StackName=stack_name,
WaiterConfig=waiter_config)
except botocore.exceptions.WaiterError as ex:
LOG.debug("Create changeset waiter exception", exc_info=ex)

Expand Down Expand Up @@ -178,10 +179,13 @@ def wait_for_execute(self, stack_name, changeset_type):

# Poll every 5 seconds. Optimizing for the case when the stack has only
# minimal changes, such the Code for Lambda Function
waiter.config.delay = 5
waiter_config = {
'Delay': 5,
'MaxAttempts': 720,
}

try:
waiter.wait(StackName=stack_name)
waiter.wait(StackName=stack_name, WaiterConfig=waiter_config)
except botocore.exceptions.WaiterError as ex:
LOG.debug("Execute changeset waiter exception", exc_info=ex)

Expand Down
15 changes: 12 additions & 3 deletions tests/unit/customizations/cloudformation/test_deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,10 @@ def test_wait_for_changeset_no_changes(self):
with self.assertRaises(exceptions.ChangeEmptyError):
mock_deployer.wait_for_changeset(changeset_id, stack_name)

waiter_config = {'Delay': 5}
mock_waiter.wait.assert_called_once_with(ChangeSetName=changeset_id,
StackName=stack_name)
StackName=stack_name,
WaiterConfig=waiter_config)

mock_client.get_waiter.assert_called_once_with(
"change_set_create_complete")
Expand All @@ -282,8 +284,10 @@ def test_wait_for_changeset_failed_to_create_changeset(self):
with self.assertRaises(RuntimeError):
mock_deployer.wait_for_changeset(changeset_id, stack_name)

waiter_config = {'Delay': 5}
mock_waiter.wait.assert_called_once_with(ChangeSetName=changeset_id,
StackName=stack_name)
StackName=stack_name,
WaiterConfig=waiter_config)

mock_client.get_waiter.assert_called_once_with(
"change_set_create_complete")
Expand All @@ -305,7 +309,12 @@ def test_wait_for_execute_no_changes(self):
with self.assertRaises(exceptions.DeployFailedError):
mock_deployer.wait_for_execute(stack_name, changeset_type)

mock_waiter.wait.assert_called_once_with(StackName=stack_name)
waiter_config = {
'Delay': 5,
'MaxAttempts': 720,
}
mock_waiter.wait.assert_called_once_with(StackName=stack_name,
WaiterConfig=waiter_config)

mock_client.get_waiter.assert_called_once_with(
"stack_create_complete")
Expand Down

0 comments on commit a3fdac6

Please sign in to comment.