Commit Graph

756 Commits

Author SHA1 Message Date
Takashi Kajinami 813f229a08 Bump hacking
hacking 3.0.x is too old.

Also fix failures detected by the new hacking version.

Change-Id: Ifccbbf2ff7b0824d2079937526d3eee1c536349b
2024-01-18 19:04:37 +09:00
Brendan Shephard 5e14163f9c Allow multiple required_service_extension
In some cases, some resources may require more than
one service_extension. In this case, we should allow
resources to define a list of required resources.

Change-Id: Iee0104a741cc050047824d23b8ab5ee9871c4f28
2022-04-26 06:37:05 +00:00
rabi b1fe9752b0 Fix for tenacity 8.0.1
Use retry_state parameter that contains all information about
current retry invocation in the prepare_attempt callback.

Change-Id: Ib47b6335b591850965132448befb7b3dbe31984a
Task: 44471
2022-02-11 18:13:37 +05:30
ramishra bfbaab107d Don't update status for replaced resource
With I04e7ad90944c2d03ce0e59ba16af9d60d6e01222 we allowed
update of previously-existing resource if replacement
creation has failed during last update. However, we force
update the status of the existing resource to 'COMPLETE'.
Therefore, in the next update if properties/type has not
changed for the resource it won't try to update/replace
the previously existing resource resulting in false positive
of stack updated successfully.

Task: 42194
Change-Id: Icc90a921ec67e49aec2c4acfad72235c57c78421
2021-04-01 19:39:58 +05:30
Stephen Finucane 57e9754093 Switch to collections.abc.*
The abstract base classes previously defined in 'collections' were moved
to 'collections.abc' in 3.3. The aliases will be removed in 3.10.
Preempt this change now with a simple find-replace:

  $ ag -l 'collections.($TYPES)' | \
      xargs sed -i 's/\(collections\)\.\($TYPES\)/\1.abc.\2/g'

Where $TYPES is the list of moved ABCs from [1].

[1] https://docs.python.org/3/library/collections.abc.html

Change-Id: Ia282479bb1d466bd2189ebb21b51d91e89b9581e
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-02-01 11:15:59 +00:00
Zuul 9f931119ba Merge "Deprecate wrappertask decorator" 2020-07-06 06:00:17 +00:00
Zuul aa54b13bcf Merge "Ensure use of stored properties in actions" 2020-05-04 23:19:57 +00:00
Zuul 0e7d99ac3f Merge "Logging Consistency" 2020-05-04 10:12:13 +00:00
Zuul bdaf258c00 Merge "Check external resources after creation" 2020-05-01 06:39:46 +00:00
Andreas Jaeger 37a83c1ede pep8: Enable E226
Enable
"E226 missing whitespace around arithmetic operator"

And fix problems encountered.

Change-Id: I90cbf6220f487a0808e13cd3998c8127be563498
2020-04-30 16:42:53 +02:00
Zane Bitter 2c58017a14 Deprecate wrappertask decorator
Now that we only support Python 3, use the 'yield from' keyword instead
of the @wrappertask decorator for calling co-routines from a co-routine.
This should greatly simplify backtraces when calling nested co-routines.

Change-Id: If9beaff74cf4facbc4aa4b30f31a3a087bdcad8a
2020-04-30 09:56:20 -04:00
Zane Bitter 0e2174fb3e Ensure use of stored properties in actions
This patch gives effect to the change intended to be implemented in
6bc25ef0e0.

The Resource._do_action() method is a co-routine, but in a number of
less common resource actions, we simply return the result of calling it
rather than turning the action into a wrappertask and yielding it. This
works fine (the action returns a generator; the caller doesn't care
where it came from) and reduces the amount of wrapper frames on the
stack.

However, in most cases we want the stored properties to be used while
calling _do_action(). However, to ensure that they are actually in place
when the co-routine is running, we must yield rather than return the
generator. In the suspend, resume, snapshot, and chekc actions we were
not doing that. It is not known whether any resource types are actually
accessing properties during any of these actions.

