Commit Graph

93 Commits

Author SHA1 Message Date
Takashi Kajinami 7e7171755a Bump hacking
hacking 3.0.x is too old.

Change-Id: I62dca32f2a81f6e39ff2522a20d9a82dcb41e649
2024-01-17 01:25:05 +09:00
Zuul 277ec355dc Merge "remove unicode prefix from code" 2023-12-19 13:46:31 +00:00
Takashi Kajinami 0235a734e4 Fix python shebang
The current shebang requires /usr/bin/python which is not available in
Ubuntu Jammy by default.

Change-Id: I142472eb20591fc752db9ca06c954d362cd3e405
2023-10-17 16:02:20 +00:00
niuke 3c801fe8ca remove unicode prefix from code
Change-Id: Id83c2e9b0cb06f2aae051ba95fa7d0e7545f848e
2022-08-18 15:37:07 +08:00
likui 7b525d8eeb Remove six
The Python 2.7 Support has been support
So remove hacking rules for compatibility between python 2 and 3

Change-Id: Ia0fe869b80d330551cc9dac06c23001faf229542
2020-11-16 06:52:57 +00:00
likui a1d32e9f0e replace imp module
The imp module is deprecated since version 3.4

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

Change-Id: I7d0f07c338693b7c76e16359a36bfcf579ed0ee6
2020-10-23 17:19:11 +08:00
Ghanshyam Mann 41167c4ae5 [goal] Migrate testing to ubuntu focal
As per victoria cycle testing runtime and community goal[1]
we need to migrate upstream CI/CD to Ubuntu Focal(20.04).

Fixing:
- bug#1886298
Bump the lower constraints for required deps which added python3.8 support
in their later version.

Also skip salt tests before we fix salt failing issues.
Sync salt requirelemt with global requirement to support py3.8.

Story: #2007865
Task: #40186

[1] https://governance.openstack.org/tc/goals/selected/victoria/migrate-ci-cd-jobs-to-ubuntu-focal>

Change-Id: I482ac98bc56f0e3cfb8b767f47649da11ed1afab
2020-09-11 12:05:36 +00:00
ricolin 7872568ed9 Revert "docker-cmd hook switch to the paunch library"
This reverts commit 33241a84c1

The requirements check fails since
Ia4e086162e65a51af417a8b381ae898c95966a09 removed paunch as valid
dependency.

Since Paunch is retired, this patch propose to switch to use docker cli
for docker cmd hook and remove any dependency to Paunch.

Change-Id: I9c3839e551259fb85b191a27fa054c605964f30e
2020-06-11 17:31:17 +08:00
Andreas Jaeger 5999d35cb6 Update hacking for Python3
The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.

Fix problems found.

Remove hacking and friends from lower-constraints, they are not needed
for installation.

Change-Id: I035eb2f83c289ff994c77b02d5f3c2f9a0d583d8
2020-04-07 11:41:45 +02:00
Andreas Jaeger dd7efc353e [ussuri][goal] Drop python 2.7 support and testing
OpenStack is dropping the py2.7 support in ussuri cycle.

Complete discussion & schedule can be found in
- http://lists.openstack.org/pipermail/openstack-discuss/2019-October/010142.html
- https://etherpad.openstack.org/p/drop-python2-support

Ussuri Communtiy-wide goal:
https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html

Cleanup tox.ini, remove install_command and add constraints to deps.
Replace mock with unittest.mock.

Change-Id: Idcac0b5310adf27a35223273bd54a4a154988c9b
2020-02-04 20:21:41 +01:00
Zuul d3e644b856 Merge "Additional tests for region_name" 2019-09-04 05:57:45 +00:00
Steve Baker 9a399e7c35 Rewrite test_hook_docker_cmd to avoid paunch internals
This test breaks frequently as it is asserting the docker calls which
paunch is making internally. These calls are changing often, as paunch
is in active development.

This change rewrites the test to be a unit test of hook-docker-cmd.py
specifically, with calls to paunch.apply mocked out.

Change-Id: Ieeef3e5916e46d006a358f132bbd64f3960e1fcd
Task: 36342
2019-08-26 11:40:21 +12:00
Zane Bitter a825d9b283 Additional tests for region_name
Test that everything works when region_name is not supplied or is None.

