Don't wait for removal during check mode. (#66145)

This commit is contained in:
Felix Fontein 2020-01-02 17:51:52 +01:00 committed by GitHub
parent 19f77faf7b
commit 14e32c85b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2657,7 +2657,7 @@ class ContainerManager(DockerBaseClass):
if not self.parameters.image: if not self.parameters.image:
self.fail('Cannot create container when image is not specified!') self.fail('Cannot create container when image is not specified!')
self.diff_tracker.add('exists', parameter=True, active=False) self.diff_tracker.add('exists', parameter=True, active=False)
if container.removing: if container.removing and not self.check_mode:
# Wait for container to be removed before trying to create it # Wait for container to be removed before trying to create it
self.wait_for_state(container.Id, wait_states=['removing'], accept_removal=True) self.wait_for_state(container.Id, wait_states=['removing'], accept_removal=True)
new_container = self.container_create(self.parameters.image, self.parameters.create_parameters) new_container = self.container_create(self.parameters.image, self.parameters.create_parameters)
@ -2685,7 +2685,8 @@ class ContainerManager(DockerBaseClass):
if container.running: if container.running:
self.container_stop(container.Id) self.container_stop(container.Id)
self.container_remove(container.Id) self.container_remove(container.Id)
self.wait_for_state(container.Id, wait_states=['removing'], accept_removal=True) if not self.check_mode:
self.wait_for_state(container.Id, wait_states=['removing'], accept_removal=True)
new_container = self.container_create(image_to_use, self.parameters.create_parameters) new_container = self.container_create(image_to_use, self.parameters.create_parameters)
if new_container: if new_container:
container = new_container container = new_container