Change-Id: I2b2a87ccf1988821a250373fea261c1850e5c51b
2020-04-30 09:51:40 -04:00
Zane Bitter 5c6038f7a2 Check external resources after creation
The method Resource.check() is not a generator function, but it does
return a generator in most cases. Simply calling the function does not
cause the resource to actually be checked. Only in the case where the
resource did not provide a handle_check() method would it do anything at
all - and in that case it simply changes the state to CHECK_COMPLETE.

Yield the generator function so that the resource will actually be
checked if the resource type supports it.

Change-Id: I2a78b6f6235529a95838307e3d38731d31ff5c4b
Task: 37828
2020-04-30 09:51:40 -04:00
Marc Methot 156f276665 Logging Consistency
A simple matter of having log lines fit
with all the others. It will now match the
ambiguous standard.

Also change comments inline to alias with log fixes.

Change-Id: I4a2ed6134f70c2965811f75ccb6ab8221fa0e960
Story: #2007319
Task: 38830
2020-04-27 06:34:31 +00:00
Hervé Beraud 0de03fcdd3 Remove six and python 2.7 full support
Six is in use to help us to keep support for python 2.7.
Since the ussuri cycle we decide to remove the python 2.7
support so we can go ahead and also remove six usage from
the python code.

Review process and help
-----------------------
Removing six introduce a lot of changes and an huge amount of modified files
To simplify reviews we decided to split changes into several patches to avoid
painful reviews and avoid mistakes.

To review this patch you can use the six documentation [1] to obtain help and
understand choices.

Additional informations
-----------------------
Changes related to 'six.b(data)' [2]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

six.b [2] encode the given datas in latin-1 in python3 so I did the same
things in this patch.

Latin-1 is equal to iso-8859-1 [3].

This encoding is the default encoding [4] of certain descriptive HTTP
headers.

I suggest to keep latin-1 for the moment and to move to another encoding
in a follow-up patch if needed to move to most powerful encoding (utf8).

HTML4 support utf8 charset and utf8 is the default charset for HTML5 [5].

Note that this commit message is autogenerated and not necesserly contains
changes related to 'six.b'

[1] https://six.readthedocs.io/
[2] https://six.readthedocs.io/#six.b
[3] https://docs.python.org/3/library/codecs.html#standard-encodings
[4] https://www.w3schools.com/charsets/ref_html_8859.asp
[5] https://www.w3schools.com/html/html_charset.asp

Patch 7 of a serie of 28 patches

Change-Id: I7c50cb96b2991dcf843ac99199b31fb3c8a899fa
2020-04-23 14:49:12 +02:00
Andreas Jaeger 57eb87149f Fix hacking warnings
Fix some warnings found by hacking and enable them again.

Change-Id: Ia09de4d0fda752a009b9246b4e6d485601cd9562
2020-04-16 06:43:27 +00:00
Rabi Mishra 9e80518b90 Handle OS::Mistral::Workflow resource replacement properly
OS::Mistral::Workflow resource creates a mistral workflow with
a unique name (resource_id). We replace FAILED resources by
default and replace wont work in this case as it will try to
use the same workflow name for the replacement resouce, if the
'name' property is provided.

If the workflow does not exist/deleted using mistral api directly,
it would create a replacement resource, but it would delete the
workflow when cleaning up the old resource. So we would endup
with a replacement resource without any backing workflow.

This adds a new resource attribute ``always_replace_on_check_failed``
and overrides needs_replace_failed() for OS::Mistral::Workflow.

Task: 38855
Change-Id: Ia0812b88cae363dfa25ccd907ecbe8b86f5b1a23
2020-02-25 08:37:16 +05:30
Zane Bitter 8cd6a06736 Pre-empt in-progress nested stack updates on new update
If the parent resource of a nested stack is locked due to an IN_PROGRESS
update, cancel the nested stack update (which will result in the parent
resource being marked FAILED and releasing the lock so that the new
traversal can begin acting on it). This also cancels all descendants of
the nested stack.

