From cea076f3795010f3b870371d2ebd5d906ec81202 Mon Sep 17 00:00:00 2001 From: Michal Nasiadka Date: Thu, 27 Apr 2023 11:41:55 +0200 Subject: [PATCH] Introduce oneshot docker_restart_policy docker_restart_policy: no causes systemd units to not get created and we use it in CI to disable restarts on services. Introducing oneshot policy to not create systemd unit for oneshot containers (those that are running bootstrap tasks, like db bootstrap and don't need a systemd unit), but still create systemd units for long lived containers but with Restart=No. Change-Id: I9e0d656f19143ec2fcad7d6d345b2c9387551604 --- ansible/library/kolla_docker.py | 2 ++ ansible/module_utils/kolla_docker_worker.py | 6 +++--- ansible/module_utils/kolla_podman_worker.py | 4 ++-- ansible/roles/aodh/tasks/bootstrap_service.yml | 2 +- ansible/roles/barbican/tasks/bootstrap_service.yml | 2 +- ansible/roles/blazar/tasks/bootstrap_service.yml | 2 +- ansible/roles/ceilometer/tasks/bootstrap_service.yml | 2 +- ansible/roles/cinder/tasks/bootstrap_service.yml | 2 +- ansible/roles/cinder/tasks/upgrade.yml | 2 +- ansible/roles/cloudkitty/tasks/bootstrap_service.yml | 2 +- ansible/roles/cyborg/tasks/bootstrap_service.yml | 2 +- ansible/roles/designate/tasks/bootstrap_service.yml | 2 +- ansible/roles/freezer/tasks/bootstrap_service.yml | 2 +- ansible/roles/glance/tasks/bootstrap_service.yml | 2 +- ansible/roles/glance/tasks/rolling_upgrade.yml | 6 +++--- ansible/roles/gnocchi/tasks/bootstrap_service.yml | 2 +- ansible/roles/heat/tasks/bootstrap_service.yml | 2 +- ansible/roles/horizon/tasks/bootstrap_service.yml | 2 +- ansible/roles/ironic/tasks/bootstrap_service.yml | 6 +++--- ansible/roles/ironic/tasks/rolling_upgrade.yml | 2 +- ansible/roles/keystone/handlers/main.yml | 4 ++-- ansible/roles/keystone/tasks/bootstrap_service.yml | 4 ++-- ansible/roles/magnum/tasks/bootstrap_service.yml | 2 +- ansible/roles/manila/tasks/bootstrap_service.yml | 2 +- ansible/roles/mariadb/handlers/main.yml | 2 +- ansible/roles/mariadb/tasks/backup.yml | 2 +- ansible/roles/mariadb/tasks/bootstrap_cluster.yml | 2 +- ansible/roles/mariadb/tasks/post-upgrade.yml | 2 +- ansible/roles/mariadb/tasks/recover_cluster.yml | 4 ++-- ansible/roles/masakari/tasks/bootstrap_service.yml | 2 +- ansible/roles/mistral/tasks/bootstrap_service.yml | 2 +- ansible/roles/murano/tasks/bootstrap_service.yml | 2 +- ansible/roles/neutron/tasks/bootstrap_service.yml | 2 +- ansible/roles/neutron/tasks/rolling_upgrade.yml | 4 ++-- ansible/roles/nova-cell/tasks/bootstrap_service.yml | 2 +- ansible/roles/nova-cell/tasks/create_cells.yml | 4 ++-- ansible/roles/nova-cell/tasks/get_cell_settings.yml | 2 +- ansible/roles/nova-cell/tasks/online_data_migrations.yml | 2 +- ansible/roles/nova/tasks/bootstrap_service.yml | 2 +- ansible/roles/nova/tasks/map_cell0.yml | 2 +- ansible/roles/nova/tasks/online_data_migrations.yml | 2 +- ansible/roles/nova/tasks/upgrade.yml | 2 +- ansible/roles/octavia/tasks/bootstrap_service.yml | 2 +- ansible/roles/placement/tasks/bootstrap_service.yml | 2 +- ansible/roles/placement/tasks/upgrade.yml | 2 +- ansible/roles/rabbitmq/tasks/bootstrap.yml | 2 +- ansible/roles/sahara/tasks/bootstrap_service.yml | 2 +- ansible/roles/senlin/tasks/bootstrap_service.yml | 2 +- ansible/roles/skyline/tasks/bootstrap_service.yml | 2 +- ansible/roles/solum/tasks/bootstrap_service.yml | 2 +- ansible/roles/tacker/tasks/bootstrap_service.yml | 2 +- ansible/roles/trove/tasks/bootstrap_service.yml | 2 +- ansible/roles/vitrage/tasks/bootstrap_service.yml | 2 +- ansible/roles/watcher/tasks/bootstrap_service.yml | 2 +- ansible/roles/zun/tasks/bootstrap_service.yml | 2 +- .../notes/restart-policy-oneshot-8dc9aa2f79cbfa19.yaml | 9 +++++++++ tests/kolla_docker_tests/test_docker_worker.py | 6 +++--- tests/kolla_docker_tests/test_podman_worker.py | 4 ++-- tests/test_kolla_docker.py | 1 + 59 files changed, 83 insertions(+), 71 deletions(-) create mode 100644 releasenotes/notes/restart-policy-oneshot-8dc9aa2f79cbfa19.yaml diff --git a/ansible/library/kolla_docker.py b/ansible/library/kolla_docker.py index f2be716759..e7d4105b24 100644 --- a/ansible/library/kolla_docker.py +++ b/ansible/library/kolla_docker.py @@ -180,6 +180,7 @@ options: choices: - no - on-failure + - oneshot - always - unless-stopped restart_retries: @@ -314,6 +315,7 @@ def generate_module(): restart_policy=dict(required=False, type='str', choices=[ 'no', 'on-failure', + 'oneshot', 'always', 'unless-stopped']), restart_retries=dict(required=False, type='int'), diff --git a/ansible/module_utils/kolla_docker_worker.py b/ansible/module_utils/kolla_docker_worker.py index d3224f160b..87beccb72a 100644 --- a/ansible/module_utils/kolla_docker_worker.py +++ b/ansible/module_utils/kolla_docker_worker.py @@ -354,7 +354,7 @@ class DockerWorker(ContainerWorker): self.changed = True options = self.build_container_options() self.dc.create_container(**options) - if self.params.get('restart_policy') != 'no': + if self.params.get('restart_policy') != 'oneshot': self.changed |= self.systemd.create_unit_file() def recreate_or_restart_container(self): @@ -397,7 +397,7 @@ class DockerWorker(ContainerWorker): if not container['Status'].startswith('Up '): self.changed = True - if self.params.get('restart_policy') == 'no': + if self.params.get('restart_policy') == 'oneshot': self.dc.start(container=self.params.get('name')) else: self.systemd.create_unit_file() @@ -466,7 +466,7 @@ class DockerWorker(ContainerWorker): msg="No such container: {}".format(name)) else: self.changed = True - if self.params.get('restart_policy') != 'no': + if self.params.get('restart_policy') != 'oneshot': self.systemd.create_unit_file() if not self.systemd.restart(): self.module.fail_json( diff --git a/ansible/module_utils/kolla_podman_worker.py b/ansible/module_utils/kolla_podman_worker.py index c0bf751811..dd215174e9 100644 --- a/ansible/module_utils/kolla_podman_worker.py +++ b/ansible/module_utils/kolla_podman_worker.py @@ -535,7 +535,7 @@ class PodmanWorker(ContainerWorker): if container.status != 'running': self.changed = True - if self.params.get('restart_policy') == 'no': + if self.params.get('restart_policy') == 'oneshot': container = self.check_container() container.start() else: @@ -583,7 +583,7 @@ class PodmanWorker(ContainerWorker): elif not (container.status == 'exited' or container.status == 'stopped'): self.changed = True - if self.params.get('restart_policy') != 'no': + if self.params.get('restart_policy') != 'oneshot': self.systemd.create_unit_file() self.systemd.stop() else: diff --git a/ansible/roles/aodh/tasks/bootstrap_service.yml b/ansible/roles/aodh/tasks/bootstrap_service.yml index b3be49e933..dcb06a71ba 100644 --- a/ansible/roles/aodh/tasks/bootstrap_service.yml +++ b/ansible/roles/aodh/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_aodh" - restart_policy: no + restart_policy: oneshot volumes: "{{ aodh_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[aodh_api.group][0] }}" diff --git a/ansible/roles/barbican/tasks/bootstrap_service.yml b/ansible/roles/barbican/tasks/bootstrap_service.yml index 3e05024410..bc11c17226 100644 --- a/ansible/roles/barbican/tasks/bootstrap_service.yml +++ b/ansible/roles/barbican/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_barbican" - restart_policy: no + restart_policy: oneshot volumes: "{{ barbican_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[barbican_api.group][0] }}" diff --git a/ansible/roles/blazar/tasks/bootstrap_service.yml b/ansible/roles/blazar/tasks/bootstrap_service.yml index ac90c642f3..476fe1f890 100644 --- a/ansible/roles/blazar/tasks/bootstrap_service.yml +++ b/ansible/roles/blazar/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_blazar" - restart_policy: no + restart_policy: oneshot volumes: "{{ blazar_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[blazar_api.group][0] }}" diff --git a/ansible/roles/ceilometer/tasks/bootstrap_service.yml b/ansible/roles/ceilometer/tasks/bootstrap_service.yml index c5cb839201..cadd038a38 100644 --- a/ansible/roles/ceilometer/tasks/bootstrap_service.yml +++ b/ansible/roles/ceilometer/tasks/bootstrap_service.yml @@ -16,7 +16,7 @@ labels: BOOTSTRAP: name: "bootstrap_ceilometer" - restart_policy: no + restart_policy: oneshot volumes: "{{ ceilometer_notification.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[ceilometer_notification.group][0] }}" diff --git a/ansible/roles/cinder/tasks/bootstrap_service.yml b/ansible/roles/cinder/tasks/bootstrap_service.yml index 3ee985c7f1..ba23da879f 100644 --- a/ansible/roles/cinder/tasks/bootstrap_service.yml +++ b/ansible/roles/cinder/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_cinder" - restart_policy: no + restart_policy: oneshot volumes: "{{ cinder_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[cinder_api.group][0] }}" diff --git a/ansible/roles/cinder/tasks/upgrade.yml b/ansible/roles/cinder/tasks/upgrade.yml index a30a1c726b..8336548364 100644 --- a/ansible/roles/cinder/tasks/upgrade.yml +++ b/ansible/roles/cinder/tasks/upgrade.yml @@ -30,7 +30,7 @@ labels: BOOTSTRAP: name: "bootstrap_cinder" - restart_policy: no + restart_policy: oneshot volumes: "{{ cinder_api.volumes }}" run_once: True delegate_to: "{{ groups[cinder_api.group][0] }}" diff --git a/ansible/roles/cloudkitty/tasks/bootstrap_service.yml b/ansible/roles/cloudkitty/tasks/bootstrap_service.yml index ed2e566e2a..117bdce7d5 100644 --- a/ansible/roles/cloudkitty/tasks/bootstrap_service.yml +++ b/ansible/roles/cloudkitty/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_cloudkitty" - restart_policy: no + restart_policy: oneshot volumes: "{{ cloudkitty_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[cloudkitty_api.group][0] }}" diff --git a/ansible/roles/cyborg/tasks/bootstrap_service.yml b/ansible/roles/cyborg/tasks/bootstrap_service.yml index bbba4b8510..5ea8f3e114 100644 --- a/ansible/roles/cyborg/tasks/bootstrap_service.yml +++ b/ansible/roles/cyborg/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_cyborg" - restart_policy: no + restart_policy: oneshot volumes: "{{ cyborg_api.volumes }}" run_once: True delegate_to: "{{ groups[cyborg_api.group][0] }}" diff --git a/ansible/roles/designate/tasks/bootstrap_service.yml b/ansible/roles/designate/tasks/bootstrap_service.yml index e3d13510bb..3cf5bbc269 100644 --- a/ansible/roles/designate/tasks/bootstrap_service.yml +++ b/ansible/roles/designate/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_designate" - restart_policy: no + restart_policy: oneshot volumes: "{{ designate_central.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[designate_central.group][0] }}" diff --git a/ansible/roles/freezer/tasks/bootstrap_service.yml b/ansible/roles/freezer/tasks/bootstrap_service.yml index a70b29454e..1559c7ad29 100644 --- a/ansible/roles/freezer/tasks/bootstrap_service.yml +++ b/ansible/roles/freezer/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_freezer" - restart_policy: no + restart_policy: oneshot volumes: "{{ freezer_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[freezer_api.group][0] }}" diff --git a/ansible/roles/glance/tasks/bootstrap_service.yml b/ansible/roles/glance/tasks/bootstrap_service.yml index a92555fb5b..e56c1072b4 100644 --- a/ansible/roles/glance/tasks/bootstrap_service.yml +++ b/ansible/roles/glance/tasks/bootstrap_service.yml @@ -31,7 +31,7 @@ labels: BOOTSTRAP: name: "bootstrap_glance" - restart_policy: no + restart_policy: oneshot volumes: "{{ glance_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ glance_api_hosts[0] }}" diff --git a/ansible/roles/glance/tasks/rolling_upgrade.yml b/ansible/roles/glance/tasks/rolling_upgrade.yml index 6e3fe4840f..313dd88b30 100644 --- a/ansible/roles/glance/tasks/rolling_upgrade.yml +++ b/ansible/roles/glance/tasks/rolling_upgrade.yml @@ -43,7 +43,7 @@ labels: BOOTSTRAP: name: "bootstrap_glance" - restart_policy: no + restart_policy: oneshot volumes: "{{ glance_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ glance_api_hosts[0] }}" @@ -64,7 +64,7 @@ labels: BOOTSTRAP: name: "bootstrap_glance" - restart_policy: no + restart_policy: oneshot volumes: "{{ glance_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ glance_api_hosts[0] }}" @@ -96,7 +96,7 @@ labels: BOOTSTRAP: name: "bootstrap_glance" - restart_policy: no + restart_policy: oneshot volumes: "{{ glance_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ glance_api_hosts[0] }}" diff --git a/ansible/roles/gnocchi/tasks/bootstrap_service.yml b/ansible/roles/gnocchi/tasks/bootstrap_service.yml index 0992575a59..12e242be6c 100644 --- a/ansible/roles/gnocchi/tasks/bootstrap_service.yml +++ b/ansible/roles/gnocchi/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_gnocchi" - restart_policy: no + restart_policy: oneshot volumes: "{{ gnocchi_api.volumes }}" run_once: True delegate_to: "{{ groups[gnocchi_api.group][0] }}" diff --git a/ansible/roles/heat/tasks/bootstrap_service.yml b/ansible/roles/heat/tasks/bootstrap_service.yml index dc7038c12f..8abb52f5d6 100644 --- a/ansible/roles/heat/tasks/bootstrap_service.yml +++ b/ansible/roles/heat/tasks/bootstrap_service.yml @@ -24,7 +24,7 @@ labels: BOOTSTRAP: name: "bootstrap_heat" - restart_policy: no + restart_policy: oneshot volumes: "{{ heat_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[heat_api.group][0] }}" diff --git a/ansible/roles/horizon/tasks/bootstrap_service.yml b/ansible/roles/horizon/tasks/bootstrap_service.yml index 213d71fab1..397bed9df0 100644 --- a/ansible/roles/horizon/tasks/bootstrap_service.yml +++ b/ansible/roles/horizon/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_horizon" - restart_policy: no + restart_policy: oneshot volumes: "{{ horizon.volumes }}" run_once: True delegate_to: "{{ groups[horizon.group][0] }}" diff --git a/ansible/roles/ironic/tasks/bootstrap_service.yml b/ansible/roles/ironic/tasks/bootstrap_service.yml index 318f418cf9..c8293d4bc3 100644 --- a/ansible/roles/ironic/tasks/bootstrap_service.yml +++ b/ansible/roles/ironic/tasks/bootstrap_service.yml @@ -18,7 +18,7 @@ labels: BOOTSTRAP: name: "bootstrap_ironic" - restart_policy: no + restart_policy: oneshot volumes: "{{ ironic_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[ironic_api.group][0] }}" @@ -39,7 +39,7 @@ labels: BOOTSTRAP: name: "bootstrap_ironic_inspector" - restart_policy: no + restart_policy: oneshot volumes: "{{ ironic_inspector.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[ironic_inspector.group][0] }}" @@ -62,6 +62,6 @@ labels: BOOTSTRAP: name: "bootstrap_ironic_tftp" - restart_policy: no + restart_policy: oneshot volumes: "{{ ironic_tftp.volumes }}" when: inventory_hostname in groups[ironic_tftp.group] diff --git a/ansible/roles/ironic/tasks/rolling_upgrade.yml b/ansible/roles/ironic/tasks/rolling_upgrade.yml index ad39fba27a..52a3cdda01 100644 --- a/ansible/roles/ironic/tasks/rolling_upgrade.yml +++ b/ansible/roles/ironic/tasks/rolling_upgrade.yml @@ -42,7 +42,7 @@ labels: BOOTSTRAP: name: "bootstrap_ironic" - restart_policy: no + restart_policy: oneshot volumes: "{{ ironic_api.volumes }}" run_once: True delegate_to: "{{ groups[ironic_api.group][0] }}" diff --git a/ansible/roles/keystone/handlers/main.yml b/ansible/roles/keystone/handlers/main.yml index 570833d2d3..d57036e533 100644 --- a/ansible/roles/keystone/handlers/main.yml +++ b/ansible/roles/keystone/handlers/main.yml @@ -18,7 +18,7 @@ labels: KOLLA_UPGRADE: name: "init_upgrade_database" - restart_policy: no + restart_policy: oneshot volumes: "{{ service.volumes | reject('equalto', '') | list }}" dimensions: "{{ service.dimensions }}" run_once: True @@ -90,7 +90,7 @@ labels: KOLLA_UPGRADE: name: "finish_upgrade_database" - restart_policy: no + restart_policy: oneshot volumes: "{{ service.volumes | reject('equalto', '') | list }}" dimensions: "{{ service.dimensions }}" run_once: True diff --git a/ansible/roles/keystone/tasks/bootstrap_service.yml b/ansible/roles/keystone/tasks/bootstrap_service.yml index 02f7abf71e..73cd6bd930 100644 --- a/ansible/roles/keystone/tasks/bootstrap_service.yml +++ b/ansible/roles/keystone/tasks/bootstrap_service.yml @@ -45,7 +45,7 @@ labels: BOOTSTRAP: name: "bootstrap_keystone" - restart_policy: no + restart_policy: oneshot volumes: "{{ keystone.volumes | reject('equalto', '') | list }}" run_once: True @@ -67,7 +67,7 @@ keystone-manage --config-file /etc/keystone/keystone.conf fernet_setup --keystone-user {{ keystone_username }} --keystone-group {{ keystone_groupname }}' name: "bootstrap_keystone_fernet" - restart_policy: no + restart_policy: oneshot volumes: "{{ keystone_fernet.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups['keystone'][0] }}" diff --git a/ansible/roles/magnum/tasks/bootstrap_service.yml b/ansible/roles/magnum/tasks/bootstrap_service.yml index fe79cbeef2..9b4563ab53 100644 --- a/ansible/roles/magnum/tasks/bootstrap_service.yml +++ b/ansible/roles/magnum/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_magnum" - restart_policy: no + restart_policy: oneshot volumes: "{{ magnum_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[magnum_api.group][0] }}" diff --git a/ansible/roles/manila/tasks/bootstrap_service.yml b/ansible/roles/manila/tasks/bootstrap_service.yml index 13786be068..c820d54f51 100644 --- a/ansible/roles/manila/tasks/bootstrap_service.yml +++ b/ansible/roles/manila/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_manila" - restart_policy: no + restart_policy: oneshot volumes: "{{ manila_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[manila_api.group][0] }}" diff --git a/ansible/roles/mariadb/handlers/main.yml b/ansible/roles/mariadb/handlers/main.yml index a327668235..87b01ade08 100644 --- a/ansible/roles/mariadb/handlers/main.yml +++ b/ansible/roles/mariadb/handlers/main.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "{{ service.container_name }}" - restart_policy: no + restart_policy: oneshot volumes: "{{ service.volumes }}" dimensions: "{{ service.dimensions }}" listen: Bootstrap MariaDB cluster diff --git a/ansible/roles/mariadb/tasks/backup.yml b/ansible/roles/mariadb/tasks/backup.yml index c57f673fc7..8095285e84 100644 --- a/ansible/roles/mariadb/tasks/backup.yml +++ b/ansible/roles/mariadb/tasks/backup.yml @@ -8,7 +8,7 @@ detach: False image: "{{ mariabackup_image_full }}" name: "mariabackup" - restart_policy: no + restart_policy: oneshot remove_on_exit: True environment: BACKUP_TYPE: "{{ mariadb_backup_type }}" diff --git a/ansible/roles/mariadb/tasks/bootstrap_cluster.yml b/ansible/roles/mariadb/tasks/bootstrap_cluster.yml index e9efe4391d..866cf609fd 100644 --- a/ansible/roles/mariadb/tasks/bootstrap_cluster.yml +++ b/ansible/roles/mariadb/tasks/bootstrap_cluster.yml @@ -17,7 +17,7 @@ labels: BOOTSTRAP: name: "bootstrap_mariadb" - restart_policy: no + restart_policy: oneshot volumes: "{{ service.volumes }}" notify: - Bootstrap MariaDB cluster diff --git a/ansible/roles/mariadb/tasks/post-upgrade.yml b/ansible/roles/mariadb/tasks/post-upgrade.yml index cb07e7d569..da40c677c4 100644 --- a/ansible/roles/mariadb/tasks/post-upgrade.yml +++ b/ansible/roles/mariadb/tasks/post-upgrade.yml @@ -19,6 +19,6 @@ labels: UPGRADE: name: "upgrade_mariadb" - restart_policy: no + restart_policy: oneshot volumes: "{{ service.volumes }}" no_log: true diff --git a/ansible/roles/mariadb/tasks/recover_cluster.yml b/ansible/roles/mariadb/tasks/recover_cluster.yml index fc3f1c600a..118af30935 100644 --- a/ansible/roles/mariadb/tasks/recover_cluster.yml +++ b/ansible/roles/mariadb/tasks/recover_cluster.yml @@ -38,7 +38,7 @@ labels: BOOTSTRAP: name: mariadb_wsrep_recovery - restart_policy: no + restart_policy: oneshot volumes: "{{ mariadb_service.volumes }}" - name: Copying MariaDB log file to /tmp @@ -120,7 +120,7 @@ labels: BOOTSTRAP: name: "{{ mariadb_service.container_name }}" - restart_policy: no + restart_policy: oneshot volumes: "{{ mariadb_service.volumes }}" when: - bootstrap_host is defined diff --git a/ansible/roles/masakari/tasks/bootstrap_service.yml b/ansible/roles/masakari/tasks/bootstrap_service.yml index c5782dc184..cc8d6745ca 100644 --- a/ansible/roles/masakari/tasks/bootstrap_service.yml +++ b/ansible/roles/masakari/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_masakari" - restart_policy: "no" + restart_policy: "oneshot" volumes: "{{ masakari_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[masakari_api.group][0] }}" diff --git a/ansible/roles/mistral/tasks/bootstrap_service.yml b/ansible/roles/mistral/tasks/bootstrap_service.yml index f37ae7fca0..562f00f9c0 100644 --- a/ansible/roles/mistral/tasks/bootstrap_service.yml +++ b/ansible/roles/mistral/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_mistral" - restart_policy: no + restart_policy: oneshot volumes: "{{ mistral_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[mistral_api.group][0] }}" diff --git a/ansible/roles/murano/tasks/bootstrap_service.yml b/ansible/roles/murano/tasks/bootstrap_service.yml index c1acf18ee2..c4c14cec16 100644 --- a/ansible/roles/murano/tasks/bootstrap_service.yml +++ b/ansible/roles/murano/tasks/bootstrap_service.yml @@ -12,7 +12,7 @@ labels: BOOTSTRAP: name: "bootstrap_murano" - restart_policy: no + restart_policy: oneshot volumes: - "{{ node_config_directory }}/murano-api/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" diff --git a/ansible/roles/neutron/tasks/bootstrap_service.yml b/ansible/roles/neutron/tasks/bootstrap_service.yml index 6c212bd690..2a61c86c42 100644 --- a/ansible/roles/neutron/tasks/bootstrap_service.yml +++ b/ansible/roles/neutron/tasks/bootstrap_service.yml @@ -15,7 +15,7 @@ labels: BOOTSTRAP: name: "bootstrap_neutron" - restart_policy: no + restart_policy: oneshot volumes: "{{ neutron_server.volumes }}" run_once: True delegate_to: "{{ groups[neutron_server.group][0] }}" diff --git a/ansible/roles/neutron/tasks/rolling_upgrade.yml b/ansible/roles/neutron/tasks/rolling_upgrade.yml index 20c523bbde..17801c7b86 100644 --- a/ansible/roles/neutron/tasks/rolling_upgrade.yml +++ b/ansible/roles/neutron/tasks/rolling_upgrade.yml @@ -27,7 +27,7 @@ labels: UPGRADE: name: "bootstrap_neutron" - restart_policy: no + restart_policy: oneshot volumes: "{{ neutron_server.volumes }}" run_once: True delegate_to: "{{ groups['neutron-server'][0] }}" @@ -79,7 +79,7 @@ labels: UPGRADE: name: "bootstrap_neutron" - restart_policy: no + restart_policy: oneshot volumes: "{{ neutron_server.volumes }}" run_once: True delegate_to: "{{ groups['neutron-server'][0] }}" diff --git a/ansible/roles/nova-cell/tasks/bootstrap_service.yml b/ansible/roles/nova-cell/tasks/bootstrap_service.yml index 46b95d66be..23b6b4c50b 100644 --- a/ansible/roles/nova-cell/tasks/bootstrap_service.yml +++ b/ansible/roles/nova-cell/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "nova_cell_bootstrap" - restart_policy: no + restart_policy: oneshot volumes: "{{ nova_cell_bootstrap_default_volumes + nova_cell_bootstrap_extra_volumes }}" register: bootstrap_result changed_when: bootstrap_result.stdout | default("") | length > 0 diff --git a/ansible/roles/nova-cell/tasks/create_cells.yml b/ansible/roles/nova-cell/tasks/create_cells.yml index a7b901eb01..2300098e06 100644 --- a/ansible/roles/nova-cell/tasks/create_cells.yml +++ b/ansible/roles/nova-cell/tasks/create_cells.yml @@ -16,7 +16,7 @@ labels: BOOTSTRAP: name: "create_cell_nova" - restart_policy: no + restart_policy: oneshot volumes: "{{ nova_cell_bootstrap_default_volumes + nova_cell_bootstrap_extra_volumes }}" register: nova_cell_create changed_when: @@ -42,7 +42,7 @@ labels: BOOTSTRAP: name: "create_cell_nova" - restart_policy: no + restart_policy: oneshot volumes: "{{ nova_cell_bootstrap_default_volumes + nova_cell_bootstrap_extra_volumes }}" register: nova_cell_updated changed_when: diff --git a/ansible/roles/nova-cell/tasks/get_cell_settings.yml b/ansible/roles/nova-cell/tasks/get_cell_settings.yml index b1cac0cb47..bbeed06441 100644 --- a/ansible/roles/nova-cell/tasks/get_cell_settings.yml +++ b/ansible/roles/nova-cell/tasks/get_cell_settings.yml @@ -12,7 +12,7 @@ labels: BOOTSTRAP: name: "nova_list_cells" - restart_policy: no + restart_policy: oneshot volumes: "{{ nova_cell_bootstrap_default_volumes + nova_cell_bootstrap_extra_volumes }}" register: existing_cells_list changed_when: false diff --git a/ansible/roles/nova-cell/tasks/online_data_migrations.yml b/ansible/roles/nova-cell/tasks/online_data_migrations.yml index a9a3260edf..b8b329a88b 100644 --- a/ansible/roles/nova-cell/tasks/online_data_migrations.yml +++ b/ansible/roles/nova-cell/tasks/online_data_migrations.yml @@ -14,6 +14,6 @@ labels: BOOTSTRAP: name: "nova_cell_online_data_migrations" - restart_policy: "no" + restart_policy: "oneshot" volumes: "{{ nova_cell_bootstrap_default_volumes + nova_cell_bootstrap_extra_volumes }}" when: inventory_hostname == groups[nova_cell_conductor_group][0] diff --git a/ansible/roles/nova/tasks/bootstrap_service.yml b/ansible/roles/nova/tasks/bootstrap_service.yml index 0d18e1b289..146ad02967 100644 --- a/ansible/roles/nova/tasks/bootstrap_service.yml +++ b/ansible/roles/nova/tasks/bootstrap_service.yml @@ -16,7 +16,7 @@ labels: BOOTSTRAP: name: "nova_api_bootstrap" - restart_policy: no + restart_policy: oneshot volumes: "{{ nova_api_bootstrap_default_volumes + nova_api_bootstrap_extra_volumes }}" register: bootstrap_result changed_when: bootstrap_result.stdout | default("") | length > 0 diff --git a/ansible/roles/nova/tasks/map_cell0.yml b/ansible/roles/nova/tasks/map_cell0.yml index 04da40bd3f..5e7ddcffd6 100644 --- a/ansible/roles/nova/tasks/map_cell0.yml +++ b/ansible/roles/nova/tasks/map_cell0.yml @@ -13,7 +13,7 @@ labels: BOOTSTRAP: name: "nova_api_map_cell0" - restart_policy: no + restart_policy: oneshot volumes: "{{ nova_api_bootstrap_default_volumes + nova_api_bootstrap_extra_volumes }}" register: map_cell0 changed_when: diff --git a/ansible/roles/nova/tasks/online_data_migrations.yml b/ansible/roles/nova/tasks/online_data_migrations.yml index 2ab13de078..999e3b98a6 100644 --- a/ansible/roles/nova/tasks/online_data_migrations.yml +++ b/ansible/roles/nova/tasks/online_data_migrations.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "nova_api_online_data_migrations" - restart_policy: "no" + restart_policy: "oneshot" volumes: "{{ nova_api_bootstrap_default_volumes + nova_api_bootstrap_extra_volumes }}" run_once: true delegate_to: "{{ groups[nova_api.group][0] }}" diff --git a/ansible/roles/nova/tasks/upgrade.yml b/ansible/roles/nova/tasks/upgrade.yml index 1cc8f29581..1e80b2abe1 100644 --- a/ansible/roles/nova/tasks/upgrade.yml +++ b/ansible/roles/nova/tasks/upgrade.yml @@ -14,7 +14,7 @@ labels: UPGRADE: name: "nova_upgrade_checks" - restart_policy: no + restart_policy: oneshot volumes: "{{ nova_api_default_volumes + nova_api_extra_volumes }}" run_once: True register: nova_upgrade_check_stdout diff --git a/ansible/roles/octavia/tasks/bootstrap_service.yml b/ansible/roles/octavia/tasks/bootstrap_service.yml index ce5ce74635..fee1594878 100644 --- a/ansible/roles/octavia/tasks/bootstrap_service.yml +++ b/ansible/roles/octavia/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_octavia" - restart_policy: no + restart_policy: oneshot volumes: "{{ octavia_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[octavia_api.group][0] }}" diff --git a/ansible/roles/placement/tasks/bootstrap_service.yml b/ansible/roles/placement/tasks/bootstrap_service.yml index 6669701b8c..1f347a9f41 100644 --- a/ansible/roles/placement/tasks/bootstrap_service.yml +++ b/ansible/roles/placement/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_placement" - restart_policy: no + restart_policy: oneshot volumes: "{{ placement_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[placement_api.group][0] }}" diff --git a/ansible/roles/placement/tasks/upgrade.yml b/ansible/roles/placement/tasks/upgrade.yml index 7e98e01270..26aa26b9dc 100644 --- a/ansible/roles/placement/tasks/upgrade.yml +++ b/ansible/roles/placement/tasks/upgrade.yml @@ -28,7 +28,7 @@ labels: BOOTSTRAP: name: "bootstrap_placement" - restart_policy: no + restart_policy: oneshot volumes: "{{ placement_api.volumes }}" run_once: True delegate_to: "{{ groups[placement_api.group][0] }}" diff --git a/ansible/roles/rabbitmq/tasks/bootstrap.yml b/ansible/roles/rabbitmq/tasks/bootstrap.yml index 13e0933970..ceeca47009 100644 --- a/ansible/roles/rabbitmq/tasks/bootstrap.yml +++ b/ansible/roles/rabbitmq/tasks/bootstrap.yml @@ -21,6 +21,6 @@ labels: BOOTSTRAP: name: "{{ project_name }}_bootstrap" - restart_policy: no + restart_policy: oneshot volumes: "{{ service.volumes }}" when: rabbitmq_volume is changed diff --git a/ansible/roles/sahara/tasks/bootstrap_service.yml b/ansible/roles/sahara/tasks/bootstrap_service.yml index 6f78f9d867..7e119608e7 100644 --- a/ansible/roles/sahara/tasks/bootstrap_service.yml +++ b/ansible/roles/sahara/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_sahara" - restart_policy: no + restart_policy: oneshot volumes: "{{ sahara_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[sahara_api.group][0] }}" diff --git a/ansible/roles/senlin/tasks/bootstrap_service.yml b/ansible/roles/senlin/tasks/bootstrap_service.yml index 318201f5a7..de07a19637 100644 --- a/ansible/roles/senlin/tasks/bootstrap_service.yml +++ b/ansible/roles/senlin/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_senlin" - restart_policy: no + restart_policy: oneshot volumes: "{{ senlin_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[senlin_api.group][0] }}" diff --git a/ansible/roles/skyline/tasks/bootstrap_service.yml b/ansible/roles/skyline/tasks/bootstrap_service.yml index 657ac3d8eb..ae842a317f 100644 --- a/ansible/roles/skyline/tasks/bootstrap_service.yml +++ b/ansible/roles/skyline/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_skyline" - restart_policy: no + restart_policy: oneshot volumes: "{{ skyline_apiserver.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[skyline_apiserver.group][0] }}" diff --git a/ansible/roles/solum/tasks/bootstrap_service.yml b/ansible/roles/solum/tasks/bootstrap_service.yml index 47eadb47e4..c15a3db488 100644 --- a/ansible/roles/solum/tasks/bootstrap_service.yml +++ b/ansible/roles/solum/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_solum" - restart_policy: no + restart_policy: oneshot volumes: "{{ solum_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[solum_api.group][0] }}" diff --git a/ansible/roles/tacker/tasks/bootstrap_service.yml b/ansible/roles/tacker/tasks/bootstrap_service.yml index 7ccfa80888..fab805b17e 100644 --- a/ansible/roles/tacker/tasks/bootstrap_service.yml +++ b/ansible/roles/tacker/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_tacker" - restart_policy: no + restart_policy: oneshot volumes: "{{ tacker_server.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[tacker_server.group][0] }}" diff --git a/ansible/roles/trove/tasks/bootstrap_service.yml b/ansible/roles/trove/tasks/bootstrap_service.yml index 72603c84bc..2ea8bc80f2 100644 --- a/ansible/roles/trove/tasks/bootstrap_service.yml +++ b/ansible/roles/trove/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_trove" - restart_policy: no + restart_policy: oneshot volumes: "{{ trove_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[trove_api.group][0] }}" diff --git a/ansible/roles/vitrage/tasks/bootstrap_service.yml b/ansible/roles/vitrage/tasks/bootstrap_service.yml index 771be16102..3cce9b8a87 100644 --- a/ansible/roles/vitrage/tasks/bootstrap_service.yml +++ b/ansible/roles/vitrage/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_vitrage" - restart_policy: no + restart_policy: oneshot volumes: "{{ vitrage_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[vitrage_api.group][0] }}" diff --git a/ansible/roles/watcher/tasks/bootstrap_service.yml b/ansible/roles/watcher/tasks/bootstrap_service.yml index 789348a3d3..f2e9029403 100644 --- a/ansible/roles/watcher/tasks/bootstrap_service.yml +++ b/ansible/roles/watcher/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_watcher" - restart_policy: no + restart_policy: oneshot volumes: "{{ watcher_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[watcher_api.group][0] }}" diff --git a/ansible/roles/zun/tasks/bootstrap_service.yml b/ansible/roles/zun/tasks/bootstrap_service.yml index cc694f57df..dae0ca2db2 100644 --- a/ansible/roles/zun/tasks/bootstrap_service.yml +++ b/ansible/roles/zun/tasks/bootstrap_service.yml @@ -14,7 +14,7 @@ labels: BOOTSTRAP: name: "bootstrap_zun" - restart_policy: no + restart_policy: oneshot volumes: "{{ zun_api.volumes | reject('equalto', '') | list }}" run_once: True delegate_to: "{{ groups[zun_api.group][0] }}" diff --git a/releasenotes/notes/restart-policy-oneshot-8dc9aa2f79cbfa19.yaml b/releasenotes/notes/restart-policy-oneshot-8dc9aa2f79cbfa19.yaml new file mode 100644 index 0000000000..ea9ebfff10 --- /dev/null +++ b/releasenotes/notes/restart-policy-oneshot-8dc9aa2f79cbfa19.yaml @@ -0,0 +1,9 @@ +--- +features: + - | + Adds new ``restart_policy`` called ``oneshot`` that does not create + systemd units and is used for bootstrap tasks. +upgrade: + - | + ``restart_policy: no`` will now create systemd units, but with + ``Restart`` property set to ``no``. diff --git a/tests/kolla_docker_tests/test_docker_worker.py b/tests/kolla_docker_tests/test_docker_worker.py index 08125e3597..550882e888 100644 --- a/tests/kolla_docker_tests/test_docker_worker.py +++ b/tests/kolla_docker_tests/test_docker_worker.py @@ -478,7 +478,7 @@ class TestContainer(base.BaseTestCase): def test_start_container_no_systemd(self): self.fake_data['params'].update({'name': 'my_container', - 'restart_policy': 'no', + 'restart_policy': 'oneshot', 'auth_username': 'fake_user', 'auth_password': 'fake_psw', 'auth_registry': 'myrepo/myapp', @@ -537,7 +537,7 @@ class TestContainer(base.BaseTestCase): def test_stop_container_no_systemd(self): self.dw = get_DockerWorker({'name': 'my_container', 'action': 'stop_container', - 'restart_policy': 'no'}) + 'restart_policy': 'oneshot'}) self.dw.dc.containers.return_value = self.fake_data['containers'] self.dw.systemd.check_unit_file.return_value = False self.dw.stop_container() @@ -624,7 +624,7 @@ class TestContainer(base.BaseTestCase): def test_restart_container_no_systemd(self): self.dw = get_DockerWorker({'name': 'my_container', 'action': 'stop_container', - 'restart_policy': 'no'}) + 'restart_policy': 'oneshot'}) self.dw.dc.containers.return_value = self.fake_data['containers'] self.fake_data['container_inspect'].update( self.fake_data['containers'][0]) diff --git a/tests/kolla_docker_tests/test_podman_worker.py b/tests/kolla_docker_tests/test_podman_worker.py index 5258f05ebc..7f8ca6b80d 100644 --- a/tests/kolla_docker_tests/test_podman_worker.py +++ b/tests/kolla_docker_tests/test_podman_worker.py @@ -373,7 +373,7 @@ class TestContainer(base.BaseTestCase): def test_start_container_no_systemd(self): self.fake_data['params'].update({'name': 'my_container', - 'restart_policy': 'no', + 'restart_policy': 'oneshot', 'auth_username': 'fake_user', 'auth_password': 'fake_psw', 'auth_registry': 'myrepo/myapp', @@ -437,7 +437,7 @@ class TestContainer(base.BaseTestCase): def test_stop_container_no_systemd(self): self.pw = get_PodmanWorker({'name': 'my_container', 'action': 'stop_container', - 'restart_policy': 'no'}) + 'restart_policy': 'oneshot'}) full_cont_list = get_containers(self.fake_data['containers']) container = full_cont_list[0] self.pw.pc.containers.list.return_value = full_cont_list diff --git a/tests/test_kolla_docker.py b/tests/test_kolla_docker.py index f7a2d22514..2d398d5cb2 100644 --- a/tests/test_kolla_docker.py +++ b/tests/test_kolla_docker.py @@ -83,6 +83,7 @@ class ModuleArgsTest(base.BaseTestCase): restart_policy=dict( required=False, type='str', choices=['no', 'on-failure', + 'oneshot', 'always', 'unless-stopped']), restart_retries=dict(required=False, type='int'),