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

Adding rollback timeout options #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions gonzo/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ def insert_stack_owner_output(template_dict, owner):
return template_dict


def launch_stack(stack_name, template_uri, template_params, owner=None):
def launch_stack(stack_name, template_uri, template_params,
timeout_in_minutes, disable_rollback, owner=None):
""" Launch stacks """

unique_stack_name = get_next_hostname(stack_name)
Expand All @@ -157,7 +158,8 @@ def launch_stack(stack_name, template_uri, template_params, owner=None):
owner)

cloud = get_current_cloud()
return cloud.launch_stack(unique_stack_name, template)
return cloud.launch_stack(unique_stack_name, template,
timeout_in_minutes, disable_rollback)


def terminate_stack(stack_name_or_id):
Expand Down
5 changes: 4 additions & 1 deletion gonzo/backends/aws/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,13 @@ def launch_instance(

return instance

def launch_stack(self, name, template):
def launch_stack(self, name, template,
timeout_in_minutes, disable_rollback):
stack_id = self.orchestration_connection.create_stack(
stack_name=name,
template_body=template,
timeout_in_minutes=timeout_in_minutes,
disable_rollback=disable_rollback,
)

return self._instantiate_stack(stack_id)
Expand Down
3 changes: 2 additions & 1 deletion gonzo/backends/base/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ def launch_instance(
pass

@abstractmethod
def launch_stack(self, name, template):
def launch_stack(self, name, template,
timeout_in_minutes, disable_rollback):
""" Launch a stack """
pass

Expand Down
5 changes: 4 additions & 1 deletion gonzo/backends/openstack/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,13 @@ def launch_instance(

return instance

def launch_stack(self, name, template):
def launch_stack(self, name, template,
timeout_in_minutes, disable_rollback):
stack_id = self.orchestration_connection.create_stack(
stack_name=name,
template_body=template,
timeout_in_minutes=timeout_in_minutes,
disable_rollback=disable_rollback,
)

return self._instantiate_stack(stack_id)
Expand Down
13 changes: 11 additions & 2 deletions gonzo/scripts/stack/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ def launch(args):
username = os.environ.get('USER')

stack = launch_stack(args.stack_name, args.template_uri,
args.template_params, owner=username)
wait_for_stack_complete(stack, args.quiet)
args.template_params,
args.timeout_in_minutes, args.disable_rollback,
owner=username)
wait_for_stack_complete(stack, args.quiet,)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need the trailing comma here

we tend to use trailing commas for larger lists, where each item is on its own line (to get better diffs)

here the closing paren is already on the same line, so no need for a trailing comma

if not stack.is_healthy:
raise UnhealthyResourceError("Stack was not healthy upon completion.")

Expand Down Expand Up @@ -150,3 +152,10 @@ def init_parser(parser):
'--color', dest='color', nargs='?', default='auto',
choices=['never', 'auto', 'always'],
help='display coloured output. (default: auto)')
parser.add_argument(
'--timeout-in-minutes', dest='timeout_in_minutes', default=720,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems a little surprising to have a default here

help="Set stack creation timeout in minutes")
parser.add_argument(
'--enable-rollback', dest='disable_rollback', action="store_false",
help="Enable destroying stacks on failures(Disabled by default)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we've used the form "(Default: disabled)" elsewhere

(also. space missing before parens)

parser.set_defaults(disable_rollback=True)