Commit Graph

30 Commits

Author SHA1 Message Date
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
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
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
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
rabi 6e8e631d34 Organize heat-agents docs
This organizes the heat-agents docs as per the openstackdocs format.
Also adds the team and repository tags.

Change-Id: I997dd3f52c9cd9f8ea274520e033de3ef582401c
2017-08-04 08:52:27 +05:30
Thomas Herve 25cd394bbe Add py3.5 support
Depends-On: Ibda89b467b461b8833515f50a0cf1cc3064cb917
Change-Id: I68ac61b7d1d0d180a7696ae2f0f75b1a4a969995
2017-07-17 13:43:43 +00:00
Jenkins 887f06ab4c Merge "Don't fail on warnings in docker-cmd" 2017-05-30 20:55:01 +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
Jiri Stransky 3eb25e7df3 Don't fail on warnings in docker-cmd
It seems that during the undercloud upgrade heat-config can be empty,
and if it is, the heat-config-docker-cmd hook returns 1 and makes
os-refresh-config fail, consequently failing the undercloud upgrade.

Change-Id: Ia62e40e05f46e7e4450c6b230ddeec9b861e99bd
Related-Bug: #1648249
Closes-Bug: #1692899
2017-05-23 16:08:10 +02:00
Jenkins 251d7ab695 Merge "docker-cmd: simplify building config ids for delete" 2017-04-03 16:18:54 +00:00
Jenkins e8c10b6263 Merge "Split string commands on whitespace" 2017-04-03 08:54:22 +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
Steve Baker 2a59451676 docker-cmd: simplify building config ids for delete
Only the config IDs are needed so only build and pass a list of IDs
instead of parsed configs.

Change-Id: I7dfc1728ddd80b2dbd6652c838c11ab2414ad7b7
2017-03-29 13:57:45 +13: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 8b7af86908 Refactor docker cmd arg building
This change refactors the arg building so that the logic is contained
in dedicated functions for 'docker run' and 'docker exec', instead of
being split between the main loop and docker_arg_map.

Minor changes in behaviour which don't affect the tests include:
- No longer force ascii encoding of arg values
- Extra check to ensure the command is a list before extending cmd
- Remove the unicode/empty-string list value check

Change-Id: I09f3d2ee98020de556a3d0aa72721fe8b7420b2a
2017-02-20 16:27:54 -05: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
Steve Baker 2a230b2c6e Refactor docker invocation into function
This will be useful later when many docker calls are made to
introspect currently running containers.

Change-Id: Id2b0a74c974b2844b21061fb54b498bf88c50435
2017-02-02 16:02:31 +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 a49c1f6d5e Merge "Prevent trailing whitespace in rendered JSON" 2017-01-23 21:36:44 +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
Martin André 9ce538b6ff Prevent trailing whitespace in rendered JSON
On python <3.4 the separator for json.dump() defaulted to (', ', ': ')
which may cause trailing whitespaces in rendered JSON files when used
with indent. This change sets the separator to (',', ': ') to prevent
trailing whitespaces with older versions of python.

See https://docs.python.org/2/library/json.html#basic-usage

Change-Id: I81fabd54659bdb28da43fb4900f19dd94a70336c
2017-01-13 12:07:51 +01:00
Dan Prince 1e87454039 Add 'exec' support to docker cmd
We've got a few cases where running an exec in an
already running container would be useful. This patch
adds a new action 'exec' support so that you can used a
named docker containers.

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

Change-Id: I2f8640232442f559206b2972117b74eec6d2c086
2017-01-11 18:40:23 -05:00
Thomas Herve d802d177c7 Move elements at the top level 2017-01-04 16:57:10 +01:00