This means that a concurrent update no longer gets blocked at a nested
stack boundary until the previous update has finished.

Change-Id: I5f14453ebab75d89672c6eea12de46d48a5147f3
Task: 17760
2019-10-29 23:15:31 -04:00
Zuul 1eca082f43 Merge "Allow update of previously-replaced resources" 2019-03-12 13:14:55 +00:00
Rabi Mishra 1cd8ce37c0 Don't translate event reason when adding hook event
We don't seem to do it anywhere else. TripleO uses hook
reason string comparsion which does not work if
internationalized.

Story: #2005035
Task: 29524
Change-Id: I3e8f4587966969084cbf1e38406cd3cff23eb9a6
2019-02-16 09:11:07 +05:30
Zane Bitter e34da89290 Allow update of previously-replaced resources
The convergence prototype ignored checks of resources that had previously
been replaced by another resource. However, it turns out that this was
unnecessary in the final version of the prototype:

e9d2f833a5

Keeping this limitation prevents us from allowing users to roll back to a
previously-existing resource if creating the replacement fails, other than
by using the automated rollback mechanism (which is special-cased).

Since the graph for the traversal is calculated at the start of the update,
there's no need to limit which nodes are allowed to be checked. Only the
selected resource will have an is_update=True node in the traversal graph.
Removing this additional restriction allows us to improve the algorithm
that chooses which resource to update. Since a new traversal ID is stored
before we calculate the traversal graph, we can guarantee that no new
resource checks will start (though some may still be happening) while the
algorithm is choosing, so there's no danger of it picking a resource that
later gets replaced.

Since we're no longer treating automatic rollback as a special case, reset
the replaced_by field whenever we update a previously-replaced resource.

Change-Id: I04e7ad90944c2d03ce0e59ba16af9d60d6e01222
Story: #2003579
Task: 26197
2019-01-29 16:40:40 +13:00
Zane Bitter 8260579b2c Streamline conversion of resources to convergence
Use a single write to the database to convert each resource. Add a
method to the versioned object class that encapsulates the DB-specific
information, and get rid of the Resource.set_requires() classmethod that
just calls a method on the versioned object instance that's passed to
it.

Change-Id: Ieca7e0f0642c38c44fb8d7729333a0ccd93c9cb4
2018-12-17 16:59:25 +13:00
Zuul 011b0db85d Merge "Unit tests: Fix mock errors with too few side effects" 2018-09-04 17:18:27 +00:00
Zane Bitter 38fad07c0a Unit tests: Fix mock errors with too few side effects
When a mock hasn't been provided with a long-enough list of side-effects
for the number of times it is called, it raises StopIteration (instead
of something sensible like AssertionError). Prior to Python 3.7, this
exception could bubble up until it just stopped a task. (In Python 3.7
it will eventually be caught and turned into a RuntimeError.)

To ensure that any errors of this sort are not handled silently, and to
enable us to test for them prior to using Python 3.7, catch any
StopIteration errors coming from plugin-provided non-generator functions
and convert them to RuntimeError exceptions.

This reveals many errors in the unit tests, many introduced in the
process of converting from mox to mock, which are also fixed by this
patch.

Change-Id: I5a1eff6b704dff7c17edcbbe58cdbc380ae6abc9
Story: #2003412
Task: 24553
2018-08-10 17:25:13 -04:00
Zuul b0a72cba7a Merge "Don't change INIT_COMPLETE resources to CHECK_COMPLETE" 2018-08-09 11:36:23 +00:00
Zuul fc79d56d9d Merge "Drop ceilometerclient requirement" 2018-08-09 10:21:34 +00:00
Pradeep Kilambi 6b821beb4e Drop ceilometerclient requirement
ceilometerclient is dead in queens cycle, lets drop the
integration and remove the requirement.

