Browse Source

Do not force remove containers

Paunch does docker/podman rm -f, when removes containers. It seems it
returns too early, having some leftovers (like docker service
endpoints) behind or pending for it to be removed later, in case of
big fat deamons.

Long story short, don't do rm -f and allow it to do its job gracefully
and without a hurry.

Conflicts:
    paunch/runner.py
    paunch/tests/test_builder_compose1.py
    paunch/tests/test_runner.py

Change-Id: I346c49cb204f273bd7077ca5153412cda9846534
Closes-Bug: #1860004
Co-authored-by: Sergii Golovatiuk <sgolovat@redhat.com>
Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
(cherry picked from commit 3813fc7f2b)
(cherry picked from commit d56765a0af)
(cherry picked from commit 7a00269856)
changes/72/704672/1
Bogdan Dobrelya 1 year ago
committed by Luke Short
parent
commit
de16739795
3 changed files with 5 additions and 5 deletions
  1. +1
    -1
      paunch/runner.py
  2. +3
    -3
      paunch/tests/test_builder_compose1.py
  3. +1
    -1
      paunch/tests/test_runner.py

+ 1
- 1
paunch/runner.py View File

@ -96,7 +96,7 @@ class DockerRunner(object):
self.remove_container(container)
def remove_container(self, container):
cmd = [self.docker_cmd, 'rm', '-f', container]
cmd = [self.docker_cmd, 'rm', container]
cmd_stdout, cmd_stderr, returncode = self.execute(cmd)
if returncode != 0:
LOG.error('Error removing container: %s' % container)


+ 3
- 3
paunch/tests/test_builder_compose1.py View File

@ -283,13 +283,13 @@ three-12345678 three''', '', 0),
'--format', '{{.Names}} {{.Label "container_name"}}']
),
# rm containers not in config
mock.call(['docker', 'rm', '-f', 'five']),
mock.call(['docker', 'rm', '-f', 'six']),
mock.call(['docker', 'rm', 'five']),
mock.call(['docker', 'rm', 'six']),
# rm two, changed config
mock.call(['docker', 'inspect', '--type', 'container',
'--format', '{{index .Config.Labels "config_data"}}',
'two-12345678']),
mock.call(['docker', 'rm', '-f', 'two-12345678']),
mock.call(['docker', 'rm', 'two-12345678']),
# check three, config hasn't changed
mock.call(['docker', 'inspect', '--type', 'container',
'--format', '{{index .Config.Labels "config_data"}}',


+ 1
- 1
paunch/tests/test_runner.py View File

@ -95,7 +95,7 @@ class TestDockerRunner(base.TestCase):
self.runner.remove_container('one')
self.assert_execute(
popen, ['docker', 'rm', '-f', 'one']
popen, ['docker', 'rm', 'one']
)
@mock.patch('subprocess.Popen')


Loading…
Cancel
Save