avoid excessive database calls while loading events
list_events constructs Event objects through Event.load, which causes
every event record previously loaded into memory to be reloaded again.
Furthermore, Event.load will also reload the associated stack, thus
all its resources and template. Another bad thing with that is
reloading a stack will lead to many extra stack static resolution
(including calls to nova to resovle Fn::GetAZs if it's referenced in
the template).
Steve Baker [Thu, 11 Jul 2013 04:08:54 +0000 (16:08 +1200)]
Global disable scheduler _sleep instead of mocking.
It is becoming increasingly difficult to predict when
a call to TaskRunner._sleep needs to be scripted, and is probably an
implementation detail which shouldn't be exposed to unit tests anyway.
This change defines a global which prevents sleeping in calls to _sleep
and toggles that global in HeatTestCase setUp.
Steve Baker [Tue, 9 Jul 2013 04:01:58 +0000 (16:01 +1200)]
Tolerate an empty environment properties.
An environment file containing the following:
properties:
Results in the following error:
File "/home/steveb/dev/localstack/heat/heat/api/openstack/v1/stacks.py",
line 132, in environment
env[self.PARAM_USER_PARAMS].update(parameters)
AttributeError: 'NoneType' object has no attribute 'update'
Steve Baker [Wed, 3 Jul 2013 03:21:23 +0000 (15:21 +1200)]
Define behaviour for properties with None values.
Now that Ref and Fn::GetAtt might return None values, behaviour for
properties with None values needs definition.
This change will treat a None value in the following way:
- if there is a default in the schema, that value will be used
- otherwise a default is used depending on the type ('', False, 0, [] {})
Steven Hardy [Wed, 3 Jul 2013 17:03:57 +0000 (18:03 +0100)]
engine : add suspend/resume support to watch resource
Add suspend/resume support to CloudWatchAlarm resource and
underlying watchrule - this means that when in suspended
state watches will not allow new metric data to be added
or for alarm evaluation/actions to happen
Stop patching the GenericResource's property_schema
This is causing test failures if you add a new test
and don't reset the scema to {}, this seems to be timing
related. Just add Resource types that we need prevents the
need for this patching.
Steve Baker [Wed, 3 Jul 2013 23:50:49 +0000 (11:50 +1200)]
Enforce credentials requirement on stack create/update.
Credentials need to be supplied whenever they are stored with the stack,
which is during stack create and update.
Some users have been relying on their auth token to perform all heat
operations (as all other openstack services support) however this has
led them to experience obscure errors when wait handles or alarms are
triggered.
Failing early with a clear error message will stop this class of errors.
Steven Hardy [Thu, 4 Jul 2013 09:26:31 +0000 (10:26 +0100)]
cleanup watchrule delete logic/tests
Rework watchrule delete interface so we delete by ID, rather than
by name (where we only delete the first rule in the event of multiple
watcherule rows with the same name, which is allowed although not likely
in normal heat operation - it can cause weird behavior in the tests)
Encapsulating the delete in a WatchRule.destroy() is cleaner and more
consistent with the rest of the codebase, and reworking the tests to
ensure proper cleanup reduces the chances of odd errors and cascading
failures between tests on failure.
We need to pass the id_list to the loadbalancer, otherwise it
can't lookup the instance IP adresses with nova and the loadbalancer
config ends up with 0.0.0.0 for every instance
Steven Hardy [Tue, 2 Jul 2013 13:22:24 +0000 (14:22 +0100)]
add missing gettextutils imports
Several files use the "_" function, but don't import it from
gettextutils - this leads to a "NameError: name '_' is not
defined" error if you try to import/use the modules from an
interactive python shell or standalone test-code.
Steven Hardy [Tue, 2 Jul 2013 13:17:30 +0000 (14:17 +0100)]
engine : perform periodic tasks with stored stack_context
The metadata update needs to be performed with the stored stack_context,
not the admin_context, which contains no credentials to e.g authenticate
with nova
Steve Baker [Mon, 20 May 2013 22:01:16 +0000 (10:01 +1200)]
Rework associations from vpc to quantum resources.
Metadata cannot be used to store the relationships between VPC
resources and the underlying quantum resources, since this prevents
VPC or Subnet refs from being passed in as parameters.
This rework results in no state being stored in metadata. Route table
relationships are inferred from the template. An assumption is made that
the quantum router associatiated with the VPC will have the same name
as the quantum net. The easiest way of ensuring that is to creat the VPC
in a different Heat stack.
Steven Hardy [Mon, 1 Jul 2013 10:27:26 +0000 (11:27 +0100)]
tests : remove duplicate suspend tests
A previous patch erroneously introduced two copies of the same
tests, remove the stackServiceTest duplicates as they already
exist in the stackServiceSuspendResumeTest testcase.
Steven Hardy [Fri, 28 Jun 2013 10:15:40 +0000 (11:15 +0100)]
api : Add actions resume support
Add support for resume action using a similar interface to that provided
by nova for the admin actions extension. So a body of {'resume': None}
will suspend the stack, see http://api.openstack.org/api-ref.html
Liang Chen [Sat, 29 Jun 2013 13:45:43 +0000 (21:45 +0800)]
destroy failed instances created by auto scaling
The ResourceFailure exception was silently eaten when raise_on_error
set to False. This patch handles the ResourceFailure exception locally
when raise_on_error set to False - called from ScalingPolicy alarm
(i.e. runtime adjustment). So users will not be charged for orphaned
instances. But they can still see what happened through event list.
Steve Baker [Thu, 20 Jun 2013 02:17:20 +0000 (14:17 +1200)]
Expose resource dependency required_by to REST API.
Each resource can generate a list of names of resources which
require this resource as a direct (non transitive) dependency.
This information is returned in the list as well as the show REST calls
so that a diagram of the running stack can be built with a single
request.
Other uses of exposing this information is:
- template authors debugging their own template dependency issues
- integration tests validating template dependencies
Steven Hardy [Fri, 28 Jun 2013 15:43:41 +0000 (16:43 +0100)]
engine : simplify resource state check
Simplify the test to check the resource is in a COMPLETE state
(other than DELETE_COMPLETE), so we don't have to update this for
every new action state which gets added
The default behavior in _do_action is to declare COMPLETE if the
check_$action_complete is not implemented, so these default
functions returning True are not needed.
Patrick Woods [Thu, 27 Jun 2013 19:44:54 +0000 (14:44 -0500)]
Fixup handle_create backup restore.
The handle_create did not retrieve the volume_id
correctly and the check_create_complete
needs to handle the restoring-backup status.
Also modify and add support for restoring-backup
status test cases for success and error.
The additional FakeVolumeFromBackup will force
the inital status to be checked by the method
check_create_complete in volume.py.
Liang Chen [Fri, 28 Jun 2013 14:27:59 +0000 (22:27 +0800)]
add GET /{tenant_id}/stacks/detail to Heat API
Enables the building of a useful dashboard interface for Heat stacks
without looping through stacks returned from "/{tenant_id}/stacks/"
to fetch the detailed data.
Robert Collins [Thu, 27 Jun 2013 10:10:51 +0000 (22:10 +1200)]
Fixup assert_has_keys.
This test helper had awkward code that didn't support users in
debugging tests, as it didn't report enough information. Additionally
some style issues were present, which I fixed up at the same time.
Steven Hardy [Thu, 27 Jun 2013 15:20:56 +0000 (16:20 +0100)]
autoscaling : Fix issue when scaling to zero instances
As noted in https://review.openstack.org/#/c/34564, we lack
coverage of the scenario when MinSize is 0 and we scale down
to zero instances then try to do a delete. We do the wrong
thing here, by creating a GroupedInstance object with name '',
and this would also result in an incorrect update to the
LoadBalancer. Fix is to reset the resource_id to None.