Change-Id: I5267746e63fd27ad0ce8e36fb843efd4988d6eb7
2018-08-08 16:56:41 +00:00
Zane Bitter cd5c0583d6 Don't change INIT_COMPLETE resources to CHECK_COMPLETE
We assume that only resources that are in INIT_COMPLETE need to be created
(as opposed to updated). If we run a check on a resource that hasn't been
created yet, we shouldn't change the status to CHECK_COMPLETE because
thereafter we will try to update it.

Changing the status to CHECK_FAILED (as we do if the resource supports
handle_check()) is OK because the resource will get replaced on the next
update anyway.

Change-Id: Iaadf3b57b0e8edc76d338c017dbd05bf2a37698f
Story: #2003062
Task: 23102
2018-08-06 09:25:18 -04:00
Zane Bitter 8ca06cfeaf Store resources convergence-style in stack check/suspend/resume
If there are resources in a template that don't exist in the database at
the time of a stack check (or suspend or resume) operation, running the
stack check will cause them to be stored in the database. Since these
operations have not been converted to convergence (story 1727142), they do
not set the current_template_id as a convergence update would. If this
occurs then the stack will be unrecoverable.

To avoid this, when convergence is enabled store any missing resources in
the same manner that a convergence update would, prior to running the stack
check/suspend/resume.

Just in case, make sure the stack doesn't get stuck if we do end up in the
wrong state, by not trying to load a template with None as an ID.

Change-Id: Iedba67c5de39dc2d58938da5505dda5dd147c130
Story: #2003062
Task: 23101
2018-08-06 09:25:18 -04:00
rabi 26f8a70a1e Ignore RESOLVE translation errors when deleting resources
Sometimes when deleting resources, we use parent resources in api
calls. If the parent resource is deleted then the children
could be assumed to be deleted. So ignore those translations errors
and return unresolved values when accessing properties.

Change-Id: I2392b5c46920ac6da518fe33bdcba3e7a9fe17a8
Story: #1747836
Task: 23278
2018-07-30 15:37:06 +05:30
rabi 8c39f3bb8b Ignore RESOLVE translation errors when translating before_props
When translating name to id, if we don't find the resource it's
better to ignore the error and return the non-translated value
for before properties.

Change-Id: Ic25c35098cff8b68e184a336b21f2e8df70bb1ee
Story: #2003015
Task: 23103
2018-07-30 14:15:52 +05:30
Zuul c427f30b65 Merge "Retry resource creation on conflict" 2018-07-25 00:41:25 +00:00
Zuul bea5084ea8 Merge "Docs: Eliminate warnings in docs generation" 2018-07-23 16:43:14 +00:00
Zuul 3e371fa8c5 Merge "Refactor condition expression in Resource.load()" 2018-07-13 06:17:10 +00:00
Zuul ab55acf43b Merge "Handle resource plugins without default_client_name" 2018-07-05 18:13:59 +00:00
Zane Bitter 76ec5af884 Docs: Eliminate warnings in docs generation
Fix all of the existing sphinx warnings, and treat warnings as errors in
future.

Change-Id: I084ef65da1002c47c7d05a68d6f0268b89a36a7a
Depends-On: https://review.openstack.org/553639
Depends-On: https://review.openstack.org/559348
2018-06-21 16:38:47 -04:00
Zane Bitter c4318eff65 Retry resource creation on conflict
If resource creation fails with an HTTP Conflict error, this is presumably
due to a race condition with one of the underlying services. In this case,
allow Heat to retry the resource creation so that hopefully in most cases
the user will never have to deal with the error.

Change-Id: I301bb28231fcdc249f86ec1a2f09cb993023785b
Story: #1745010
Task: 17344
2018-06-18 16:42:37 -04:00
Zane Bitter 714d9eea4c Handle resource plugins without default_client_name
We want to be able to call is_not_found() or is_conflict() from the client
plugin from the Resource class, regardless of what resource plugin is
implementing the resource type. This is only possible when the
default_client_name is set, which is optional for plugins to do. As a
result, when handling an exception we need to check explicitly that there
is a default_client name, or (as in Resource.validate_external()) we will
get an assertion error.