Change-Id: Ia880447e27289fdb488a90d77a5a1f5f3d8b8c61
Task: 33529
Related-Bug: #1830967
2019-05-29 15:54:45 -04:00
Rabi Mishra 1c768de175 Fix docker-cmd hook unit tests
Change-Id: I526c0334e18b05f017fa9960f837c61a03506ce9
Depends-On: https://review.openstack.org/634383
2019-02-12 12:10:06 +05:30
ricolin 0f0fc98bd9 Skip Hook docker cmd test until story 2004926 fixed
Change-Id: If982f3a9d769698b177071dba1364255676c6647
Task: #29443
2019-02-12 14:03:19 +08:00
Thomas Herve 637e4260ca Change docker-cmd for recent paunch changes
paunch was changed to support podman, it breaks some arguments, and
expectations in our tests. Let's fix that.

Change-Id: I7127cc2edb9af785e0533e0a1e5f2608417390e7
2018-11-06 15:21:32 +01:00
Feilong Wang fdd6a5f537 Add region_name for heat-config-notify
Now there is no region name when heat-config-notify try to get the
heat endpoint or zaqar endpoint. As a result, it could be a wrong
one returned from Keystone because there is no region name specified.
This patch fixes it.

Please refer Iec6f3606c9fdf8474f393b0990356f34d38bcf75 for the change
in Heat.

Please refer I88182a9a9af74e9760b2ec9b500971f06293f0b8 for the change
in occ.

Task: 22720
Story: 2002781

Change-Id: I8e0518fa61e237ec055834dd4bebe0fc87cd6627
2018-07-08 08:20:34 +12:00
Steven Hardy e2f3df268d Expose error when a hook script raises an exception
Currently this can result in errors being ignored so it's not clear
to the user that something failed.

Change-Id: Idf6badecbfa72150f3506a485eed9ae2cb5858f7
Story: 2002084
Task: 19753
2018-05-22 17:53:53 +01:00
Zuul 7fe19b8ed8 Merge "Chef: Fix encoding and Python 3 support" 2018-05-10 13:02:37 +00:00
Zuul 10f28e8491 Merge "Use six StringIO" 2018-03-26 20:29:31 +00:00
ricolin def252eb96 Use six StringIO
On python3, sys.stdin/stdout are Text-mode streams, which can be
approximated with io.StringIO. On python2, there's no real
distinction between Text-mode and Binary-mode (except for line
endings, which sys.stdin/stdout also treat as Text-mode). Hence,
there's no need to explicitly use io.BytesIO on python2.
StringIO.StringIO is equally or more representative of how the
mocked streams behave.

Therefore, just use six.StringIO instead of different types for
python2 vs. python3.

Change-Id: Ib80e10a40e68ece946b344ce7bcfba5e182ce848
2018-03-26 20:09:41 +00:00
Zane Bitter e140f0319e Chef: Fix encoding and Python 3 support
Allow the Chef hook to run under Python 3, and gracefully handle invalid
UTF-8 sequences in the output from the command in the same manner we
have in other hooks since 25cd394bbe.

Change-Id: I087cd93a78c48f01bdebbd1e630cb8701dc9477a
Closes-Bug: #1709026
2018-03-26 16:01:03 -04:00
Zuul 40cd47d30a Merge "Fix heat docker agent tests" 2018-02-02 04:46:32 +00:00
ricolin ed766c5fac Fix heat docker agent tests
Test for Docker agent seems broken after paunch release.

Change-Id: I10213ee8274ccd8222e5e4855d1b4144a4d39c47
2018-02-01 23:26:29 +08:00
Zuul 421b971169 Merge "Make chef agent tests more reliable" 2017-12-29 09:19:41 +00:00
Thomas Herve 62c4511eeb Make chef agent tests more reliable
They fail sometimes on py35 because we rely on dict order in asserts.
Let's remove that and load json instead.

Change-Id: I7bff32028cc130128ce05c151534c85ef99607d5
2017-11-23 13:25:57 +01:00
Alex Schultz 756fcafdf0 Retry logic for url request in heat-config-notify
Adds retry logic for software deployments using the url signals
to ensure that requests are retried if network connection issues
occur or a 500, 502, 503, or 504 is returned by the http or https
endpoint.

