Skip to content

Commit

Permalink
Fix idempotency checks when using userns (#599)
Browse files Browse the repository at this point in the history
Previously, this would only mark the userns as expected when `uidmap`
or `gidmap` is passed. However, in the case `userns` is passed, this
is also expected to be set.

Signed-off-by: Benjamin Schubert <[email protected]>
  • Loading branch information
BenjaminSchubert authored Jul 31, 2023
1 parent 0ae6baa commit 9aedda4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugins/module_utils/podman/podman_pod_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ def diffparam_share(self):
# TODO: find out why on Ubuntu the 'net' is not present
if 'net' not in before:
after.remove('net')
if self.params["uidmap"] or self.params["gidmap"]:
if self.params["uidmap"] or self.params["gidmap"] or self.params["userns"]:
after.append('user')

before, after = sorted(list(set(before))), sorted(list(set(after)))
Expand Down
43 changes: 42 additions & 1 deletion tests/integration/targets/podman_pod/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@
that:
- pod15_a_info is changed

- name: Start pod with share for idempotency
- name: Start pod with gidmap and uidmap for idempotency
containers.podman.podman_pod:
executable: "{{ test_executable | default('podman') }}"
name: pod1
Expand All @@ -347,6 +347,47 @@
that:
- pod15_b_info is not changed

# Reset the namespace check.
# This is because changing from `uidmap/gidmap` to `userns` does not
# report a difference currently
- name: Start pod without uidmap to reset
containers.podman.podman_pod:
executable: "{{ test_executable | default('podman') }}"
name: pod1
state: created
register: pod15_c_info

- name: Check info
assert:
that:
- pod15_c_info is changed

- name: Start pod with userns
containers.podman.podman_pod:
executable: "{{ test_executable | default('podman') }}"
name: pod1
userns: auto
state: created
register: pod_userns_a_info

- name: Check info
assert:
that:
- pod_userns_a_info is changed

- name: Start pod with userns for idempotency
containers.podman.podman_pod:
executable: "{{ test_executable | default('podman') }}"
name: pod1
userns: auto
state: created
register: pod_userns_b_info

- name: Check info
assert:
that:
- pod_userns_b_info is not changed

- name: Start pod with labels
containers.podman.podman_pod:
executable: "{{ test_executable | default('podman') }}"
Expand Down

0 comments on commit 9aedda4

Please sign in to comment.