Use force_kill instead of stop_timeout to fasten container cleanup. (#48733)

pull/48836/head
Felix Fontein 6 years ago committed by John R Barker
parent e6ffc4f89a
commit afded1c778

@ -20,7 +20,7 @@
docker_container: docker_container:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
with_items: "{{ cnames }}" with_items: "{{ cnames }}"
- name: "Make sure all networks are removed" - name: "Make sure all networks are removed"
docker_network: docker_network:

@ -26,6 +26,7 @@
name: "{{ cname }}" name: "{{ cname }}"
state: started state: started
hostname: example.org hostname: example.org
force_kill: yes
comparisons: comparisons:
hostname: ignore hostname: ignore
register: value_2 register: value_2
@ -37,7 +38,7 @@
name: "{{ cname }}" name: "{{ cname }}"
state: started state: started
hostname: example.org hostname: example.org
stop_timeout: 1 force_kill: yes
comparisons: comparisons:
hostname: strict hostname: strict
register: value_3 register: value_3
@ -46,7 +47,7 @@
docker_container: docker_container:
name: "{{ cname }}" name: "{{ cname }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
- assert: - assert:
that: that:
@ -77,6 +78,7 @@
state: started state: started
dns_servers: dns_servers:
- 9.9.9.9 - 9.9.9.9
force_kill: yes
comparisons: comparisons:
dns_servers: ignore dns_servers: ignore
register: list_2 register: list_2
@ -89,16 +91,16 @@
state: started state: started
dns_servers: dns_servers:
- 9.9.9.9 - 9.9.9.9
force_kill: yes
comparisons: comparisons:
dns_servers: strict dns_servers: strict
stop_timeout: 1
register: list_3 register: list_3
- name: cleanup - name: cleanup
docker_container: docker_container:
name: "{{ cname }}" name: "{{ cname }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
- assert: - assert:
that: that:
@ -131,6 +133,7 @@
- 1010 - 1010
- 1011 - 1011
- 1012 - 1012
force_kill: yes
comparisons: comparisons:
groups: ignore groups: ignore
register: set_2 register: set_2
@ -145,9 +148,9 @@
- 1010 - 1010
- 1011 - 1011
- 1012 - 1012
force_kill: yes
comparisons: comparisons:
groups: allow_more_present groups: allow_more_present
stop_timeout: 1
register: set_3 register: set_3
- name: set (change, allow_more_present) - name: set (change, allow_more_present)
@ -159,9 +162,9 @@
groups: groups:
- 1010 - 1010
- 1012 - 1012
force_kill: yes
comparisons: comparisons:
groups: allow_more_present groups: allow_more_present
stop_timeout: 1
register: set_4 register: set_4
- name: set (change, strict) - name: set (change, strict)
@ -173,16 +176,16 @@
groups: groups:
- 1010 - 1010
- 1012 - 1012
force_kill: yes
comparisons: comparisons:
groups: strict groups: strict
stop_timeout: 1
register: set_5 register: set_5
- name: cleanup - name: cleanup
docker_container: docker_container:
name: "{{ cname }}" name: "{{ cname }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
- assert: - assert:
that: that:
@ -217,6 +220,7 @@
- "/dev/random:/dev/virt-random:rwm" - "/dev/random:/dev/virt-random:rwm"
- "/dev/urandom:/dev/virt-urandom:rwm" - "/dev/urandom:/dev/virt-urandom:rwm"
- "/dev/null:/dev/virt-null:rwm" - "/dev/null:/dev/virt-null:rwm"
force_kill: yes
comparisons: comparisons:
devices: ignore devices: ignore
register: set_dict_2 register: set_dict_2
@ -231,9 +235,9 @@
- "/dev/random:/dev/virt-random:rwm" - "/dev/random:/dev/virt-random:rwm"
- "/dev/urandom:/dev/virt-urandom:rwm" - "/dev/urandom:/dev/virt-urandom:rwm"
- "/dev/null:/dev/virt-null:rwm" - "/dev/null:/dev/virt-null:rwm"
force_kill: yes
comparisons: comparisons:
devices: allow_more_present devices: allow_more_present
stop_timeout: 1
register: set_dict_3 register: set_dict_3
- name: set(dict) (change, allow_more_present) - name: set(dict) (change, allow_more_present)
@ -245,9 +249,9 @@
devices: devices:
- "/dev/random:/dev/virt-random:rwm" - "/dev/random:/dev/virt-random:rwm"
- "/dev/null:/dev/virt-null:rwm" - "/dev/null:/dev/virt-null:rwm"
force_kill: yes
comparisons: comparisons:
devices: allow_more_present devices: allow_more_present
stop_timeout: 1
register: set_dict_4 register: set_dict_4
- name: set(dict) (change, strict) - name: set(dict) (change, strict)
@ -259,16 +263,16 @@
devices: devices:
- "/dev/random:/dev/virt-random:rwm" - "/dev/random:/dev/virt-random:rwm"
- "/dev/null:/dev/virt-null:rwm" - "/dev/null:/dev/virt-null:rwm"
force_kill: yes
comparisons: comparisons:
devices: strict devices: strict
stop_timeout: 1
register: set_dict_5 register: set_dict_5
- name: cleanup - name: cleanup
docker_container: docker_container:
name: "{{ cname }}" name: "{{ cname }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
- assert: - assert:
that: that:
@ -303,6 +307,7 @@
ansible.test.1: hello ansible.test.1: hello
ansible.test.2: world ansible.test.2: world
ansible.test.3: ansible ansible.test.3: ansible
force_kill: yes
comparisons: comparisons:
labels: ignore labels: ignore
register: dict_2 register: dict_2
@ -317,9 +322,9 @@
ansible.test.1: hello ansible.test.1: hello
ansible.test.2: world ansible.test.2: world
ansible.test.3: ansible ansible.test.3: ansible
force_kill: yes
comparisons: comparisons:
labels: allow_more_present labels: allow_more_present
stop_timeout: 1
register: dict_3 register: dict_3
- name: dict (change, allow_more_present) - name: dict (change, allow_more_present)
@ -331,9 +336,9 @@
labels: labels:
ansible.test.1: hello ansible.test.1: hello
ansible.test.3: ansible ansible.test.3: ansible
force_kill: yes
comparisons: comparisons:
labels: allow_more_present labels: allow_more_present
stop_timeout: 1
register: dict_4 register: dict_4
- name: dict (change, strict) - name: dict (change, strict)
@ -345,16 +350,16 @@
labels: labels:
ansible.test.1: hello ansible.test.1: hello
ansible.test.3: ansible ansible.test.3: ansible
force_kill: yes
comparisons: comparisons:
labels: strict labels: strict
stop_timeout: 1
register: dict_5 register: dict_5
- name: cleanup - name: cleanup
docker_container: docker_container:
name: "{{ cname }}" name: "{{ cname }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
- assert: - assert:
that: that:
@ -399,6 +404,7 @@
labels: labels:
ansible.test.1: hello ansible.test.1: hello
ansible.test.4: ignore ansible.test.4: ignore
force_kill: yes
comparisons: comparisons:
'*': ignore '*': ignore
register: wildcard_2 register: wildcard_2
@ -415,6 +421,7 @@
ansible.test.1: hello ansible.test.1: hello
ansible.test.2: world ansible.test.2: world
ansible.test.3: ansible ansible.test.3: ansible
force_kill: yes
comparisons: comparisons:
'*': strict '*': strict
register: wildcard_3 register: wildcard_3
@ -431,6 +438,7 @@
ansible.test.1: hello ansible.test.1: hello
ansible.test.2: world ansible.test.2: world
ansible.test.3: ansible ansible.test.3: ansible
force_kill: yes
comparisons: comparisons:
'*': strict '*': strict
register: wildcard_4 register: wildcard_4
@ -439,7 +447,7 @@
docker_container: docker_container:
name: "{{ cname }}" name: "{{ cname }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
- assert: - assert:
that: that:

@ -34,6 +34,7 @@
image: "{{ image_facts.images[0].Id }}" image: "{{ image_facts.images[0].Id }}"
name: "{{ cname }}" name: "{{ cname }}"
state: present state: present
force_kill: yes
register: create_1 register: create_1
- name: Create container with hello-world image via ID (idempotent) - name: Create container with hello-world image via ID (idempotent)
@ -41,6 +42,7 @@
image: "{{ image_facts.images[0].Id }}" image: "{{ image_facts.images[0].Id }}"
name: "{{ cname }}" name: "{{ cname }}"
state: present state: present
force_kill: yes
register: create_2 register: create_2
- name: Create container with alpine image via ID - name: Create container with alpine image via ID
@ -48,6 +50,7 @@
image: "{{ image_facts.images[1].Id }}" image: "{{ image_facts.images[1].Id }}"
name: "{{ cname }}" name: "{{ cname }}"
state: present state: present
force_kill: yes
register: create_3 register: create_3
- name: Create container with alpine image via ID (idempotent) - name: Create container with alpine image via ID (idempotent)
@ -55,13 +58,14 @@
image: "{{ image_facts.images[1].Id }}" image: "{{ image_facts.images[1].Id }}"
name: "{{ cname }}" name: "{{ cname }}"
state: present state: present
force_kill: yes
register: create_4 register: create_4
- name: Cleanup - name: Cleanup
docker_container: docker_container:
name: "{{ cname }}" name: "{{ cname }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
- assert: - assert:
that: that:

@ -18,7 +18,7 @@
- 8081 - 8081
published_ports: published_ports:
- all - all
stop_timeout: 1 force_kill: yes
register: published_ports_1 register: published_ports_1
- name: published_ports -- all (idempotency) - name: published_ports -- all (idempotency)
@ -32,7 +32,7 @@
- 8081 - 8081
published_ports: published_ports:
- all - all
stop_timeout: 1 force_kill: yes
register: published_ports_2 register: published_ports_2
- name: published_ports -- all (writing out 'all') - name: published_ports -- all (writing out 'all')
@ -47,7 +47,7 @@
published_ports: published_ports:
- 8080 - 8080
- 8081 - 8081
stop_timeout: 1 force_kill: yes
register: published_ports_3 register: published_ports_3
- name: published_ports -- all (idempotency 2) - name: published_ports -- all (idempotency 2)
@ -62,7 +62,7 @@
published_ports: published_ports:
- 8080 - 8080
- 8081 - 8081
stop_timeout: 1 force_kill: yes
register: published_ports_4 register: published_ports_4
- name: published_ports -- all (switching back to 'all') - name: published_ports -- all (switching back to 'all')
@ -76,14 +76,14 @@
- 8081 - 8081
published_ports: published_ports:
- all - all
stop_timeout: 1 force_kill: yes
register: published_ports_5 register: published_ports_5
- name: cleanup - name: cleanup
docker_container: docker_container:
name: "{{ cname }}" name: "{{ cname }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
- assert: - assert:
that: that:
@ -109,7 +109,7 @@
published_ports: published_ports:
- 8080:8080 - 8080:8080
- 5000-5040:5000-5040 - 5000-5040:5000-5040
stop_timeout: 1 force_kill: yes
register: published_ports_1 register: published_ports_1
- name: published_ports -- port range (idempotency) - name: published_ports -- port range (idempotency)
@ -124,7 +124,7 @@
published_ports: published_ports:
- 8080:8080 - 8080:8080
- 5000-5040:5000-5040 - 5000-5040:5000-5040
stop_timeout: 1 force_kill: yes
register: published_ports_2 register: published_ports_2
- name: published_ports -- port range (different range) - name: published_ports -- port range (different range)
@ -139,14 +139,14 @@
published_ports: published_ports:
- 8080:8080 - 8080:8080
- 5010-5050:5010-5050 - 5010-5050:5010-5050
stop_timeout: 1 force_kill: yes
register: published_ports_3 register: published_ports_3
- name: cleanup - name: cleanup
docker_container: docker_container:
name: "{{ cname }}" name: "{{ cname }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
- assert: - assert:
that: that:
@ -166,7 +166,7 @@
state: started state: started
published_ports: published_ports:
- "[::1]:8080:8080" - "[::1]:8080:8080"
stop_timeout: 1 force_kill: yes
register: published_ports_1 register: published_ports_1
- name: published_ports -- IPv6 (idempotency) - name: published_ports -- IPv6 (idempotency)
@ -177,7 +177,7 @@
state: started state: started
published_ports: published_ports:
- "[::1]:8080:8080" - "[::1]:8080:8080"
stop_timeout: 1 force_kill: yes
register: published_ports_2 register: published_ports_2
- name: published_ports -- IPv6 (different IP) - name: published_ports -- IPv6 (different IP)
@ -188,7 +188,7 @@
state: started state: started
published_ports: published_ports:
- 127.0.0.1:8080:8080 - 127.0.0.1:8080:8080
stop_timeout: 1 force_kill: yes
register: published_ports_3 register: published_ports_3
- name: published_ports -- IPv6 (hostname) - name: published_ports -- IPv6 (hostname)
@ -199,7 +199,7 @@
state: started state: started
published_ports: published_ports:
- localhost:8080:8080 - localhost:8080:8080
stop_timeout: 1 force_kill: yes
register: published_ports_4 register: published_ports_4
ignore_errors: yes ignore_errors: yes
@ -207,7 +207,7 @@
docker_container: docker_container:
name: "{{ cname }}" name: "{{ cname }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
- assert: - assert:
that: that:

@ -17,7 +17,7 @@
- name: Stop container with a lot of invalid options - name: Stop container with a lot of invalid options
docker_container: docker_container:
name: "{{ cname }}" name: "{{ cname }}"
stop_timeout: 1 force_kill: yes
# Some options with "invalid" values, which would # Some options with "invalid" values, which would
# have to be parsed. The values are "invalid" because # have to be parsed. The values are "invalid" because
# the containers and networks listed here do not exist. # the containers and networks listed here do not exist.

@ -122,12 +122,13 @@
docker_container: docker_container:
name: "{{ cname }}" name: "{{ cname }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
- name: Start container from scratch (check) - name: Start container from scratch (check)
docker_container: docker_container:
image: alpine:3.8 image: alpine:3.8
command: '/bin/sh -c "sleep 10m"' command: '/bin/sh -c "sleep 10m"'
stop_timeout: 1
name: "{{ cname }}" name: "{{ cname }}"
state: started state: started
check_mode: yes check_mode: yes
@ -137,6 +138,7 @@
docker_container: docker_container:
image: alpine:3.8 image: alpine:3.8
command: '/bin/sh -c "sleep 10m"' command: '/bin/sh -c "sleep 10m"'
stop_timeout: 1
name: "{{ cname }}" name: "{{ cname }}"
state: started state: started
register: start_scratch_2 register: start_scratch_2
@ -145,6 +147,7 @@
docker_container: docker_container:
image: alpine:3.8 image: alpine:3.8
command: '/bin/sh -c "sleep 10m"' command: '/bin/sh -c "sleep 10m"'
stop_timeout: 1
name: "{{ cname }}" name: "{{ cname }}"
state: started state: started
register: start_scratch_3 register: start_scratch_3
@ -153,6 +156,7 @@
docker_container: docker_container:
image: alpine:3.8 image: alpine:3.8
command: '/bin/sh -c "sleep 10m"' command: '/bin/sh -c "sleep 10m"'
stop_timeout: 1
name: "{{ cname }}" name: "{{ cname }}"
state: started state: started
check_mode: yes check_mode: yes
@ -262,7 +266,7 @@
docker_container: docker_container:
name: "{{ cname }}" name: "{{ cname }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
check_mode: yes check_mode: yes
register: remove_from_running_1 register: remove_from_running_1
@ -270,21 +274,21 @@
docker_container: docker_container:
name: "{{ cname }}" name: "{{ cname }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
register: remove_from_running_2 register: remove_from_running_2
- name: Remove container from running (idempotent) - name: Remove container from running (idempotent)
docker_container: docker_container:
name: "{{ cname }}" name: "{{ cname }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
register: remove_from_running_3 register: remove_from_running_3
- name: Remove container from running (idempotent check) - name: Remove container from running (idempotent check)
docker_container: docker_container:
name: "{{ cname }}" name: "{{ cname }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
check_mode: yes check_mode: yes
register: remove_from_running_4 register: remove_from_running_4

@ -8,7 +8,7 @@
docker_container: docker_container:
name: "{{ cname }}" name: "{{ cname }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
- name: Inspect a non-present container - name: Inspect a non-present container
docker_container_facts: docker_container_facts:
@ -28,7 +28,7 @@
command: '/bin/sh -c "sleep 10m"' command: '/bin/sh -c "sleep 10m"'
state: started state: started
auto_remove: yes auto_remove: yes
stop_timeout: 1 force_kill: yes
- name: Inspect a present container - name: Inspect a present container
docker_container_facts: docker_container_facts:
@ -49,7 +49,7 @@
docker_container: docker_container:
name: "{{ cname }}" name: "{{ cname }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
- assert: - assert:
that: that:

@ -44,7 +44,7 @@
docker_container: docker_container:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
with_items: "{{ cnames }}" with_items: "{{ cnames }}"
# Skip for CentOS 6 # Skip for CentOS 6

@ -18,7 +18,7 @@
docker_container: docker_container:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
loop: "{{ cnames }}" loop: "{{ cnames }}"
- name: "Make sure all networks are removed" - name: "Make sure all networks are removed"
docker_network: docker_network:

@ -125,7 +125,7 @@
docker_container: docker_container:
name: "{{ container_name }}" name: "{{ container_name }}"
state: absent state: absent
stop_timeout: 1 force_kill: yes
loop: loop:
- "{{ cname_1 }}" - "{{ cname_1 }}"
- "{{ cname_2 }}" - "{{ cname_2 }}"

Loading…
Cancel
Save