Skip to content

Commit

Permalink
Fix idempotency for RestartPolicy when MaximumRetryCount > 0 (#607)
Browse files Browse the repository at this point in the history
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 <[email protected]>
Co-authored-by: Sebastian Endres <[email protected]>
  • Loading branch information
sedrubal and Sebastian Endres authored Jul 30, 2023
1 parent 0932809 commit 0ae6baa
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plugins/module_utils/podman/podman_container_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,15 @@ def diffparam_read_only(self):

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):
Expand Down

0 comments on commit 0ae6baa

Please sign in to comment.