Support stop specific containers

With this change, an operator may be able to stop a
service container without stopping all services in a host.
This change is the starting point to start
fast-forward upgrades support.
In next changes new flags will be introducced to disable
stop dataplane services during upgrades.

Change-Id: Ifde7a39d7d8596ef0d7405ecf1ac1d49a459d9ef
Implements: blueprint support-stop-containers
This commit is contained in:
Eduardo Gonzalez 2018-11-22 11:30:44 +01:00
parent 23415bf8bb
commit 1a682fab28
77 changed files with 641 additions and 48 deletions

View File

@ -581,6 +581,15 @@ monasca_agent_user: "monasca-agent"
# can access these from the Monasca APIs.
monasca_control_plane_project: "monasca_control_plane"
####################
# Global Options
####################
# List of containers to skip during stop command in YAML list format
# skip_stop_containers:
# - container1
# - container2
skip_stop_containers: []
####################
# Logging options
####################

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ barbican_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,9 @@
---
- name: Stopping bifrost_deploy container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "bifrost_deploy"
when:
- inventory_hostname in groups['bifrost']
- "'bifrost_deploy' not in skip_stop_containers"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ blazar_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ ceilometer_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,63 @@
---
- name: Stopping ceph-mon container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "ceph_mon"
when:
- inventory_hostname in groups['ceph-mon']
- "'ceph_mon' not in skip_stop_containers"
- name: Find running ceph-osds containers
command: "docker ps --filter name=ceph_osd_ --format {% raw %}{{.Names}}{% endraw %}"
register: ceph_osd_containers
- name: Stopping ceph-osd container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "{{ item }}"
with_items: "{{ ceph_osd_containers.stdout_lines }}"
when:
- inventory_hostname in groups['ceph-osd']
- ceph_osd_containers.stdout_lines | length >= 1
- item not in skip_stop_containers
- name: Stopping ceph-rgw container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "ceph_rgw"
when:
- inventory_hostname in groups['ceph-rgw']
- enable_ceph_rgw | bool
- "'ceph_rgw' not in skip_stop_containers"
- name: Stopping ceph-mgr container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "ceph_mgr"
when:
- inventory_hostname in groups['ceph-mgr']
- "'ceph_mgr' not in skip_stop_containers"
- name: Stopping ceph-mds container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "ceph_mds"
when:
- enable_ceph_mds | bool
- inventory_hostname in groups['ceph-mds']
- "'ceph_mds' not in skip_stop_containers"
- name: Stopping ceph-nfs container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "ceph_nfs"
when:
- enable_ceph_nfs | bool
- inventory_hostname in groups['ceph-nfs']
- "'ceph_nfs' not in skip_stop_containers"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ chrony_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ cinder_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ cloudkitty_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ collectd_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ common_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ congress_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ designate_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ elasticsearch_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ etcd_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ freezer_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ glance_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ gnocchi_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ grafana_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ haproxy_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ heat_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ horizon_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ influxdb_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ ironic_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,19 @@
---
- name: Stopping iscsid container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "iscsid"
when: ( ( inventory_hostname in groups['compute'] or inventory_hostname in groups['cinder-volume'] ) and enable_cinder | bool and enable_cinder_backend_iscsi | bool )
or ( inventory_hostname in groups['ironic-conductor'] and enable_ironic | bool and 'iscsid' not in skip_stop_containers)
- name: Stopping tgtd container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "tgtd"
when:
- inventory_hostname in groups['tgtd']
- enable_cinder | bool
- enable_cinder_backend_lvm | bool
- "'tgtd' not in skip_stop_containers"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ kafka_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ karbor_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ keystone_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ kibana_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ kuryr_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ magnum_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ manila_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ mariadb_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ memcached_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ mistral_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ monasca_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ mongodb_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ multipathd_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ murano_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ neutron_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ nova_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ octavia_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ opendaylight_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ openvswitch_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ ovsdpdk_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ panko_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ prometheus_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ qdrouterd_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ rabbitmq_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ rally_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ redis_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ sahara_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ searchlight_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ senlin_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,12 @@
---
- name: "Stopping {{ service_name }} containers"
vars:
service: "{{ item.value }}"
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "{{ service.container_name }}"
when:
- service.enabled | bool
- service.container_name not in skip_stop_containers
with_dict: "{{ project_services }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ skydive_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ solum_services }}"
service_name: "{{ project_name }}"

View File

@ -1,17 +0,0 @@
---
- name: Creating /kolla-stop/tools directory on node
file:
state: directory
path: /tmp/kolla-stop/tools
- name: Copying validate-docker-execute.sh file
copy:
src: ../tools/validate-docker-execute.sh
dest: /tmp/kolla-stop/tools
mode: 0755
- name: Copying stop-containers file
copy:
src: ../tools/stop-containers
dest: /tmp/kolla-stop/tools
mode: 0755

View File

@ -1,4 +0,0 @@
---
- include_tasks: copy_tools.yml
- include_tasks: stop_containers.yml

View File

