1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-04-30 21:08:49 +00:00

Fix idempoency issue with PID of container (#622)

Fix #573
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
Sergey 2023-08-12 14:25:09 +03:00 committed by GitHub
parent 4812aea6b8
commit 11f9eded6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 68 additions and 0 deletions

View file

@ -1136,8 +1136,19 @@ class PodmanContainerDiff:
return self._diff_update_and_compare('privileged', before, after)
def diffparam_pid(self):
def get_container_id_by_name(name):
rc, podman_inspect_info, err = self.module.run_command(
[self.module.params["executable"], "inspect", name, "-f", "{{.Id}}"])
if rc != 0:
return None
return podman_inspect_info.strip()
before = self.info['hostconfig']['pidmode']
after = self.params['pid']
if after is not None and "container:" in after and "container:" in before:
if after.split(":")[1] == before.split(":")[1]:
return self._diff_update_and_compare('pid', before, after)
after = "container:" + get_container_id_by_name(after.split(":")[1])
return self._diff_update_and_compare('pid', before, after)
# TODO(sshnaidm) Need to add port ranges support