Skip to content

Commit aeec6b9

Browse files
authored
Revert "Use replace option to recreate a container (#613)" (#616)
This reverts commit cb832c9. We lose flexibility in recreating workflow, replace actually does the same in Podman - stops and removes/creates. Signed-off-by: Sagi Shnaidman <[email protected]>
1 parent cb832c9 commit aeec6b9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

plugins/module_utils/podman/podman_container_lib.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def construct_command_from_params(self):
208208
"""
209209
if self.action in ['start', 'stop', 'delete', 'restart']:
210210
return self.start_stop_delete()
211-
if self.action in ['create', 'run', 'recreate']:
211+
if self.action in ['create', 'run']:
212212
cmd = [self.action, '--name', self.params['name']]
213213
all_param_methods = [func for func in dir(self)
214214
if callable(getattr(self, func))
@@ -1443,14 +1443,11 @@ def _perform_action(self, action):
14431443
action {str} -- action to perform - start, create, stop, run,
14441444
delete, restart
14451445
"""
1446-
b_command = PodmanModuleParams(action if action != 'recreate' else 'create',
1446+
b_command = PodmanModuleParams(action,
14471447
self.module_params,
14481448
self.version,
14491449
self.module,
14501450
).construct_command_from_params()
1451-
if action == 'recreate':
1452-
action = 'create'
1453-
b_command.insert(1, b'--replace')
14541451
if action == 'create':
14551452
b_command.remove(b'--detach=True')
14561453
full_cmd = " ".join([self.module_params['executable']]
@@ -1501,7 +1498,11 @@ def create(self):
15011498

15021499
def recreate(self):
15031500
"""Recreate the container."""
1504-
self._perform_action('recreate')
1501+
if self.running:
1502+
self.stop()
1503+
if not self.info['HostConfig']['AutoRemove']:
1504+
self.delete()
1505+
self.create()
15051506

15061507
def recreate_run(self):
15071508
"""Recreate and run the container."""

0 commit comments

Comments
 (0)