From 16c5289841fc716d936df9dc58b93ec941ad0326 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Fri, 31 May 2013 12:39:08 +0200 Subject: [PATCH] Allow stacks to be created without a timeout This should be the default for nested stacks, rather than the default timeout of 60 minutes for stacks created through the API. Change-Id: Iacee6eaf8f345e506b417e776f696db6b11bbf20 --- .../versions/016_timeout_nullable.py | 32 +++++++++++++++++++ heat/engine/parser.py | 14 ++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 heat/db/sqlalchemy/migrate_repo/versions/016_timeout_nullable.py diff --git a/heat/db/sqlalchemy/migrate_repo/versions/016_timeout_nullable.py b/heat/db/sqlalchemy/migrate_repo/versions/016_timeout_nullable.py new file mode 100644 index 00000000..3604c7e6 --- /dev/null +++ b/heat/db/sqlalchemy/migrate_repo/versions/016_timeout_nullable.py @@ -0,0 +1,32 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from sqlalchemy import * +from migrate import * + + +def upgrade(migrate_engine): + meta = MetaData() + meta.bind = migrate_engine + + stack = Table('stack', meta, autoload=True) + stack.c.timeout.alter(nullable=True) + + +def downgrade(migrate_engine): + meta = MetaData() + meta.bind = migrate_engine + + stack = Table('stack', meta, autoload=True) + stack.c.timeout.alter(nullable=False) diff --git a/heat/engine/parser.py b/heat/engine/parser.py index ebe4614a..ef5c00b7 100644 --- a/heat/engine/parser.py +++ b/heat/engine/parser.py @@ -264,6 +264,16 @@ class Stack(object): stack.update_and_save({'status': new_status, 'status_reason': reason}) + def timeout_secs(self): + ''' + Return the stack creation timeout in seconds, or None if no timeout + should be used. + ''' + if self.timeout_mins is None: + return None + + return self.timeout_mins * 60 + def create(self): ''' Create the stack and all of the resources. @@ -284,7 +294,7 @@ class Stack(object): resource_create) create = scheduler.TaskRunner(create_task) - with eventlet.Timeout(self.timeout_mins * 60) as tmo: + with eventlet.Timeout(self.timeout_secs()) as tmo: try: create() except exception.ResourceFailure as ex: @@ -342,7 +352,7 @@ class Stack(object): r.cache_template() # Now make the resources match the new stack definition - with eventlet.Timeout(self.timeout_mins * 60) as tmo: + with eventlet.Timeout(self.timeout_secs()) as tmo: try: # First delete any resources which are not in newstack for res in reversed(self): -- 2.45.2