Note: this does not add retry logic to heatclient or zaqarclient
if they are used for signaling.

Change-Id: I82dff4a4b9fac05c5ec649db3eb379bdec71e208
Related-Bug: #1731540
2017-11-14 21:10:34 +00:00
Thomas Herve 25cd394bbe Add py3.5 support
Depends-On: Ibda89b467b461b8833515f50a0cf1cc3064cb917
Change-Id: I68ac61b7d1d0d180a7696ae2f0f75b1a4a969995
2017-07-17 13:43:43 +00:00
Jenkins 964c41e3ab Merge "Remove color from puppet output" 2017-06-21 22:21:39 +00:00
Steve Baker 33241a84c1 docker-cmd hook switch to the paunch library
paunch is a library and utility which is now in OpenStack
under the TripleO umbrella. It contains the logic currently in the
docker-cmd hook exposed as a python library and command utility.

This change switches the docker-cmd hook to paunch.

Asserting --label arguments has been split out from the other docker
run arguments so that paunch can add new --label arguments in future
releases without breaking these tests.

paunch-1.1.0 has just been release which contains new idempotency
behaviour, so the tests have been modified to work with the new docker
command behaviour that idempotency requires.

Change-Id: I884c38ade06ab0e01432837c43f29b123e65fa3c
2017-05-24 12:29:38 +12:00
Thomas Herve ffe8ea7d9a Remove color from puppet output
This passes --color false to the puppet apply call, removing color from
puppet output. As it's meant to be passed to software deployment, it
will make it more readable.

Change-Id: I12074f06f6bdbddc8706426b1515b3db4affb2f7
2017-05-17 09:46:06 +02:00
Steve Baker 3a86f8789c Set the config ID as an ansible variable
This change sets the ansible variable called heat_config_id to the
'id' value of the heat config data.

This will be useful in some playbooks to make idempotency decisions.

Change-Id: I5f03e012b2fb97cc0076c886ca7bd3f284d19032
2017-04-28 13:33:27 +12:00
Jenkins e8c10b6263 Merge "Split string commands on whitespace" 2017-04-03 08:54:22 +00:00
Jenkins 5dcddacdcd Merge "Add env_file for docker hook" 2017-03-31 15:24:49 +00:00
Bogdan Dobrelya 5a694739a4 Add env_file for docker hook
Add docker hook for environment files.
Some containerized services need to accept environment
files and cannot be configured otherwise, for example
Etcd key-value storage.

Partial-bug: #1668938

Change-Id: I228b5f9ee67215ae742760d449b9cd8a4b9543d0
Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
2017-03-30 15:38:30 +02:00
David Moreau-Simard 0d52f5b047 Add a generic option to configure Ansible callbacks in the agent
Ansible callbacks [1] are used to hook into Ansible events such
as running tasks. They can be used to alter the behavior of Ansible
like providing helpful console output for tasks.

[1]: http://docs.ansible.com/ansible/dev_guide/developing_plugins.html#callback-plugins

Change-Id: I7e2c041ca359ab63140102c9d4a22914d9add228
2017-03-17 11:01:20 -04:00
Steve Baker 7ea3e3aec6 Split string commands on whitespace
This change supports specifying commands as strings by spliting the
string into a list using python's default whitespace string split().

This will handle simple string commands but not cases like
quoted/escaped spaces. Other cases can be handled by specifying the
command as a list instead.

Change-Id: Icc4eebe324a4e6a7dd06f697ef16d38777f90861
2017-03-02 15:03:46 +13:00
Steve Baker 5c33973e7f Rename containers to their desired name
Once 50-heat-config-docker-cmd (or any other container managing tool)
deletes existing containers, 50-heat-config-docker-cmd can check if
any containers do not have their desired name, and rename them where
possible.

Change-Id: I1bc9fa4880b2487b15e28da67c4fad79312d54ad
2017-02-20 14:24:55 -05:00
Steve Baker 4d34592f4a Ensure unique container names
When a container already exists with the desired name, the container
name has a random suffix attached to it so that it can still be run.
This ensures containers are always created regardless of other running
containers.

Since the name may not be as expected, the exec action needs an extra
lookup to attempt to discover the actual name, falling back to the
requested name if the lookup fails.

