1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-03-22 02:29:08 +00:00

Fix idempotency for RestartPolicy when MaximumRetryCount > 0 (#607)

Before this change, this task:

```ansible
- containers.podman.podman_container:
    # ...
    restart_policy: on-failure:3
    # ...
```

always caused this diff:

```diff
--- before
+++ after
@@ -1 +1 @@
-restart_policy - on-failure
+restart_policy - on-failure:3
```

Signed-off-by: Sebastian Endres <sebastian.endres@dlr.de>
Co-authored-by: Sebastian Endres <sebastian.endres@dlr.de>
This commit is contained in:
sedrubal 2023-07-30 20:59:13 +02:00 committed by GitHub
parent 0932809c6a
commit 0ae6baac3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1166,7 +1166,15 @@ class PodmanContainerDiff:
def diffparam_restart_policy(self):
before = self.info['hostconfig']['restartpolicy']['name']
before_max_count = int(self.info['hostconfig']['restartpolicy'].get('maximumretrycount', 0))
after = self.params['restart_policy'] or ""
if ':' in after:
after, after_max_count = after.rsplit(':', 1)
after_max_count = int(after_max_count)
else:
after_max_count = 0
before = "%s:%i" % (before, before_max_count)
after = "%s:%i" % (after, after_max_count)
return self._diff_update_and_compare('restart_policy', before, after)
def diffparam_rm(self):