To simplify the avoidance of programming errors, define a
_default_client_plugin() method that *always* returns a plugin whose
is_not_found() and is_conflict() methods can be called.

Change-Id: I1005397187457d9be42ba86096644dd17287d0e7
Story: #1745024
Task: 17677
2018-06-18 16:41:43 -04:00
Zane Bitter 83da046447 Stop using needed_by field in resource
During the original prototype development, I missed the fact that the
`needed_by` field of a resource is no longer needed for the actual
convergence algorithm:

c74aac1f07

Since nothing is using this any more, we can avoid an unnecessary DB
write to every resource at the start of a stack update. For now, just
write an empty list to that field any time we are storing the resource.
In future, we can stop reading/writing the field altogether, and in a
subsequent release we could drop the column from the DB.

Change-Id: I0c9c77f395db1131b16e5bd9d579a092033400b1
2018-06-14 19:34:59 -04:00
Zane Bitter ff4ff1b839 Calculate convergence required_by from graph in Stack
In convergence, resources can continue to exist in the database that are
no longer part of the latest template. When calling
Resource.required_by() for such resources, we still want to get a list
of those resources that depend on them. Previously we did this using the
`needed_by` field in the resource. Since this is the only actual use of
needed_by, get the information from the Stack's convergence graph
instead (which is generated from the resources' `requires` field and
ignores `needed_by`). This eliminates any risk that the `requires` and
`needed_by` fields get out of sync, and allows us to get rid of
`needed_by` altogether in the future.

Change-Id: I64e1c66817151f39829d5c54b0a740c56ea8edad
2018-06-14 17:21:01 -04:00
Zuul fdfa5e6a65 Merge "Keep old files in file map for rolling update" 2018-05-18 08:04:20 +00:00
Zuul 1b23f171f7 Merge "Reset resource replaced_by field for rollback" 2018-05-15 10:19:05 +00:00
Zuul f30900e11f Merge "Make resource requires a set instead of a list" 2018-05-14 19:55:56 +00:00
Zuul 7206d88869 Merge "Create replacement resources with correct requires" 2018-05-14 19:55:54 +00:00
Zuul 99eb84d3a3 Merge "Calculate the requires list in check_resource" 2018-05-14 13:10:57 +00:00
Zuul 02c9905960 Merge "Don't pass input_data to Resource.delete_convergence()" 2018-05-14 05:54:31 +00:00
Zuul 7e15bc21d3 Merge "Increment resource atomic key when storing attributes" 2018-05-12 04:34:34 +00:00
rabi a544ce43dc Reset resource replaced_by field for rollback
We seem to leave replaced_by field of a resource after rollback
(if a stack cancel is issued before the replacement
resource is added to the stack). This in turn results in the
stack getting stuck in IN_PROGRESS for further updates.

Change-Id: I3361ad90e303d24a16a943408fe0f6c406cf785f
Co-Authored-By: Zane Bitter <zbitter@redhat.com>
Task: #19582
Story: #2001974
2018-05-11 15:04:53 +05:30
rabi d42f863dc5 Keep old files in file map for rolling update
We would need old resource definitions when doing rolling update of certain
group resources like RG/ASG. Therefore update the file map with the files
from old template.

Change-Id: I8f880e5b23c25159ecab1c63b594329d8df33973
Closes-Bug: #1765454
Task: #17360
Story: #1765454
2018-05-11 12:02:01 +05:30
Zane Bitter 68c21e01aa Make resource requires a set instead of a list
Since we are doing set operations on it, make the 'requires' attribute of a
Resource a set and only convert to/from a list when loading/storing. To
avoid churn in the database, sort the list when storing it.

Change-Id: I137fae8ae630eb235d7811fcba81738d828e6a1e
2018-04-25 16:32:02 -04:00