Since there is a container_name label set with the desired
name, the next patch in this series modifies 50-heat-config-docker-cmd
to rename containers to their desired name when possible.

Change-Id: Ibd97f52811f653295559d000487d2c50a7c67ece
2017-02-20 14:24:55 -05:00
Steve Baker b6dfdf8e99 Delete containers based on labels, not state files
This rewrites 50-heat-docker-cmd to not require any state directory to
make decisions on what containers to delete. Instead the labels on the
running containers are used to make decisions on when containers
should be deleted.

This also changes the behaviour to ignore the config name and strictly
use the config id, so all containers for a given config id are deleted
when that config no longer appears in the list of configs. This maps
correctly to heat's software deployment model and allows a future
change to properly implement replace_on_change[1] behaviour.

Containers created with an older docker-cmd (or create any other way)
will never be deleted by 50-heat-config-docker-cmd. This will result
in docker run failures when unique container names are re-used and
will require manual intervention to delete the old containers before
continuing.

[1] http://docs.openstack.org/developer/heat/template_guide/openstack.html#OS::Heat::SoftwareConfig-prop-inputs-*-replace_on_change

Change-Id: Iaf56c2b5fcb4969ce09480742f13a04d35bd2bae
2017-02-20 14:24:50 -05:00
Steve Baker d30fa94af4 Set labels on containers managed by docker-cmd
Docker labels are metadata associated with running containers. This
change sets labels which will allow the correct lifecycle decisions
to be made by the docker-cmd hook about which containers are managed
by heat and when specific containers should be deleted.

Associating these labels now will also allow the os-refresh-config
50-heat-config-docker-cmd to be rewritten to not require a directory
to store state, and instead get all of the current state information
from 'docker ps' and 'docker inspect' calls.

Change-Id: I967df26c8b0661413dc504c45d1764d23f895530
2017-02-15 09:44:33 +13:00
Jenkins 301db11253 Merge "Implement start_order for containers" 2017-01-30 02:04:35 +00:00
Flavio Percoco 4f6010da30 Implement start_order for containers
Allow for ordering containers execution within the same step. This hook
uses `start_order` and it defaults to 0.

Co-Authored-by: Ian Main <imain@redhat.com>

Change-Id: Ib0804ee622e2889e6c18a76f07a194490f4721d4
2017-01-27 17:46:41 +00:00
Jenkins 0b92c781d0 Merge "Add --skip-tags to ansible hook" 2017-01-24 03:20:30 +00:00
Jenkins a49c1f6d5e Merge "Prevent trailing whitespace in rendered JSON" 2017-01-23 21:36:44 +00:00
Jenkins 43e63cf6ff Merge "Cleanup temp files in tests" 2017-01-23 21:36:39 +00:00
Steven Hardy 93517603eb Add --skip-tags to ansible hook
We recently added --tags, but exposing --skip-tags can also
be useful (we want to use it in tripleo to optionally skip
validation tasks when resuming upgrades from a failed state).

Change-Id: I18214f80be9f3ad6c2d385fc00f3b786d3e7dda3
2017-01-23 16:30:28 +00:00
Jenkins 540b31413d Merge "Add exit_codes option to docker-cmd hook" 2017-01-17 14:39:13 +00:00
Dan Prince 408c3f8642 Add exit_codes option to docker-cmd hook
Some command we need to run with 'exec' or 'run' have custom
exit codes that are valid if the command completes sucessfully.
This patch adds an 'exit_codes' option which takes an array
of integers that are meant to represent the valid exit codes
for this hook. If for example 0 or 1 is meant to be considered
success you can specify:
 exit_codes: [0,1]

Previously an non-zero exit code would always fail this hook.

Change-Id: Ia6ca4b01982a0b33b26eca2a907d9d9f87c19922
2017-01-16 09:02:10 -05:00
Dan Prince ccbfef9cb4 Fix: all containers are being set privileged
This patch simplies the check for privileged so that we treat
it as a pass through string. Previously we were converting
to a string before doing the boolean check which was causing
all containers to get set to --privileged true.

Change-Id: Ibe2221abf9616c1c54acecf7c18ae36e2c07576c
2017-01-16 08:40:56 -05:00