]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Allow stacks to be created without a timeout
authorZane Bitter <zbitter@redhat.com>
Fri, 31 May 2013 10:39:08 +0000 (12:39 +0200)
committerZane Bitter <zbitter@redhat.com>
Fri, 31 May 2013 10:40:08 +0000 (12:40 +0200)
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

heat/db/sqlalchemy/migrate_repo/versions/016_timeout_nullable.py [new file with mode: 0644]
heat/engine/parser.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 (file)
index 0000000..3604c7e
--- /dev/null
@@ -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)
index ebe4614a927213b402baa42ca3155024c9afe177..ef5c00b754c8c94c18070cc432d175c57c60e47e 100644 (file)
@@ -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):