@ -1,3 +0,0 @@
---
- name: Stopping Kolla containers
command: /tmp/kolla-stop/tools/stop-containers

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ storm_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,136 @@
---
- name: Stopping swift-rsyncd container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "swift_rsyncd"
when: ( inventory_hostname in groups['swift-account-server'] or
inventory_hostname in groups['swift-container-server'] or
inventory_hostname in groups['swift-object-server'] ) and
'swift_rsyncd' not in skip_stop_containers
- name: Stopping swift-account-server container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "swift_account_server"
when:
- inventory_hostname in groups['swift-account-server']
- "'swift_account_server' not in skip_stop_containers"
- name: Stopping swift-account-auditor container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "swift_account_auditor"
when:
- inventory_hostname in groups['swift-account-server']
- "'swift_object_auditor' not in skip_stop_containers"
- name: Stopping swift-account-replicator container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "swift_account_replicator"
when:
- inventory_hostname in groups['swift-account-server']
- "'swift_account_replicator' not in skip_stop_containers"
- name: Stopping swift-account-reaper container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "swift_account_reaper"
when:
- inventory_hostname in groups['swift-account-server']
- "'swift_account_reaper' not in skip_stop_containers"
- name: Stopping swift-container-server container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "swift_container_server"
when:
- inventory_hostname in groups['swift-container-server']
- "'swift_container_server' not in skip_stop_containers"
- name: Stopping swift-container-auditor container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "swift_container_auditor"
when:
- inventory_hostname in groups['swift-container-server']
- "'swift_container_auditor' not in skip_stop_containers"
- name: Stopping swift-container-replicator container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "swift_container_replicator"
when:
- inventory_hostname in groups['swift-container-server']
- "'swift_container_replicator' not in skip_stop_containers"
- name: Stopping swift-container-updater container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "swift_container_updater"
when:
- inventory_hostname in groups['swift-container-server']
- "'swift_container_updater' not in skip_stop_containers"
- name: Stopping swift-object-server container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "swift_object_server"
when:
- inventory_hostname in groups['swift-object-server']
- "'swift_object_server' not in skip_stop_containers"
- name: Stopping swift-object-auditor container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "swift_object_auditor"
when:
- inventory_hostname in groups['swift-object-server']
- "'swift_object_auditor' not in skip_stop_containers"
- name: Stopping swift-object-replicator container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "swift_object_replicator"
when:
- inventory_hostname in groups['swift-object-server']
- "'swift_object_replicator' not in skip_stop_containers"
- name: Stopping swift-object-updater container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
name: "swift_object_updater"
when:
- inventory_hostname in groups['swift-object-server']
- "'swift_object_updater' not in skip_stop_containers"
- name: Stopping swift-object-expirer container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "swift_object_expirer"
when:
- inventory_hostname in groups['swift-object-server']
- "'swift_object_expirer' not in skip_stop_containers"
- name: Stopping swift-proxy-server container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "swift_proxy_server"
when:
- inventory_hostname in groups['swift-proxy-server']
- "'swift_proxy_server' not in skip_stop_containers"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ tacker_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ telegraf_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ tempest_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ trove_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ vitrage_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ vmtp_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ watcher_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ zookeeper_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ zun_services }}"
service_name: "{{ project_name }}"

View File

@ -1,4 +0,0 @@
---
- hosts: all
roles:
- stop

View File

@ -0,0 +1,11 @@
---
features:
- |
Add support to stop a service with ``kolla-ansible stop`` command.
This feature will allow to stop specific services with ``--tags`` and
``--limit`` to a host.
upgrade:
- |
New ``kolla-ansible stop`` command requires the usage of
``--yes-i-really-really-mean-it`` to avoid accidentally
stopping services.

View File

@ -28,7 +28,6 @@ data_files =
share/kolla-ansible/tools = tools/cleanup-containers
share/kolla-ansible/tools = tools/cleanup-host
share/kolla-ansible/tools = tools/cleanup-images
share/kolla-ansible/tools = tools/stop-containers
share/kolla-ansible/tools = tools/ovs-dpdkctl.sh
share/kolla-ansible/doc = doc/*
share/kolla-ansible/etc_examples = etc/*

View File

@ -330,7 +330,16 @@ EOF
;;
(stop)
ACTION="Stop Kolla containers"
PLAYBOOK="${BASEDIR}/ansible/stop.yml"
EXTRA_OPTS="$EXTRA_OPTS -e kolla_action=stop"
if [[ "${DANGER_CONFIRM}" != "--yes-i-really-really-mean-it" ]]; then
cat << EOF
WARNING:
This will stop all deployed kolla containers, limit with tags is possible and also with
skip_stop_containers variable. To confirm, please add the following option:
--yes-i-really-really-mean-it
EOF
exit 1
fi
;;
(certificates)
ACTION="Generate TLS Certificates"

View File

@ -1,18 +0,0 @@
#!/bin/bash
if [[ $(pgrep qemu) ]]; then
echo "Some qemu processes were detected."
echo "Docker will not be able to stop the nova_libvirt container with those running."
echo "Please clean them up before rerunning this script."
exit 1
fi
if [ -n "$1" ]; then
containers_to_stop=($(docker ps | grep -E "$1" | awk '{print $1}'))
else
containers_to_stop=$(docker ps --filter "label=kolla_version" --format "{{.Names}}" -a)
fi
echo "Stopping containers..."
(docker stop -t 30 ${containers_to_stop} 2>&1) > /dev/null
echo "All containers stopped!"