Because of quotas, there are times when creating a resource and then
deleting another resource may fail where doing it in the reverse order
would work, even though the resources are independent of one another.
When enqueueing 'check_resource' messages, send those for cleanup nodes
prior to those for update nodes. This means that all things being equal
(i.e. no dependency relationship), deletions will be started first. It
doesn't guarantee success when quotas allow, since only a dependency
relationship will cause Heat to wait for the deletion to complete before
starting creation, but it is a risk-free way to give us a better chance of
succeeding.
Change-Id: I9727d906cd0ad8c4bf9c5e632a47af6d7aad0c72
Partial-Bug: #1713900
The OS::Heat::HARestarter has been deprecated since Kilo. Now is the
time to eliminate support and hide it from the documentation.
This replaces it with a placeholder resource (like OS::Heat::None) and
marks it as hidden.
Change-Id: I56cd1f2d0b3323399ef02c3a0a05d79cc69af956
When listing resources with nested depth, we get all resources
for the root stack and cache them in the context. By the time
we iterate through the resources for a nested stack, if the
current_template_id of resources do not match the stack template,
we try to load the template. However, it's possible that the
template does not exist anymore. It would be good to ignore
those resources.
Change-Id: I838320539838ed74f490bca8601cde96eaf7c7ee
Closes-Bug: #1734815
It was unclear what the valid arguments to Template.get_section_name() were
(especially since the function is mis-named for what it actually does in
HOT). Define the arguments as constants and don't pass string literals any
more. Be consistent in how we define paths, standardising on the method in
Resource.validate_template().
Change-Id: Ifd073d9889ff60502f78aaa54532cec2b7814d93
It's expected that when a resource completes and the traversal it was
processing is no longer active, we won't update the stack state in the
database. Therefore don't log at WARNING level for this routine event.
Change-Id: Ic901e46c251400c4eeb90a4d9ad4a97d61fb1af8
The node key in the convergence graph is a (resource id, update/!cleanup)
tuple. Sometimes it would be convenient to access the members by name, so
convert to a namedtuple.
Change-Id: Id8c159b0137df091e96f1f8d2312395d4a5664ee
We only have to remove the existing snapshots
for resources when stack delete.
Change-Id: Ia195f3c3380fe71e0888c8291209dd4562318951
Closes-Bug: #1716612
Set old tags for old_stack to make sure the stack
with the correct tags after rollback.
Change-Id: I8450df08c84b5a467ab8ac991451c5b108ee96e7
Closes-Bug: #1702251
Add converge parameter for stack update API and RPC call,
that allow triggering observe on reality. This will be
triggered by API call with converge argument (with True
or False value) within. This flag also works for resources
within nested stack.
Implements bp get-reality-for-resources
Change-Id: I151b575b714dcc9a5971a1573c126152ecd7ea93
Eager load resource_properties_data in resources in the typical
resource-loading scenarios where properties data will be
accessed. Thus, we can save an extra db query per resource when
loading all the resources in a stack, for instance. Fall back to lazy
loading properties data in other scenarios.
Also, the resource object doesn't need to store a copy of its
ResourcePropertiesData object in self.rsrc_prop_data, so don't.
Change-Id: Ib7684af3fe06f818628fd21f1216de5047872948
Closes-Bug: #1665503
This is no longer required as the convergence 'lightweight stack' used for
checking individual resources has now merged with the other code paths: in
every case intrinsic functions are resolved using the data about resources
stored in StackDefinition and accessed via ResourceProxy.
Change-Id: I41cf21c8e1babe819b4b6c668749ed5915ae3b54
This unifies the 'lightweight stack' used in convergence with the how
things work the rest of the time: we now always obtain resource data from
the StackDefinition's ResourceProxy objects. This means that when we are
checking an individual resource, we will never create all of the other
Resource objects for the stack in memory (although we already avoided
loading data for them from the database) - now we will only create
ResourceProxy objects as needed.
Change-Id: Id7472557e26d172df88841ff7f20afdd7f5bfada
Implements: blueprint stack-definition
Since function.dep_attrs() returns logical resource names (rather
than actual objects), we can just as easily use the StackDefinition to
calculate it instead of the Stack and Resource objects.
In the legacy path, we must ensure we use the StackDefinition from the
*new* stack to determine which attributes to include in the NodeData, since
that's what we're going to be using it for. In the convergence path the
current stack definition already contains the new template.
Also, update the *new* stack's definition with the NodeData obtained from
completed resources (in addition to the existing stack's), so that that
data may be used in calculating the dep_attrs for future resources. This is
required when get_attr functions are nested in the template.
Change-Id: I23efcc091eae53470f7f9cb3ca21e09f00f43808
Partially-Implements: blueprint stack-definition
Before returning the stack outputs, update the StackDefinition with the
resource data needed to resolve them. This will enable us to switch to
resolving outputs via the StackDefinition in a subsequent patch.
Change-Id: Ide3920385d9c4841c18024e1eb1456eed5c8eef5
Partially-Implements: blueprint stack-definition
We ought to iterate over the dependency list in the validate_template call,
to check for any circular dependencies. This check was removed by
d12cbe7959 in order to avoid trying to
calculate implicit dependencies added by resource plugins (as e.g. many
Neutron resources do) at a time when we don't have sufficient data to do a
good job of it anyway.
However, the previous patch d12cbe7959 split
apart the calculation of explicit and implicit dependencies, so we can
easily do this while still checking for circular references in the
explicit dependencies. This patch splits the dependency calculation into
two phases - the first using only data available from the template, and the
second querying the resources for implicit dependencies.
Use strict_validate = False as the criterion for when to avoid calculating
implicit dependencies, since this corresponds exactly to when we don't have
enough data to do so.
Change-Id: I21c63dcc8d1cad20dbc237b472670753779b0ff8
Closes-bug: #1691575
When we choose only validate resource template, and external resource
id was set, we should consider that external resource template is
valid (since we only required `external_id` from that resource
template format). So the result of this validate will be None
(template validate passed).
Closes-Bug: #1702977
Change-Id: I8b33c957a7185a0f52356f412b13609ba1a7b469
When we read from the LaunchConfig in order to e.g. scale up an
InstanceGroup or AWS AutoscalingGroup, we want to use the properties as
they were last set by a stack update. We don't want to re-resolve functions
using live data, since any changes would result in changes to existing
members when we generate the template for scaling up, and that can possibly
result in the replacement of said existing members.
Instead, use the property values that are stored in the database from the
last update. In the case of a stack update in convergence, we need to load
them when doing Stack.resource_by_refid(), since they're not included in
the cache_data.
Change-Id: I9da5efb2559f10b2dfe44281e2ba1e615a8c618b
Partially-Implements: blueprint stack-definition
When showing the resource list during a stack update, the patch
5ce238fb17 inadvertently raises a KeyError
when a resource in the new template hasn't been created yet. This resolves
the problem.
Change-Id: If0784156211b21d8ef7047a7082d1b48e977252d
Related-Bug: #1703703
Closes-Bug: #1705170
In convergence, there can be multiple versions of the same resource
present in a stack at one time. The fix for bug 1301320 was supposed to
make data for all versions available from the resource list API. And
while it does go through all of the resources in the database and create
Resource objects for each one, they were each created with the correct
version of the resource definition but DB data from the latest resource.
(Only the name is passed to the Resource object, it has to figure out
which database row to load data from itself - and it will choose the
same one every time.)
With this change, we always load the correct DB data into the
newly-created Resource object.
Change-Id: I6b9d1b86b3dbf767bccebddd78275bbf0933029a
Closes-Bug: #1704194
The Stack._find_filtered_resources() method returns Resource objects for
all resources associated with the Stack, regardless of whether they are
current (present in the template; latest version in the case of
convergence). To do this, it previously created a new Resource object
for every resource found in the database.
However, for those resources which *are* current this is unnecessary. We
can access the Resource object simply through self.resources. It turns
out this is necessary for obtaining the required_by list for legacy
stacks, because only the Resources obtained from self.resources also
appear in the Dependencies graph obtained from self.dependencies. The
required_by list is read when listing or showing resources, which would
either return an empty list or fail for legacy stacks.
This patch also makes the Resource.required_by() method more robust in
its error handling.
Change-Id: Id438336e5c88dc7c2d168ba01ee703faa17e8b8e
Closes-Bug: #1703703
Related-Bug: #1523748
We use StackValidationFailed in many different scenarios and
the the message is at times extremely unhelpful, specifically
when the validation error is deep in a nested stack.
Change-Id: I0183bdf81442e62325a427b4eec5c4cd9b7cb91f
Closes-Bug: #1686360
The patch at I1cb321a3878a0abce9b41832f76bf77c25bf7cb4 properly deleted
the snapshots from the database, but as delete in convergence sets the
template to an empty template, stack.resources is empty. This works
around the problem by deleting the snapshots beforehand.
Related-Bug: #1508299
Change-Id: Id1c2c1a293fdcda07c527f29fedc00b716b303bc
It's possibile for resource listing of a legacy stack with an update
in progress to have resources in db but not in template.
Probably it would not hurt to filter those out.
Change-Id: I84e56ba88270079acbfcdc6227c4263b39956fe6
Closes-Bug: #1653990
Handle the restore operation as a normal convergence update instead of a
legacy one.
Change-Id: I6ee46cdf7a8fdf89c58c9812d08af21c97fb0f9e
Related-Bug: #1687006
Validating a large stack locks up a whole worker until it is complete,
because it doesn't co-operate in greenlet's co-operative multithreading.
With this change, we now yield the flow of control between each resource,
so that validation can't monopolise the process.
Validation is high priority because it happens synchronously, but it is
probably worth the trade-off to avoid blocking anything else happening on
the same worker.
Change-Id: I8514640135a915791a0905eea40ef70876ae1cb1
This was introduced in 0bc4de65e3 to try
to ensure that we never got a negative difference in times, which would
trigger a bug in our handling of time differences.
Now that bug 1688327 is fixed, there's no need for this complexity any
longer.
Change-Id: Iff76ff5ab2b1d642d464f111e78e248faf6ac77c
Related-Bug: #1688327
Related-Bug: #1493166
Since we're comparing local time to database time, we need to correctly
handle negative offsets to account for clock skew. The datetime.timedelta
class always reports a positive number of seconds, but with a possibly
negative number of *days*. Therefore, take the days into account.
Change-Id: I4422e4cf41cb57cdc89548d01b0abc27cda914ef
Closes-Bug: #1688327
Many database IDs (Resource, WatchRule) are integers, so 0 is a valid ID
and evaluating it in a boolean context may give the wrong result for the
first entry in the table. Even for the ones that aren't (e.g. Stack) it's
better to explicitly compare to None.
Change-Id: Id95eeb5cd0f9cac82937fae48122ce5fa90ca48d
Why pass a parameter to a method to influence what it does when you can set
some state on the object that the programmer always has to keep in their
head to figure out what any given call will do?
Change-Id: I020238de0a351dd2eaf51c6f970ae36ad0f931be
This reverts commit f94d76cb32.
All stack deployments in TripleO are taking about 10
minutes longer, so 20 minutes for ovb-updates job.
We found out that it's partially related to this patch.
See details in the bug report.
https://bugs.launchpad.net/tripleo/+bug/1684272
Change-Id: I80ced2dbc9127bc1501f8729eb52195c0d206813
Partial-Bug: #1684272
When an update fails, we may have copy some chunk of resources or
parameters to the new template. If the version was updated and the new
resources require the version, this can lead to a state where the stack
is in an usable state. This synchronizes the version when a failure
happens.
Change-Id: I2faf8f3541fc800ea61c417e5575f4a56a83665b
Closes-Bug: #1620696
Before validating resources, generate placeholder NodeData for them in the
StackDefinition. Currently, all attributes are given a value of None
(consistent with how the get_attr intrinsic functions substitute them when
the resource state indicates that the attributes are not valid now).
Reference IDs are generated as usual (since the logic for what to return
when the state indicates the data are not valid is contained in the
resource plugins).
In the long term, this should help us to remove the state-checking logic
from the intrinsic functions.
In the short term, this allows us to validate template data that is parsed
against the StackDefinition (rather than the Stack), since it gives us a
list of valid attribute names.
In the medium term, this should give us a place to substitute in more
sophisticated placeholder values to do better validation.
Change-Id: I154ff0cd019d279379886fccbd708cf0d39ce53f
In convergence stacks, we obtain the NodeData for the resources the current
resource depends on from the RPC message triggering the resource check. For
the legacy path, this change updates the NodeData in the StackDefinition
after each resource is created or updated.
This means that the legacy and convergence paths will be able to access
data about other resources in essentially the same way.
Change-Id: I61c61745d864de99b0127f4103a6c3a83379c516
Partially-Implements: blueprint stack-definition