mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-04-25 10:32:41 +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:
parent
4812aea6b8
commit
11f9eded6a
2 changed files with 68 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -332,6 +332,63 @@
|
|||
assert:
|
||||
that: test25 is changed
|
||||
|
||||
- name: Run container for linking with PID
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
image: "{{ idem_image }}"
|
||||
name: idempotency
|
||||
state: present
|
||||
register: test26
|
||||
|
||||
- name: Check info with PID
|
||||
assert:
|
||||
that: test26 is not changed
|
||||
|
||||
- name: Run second container for linking with PID
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
image: "{{ idem_image }}"
|
||||
name: idempotency2
|
||||
state: present
|
||||
pid: "container:idempotency"
|
||||
register: test27
|
||||
|
||||
- name: Check info of second container with PID
|
||||
assert:
|
||||
that: test27 is changed
|
||||
|
||||
- name: Run second container for linking with PID
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
image: "{{ idem_image }}"
|
||||
name: idempotency2
|
||||
state: present
|
||||
pid: "container:idempotency"
|
||||
register: test28
|
||||
|
||||
- name: Check info of second container with PID again
|
||||
assert:
|
||||
that: test28 is not changed
|
||||
|
||||
- name: Run second container for linking with PID with container ID
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
image: "{{ idem_image }}"
|
||||
name: idempotency2
|
||||
state: present
|
||||
pid: "container:{{ test26.container.Id }}"
|
||||
register: test29
|
||||
|
||||
- name: Check info of second container with PID of container ID again
|
||||
assert:
|
||||
that: test29 is not changed
|
||||
|
||||
- name: Remove dependant test container
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
name: idempotency2
|
||||
state: absent
|
||||
|
||||
- name: Remove test container
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue