From f3cea8eb683fe5abfe116d6995147a309b16788d Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 21 Mar 2022 21:32:10 +0100 Subject: [PATCH] Implement connection reset. --- changelogs/fragments/312-docker-connection-reset.yml | 3 +++ plugins/connection/docker.py | 4 ++++ plugins/connection/docker_api.py | 3 +++ 3 files changed, 10 insertions(+) create mode 100644 changelogs/fragments/312-docker-connection-reset.yml diff --git a/changelogs/fragments/312-docker-connection-reset.yml b/changelogs/fragments/312-docker-connection-reset.yml new file mode 100644 index 000000000..fef7ff94e --- /dev/null +++ b/changelogs/fragments/312-docker-connection-reset.yml @@ -0,0 +1,3 @@ +minor_changes: +- "docker connection plugin - implement connection reset by clearing internal container user cache (https://github.com/ansible-collections/community.docker/pull/312)." +- "docker_api connection plugin - implement connection reset by clearing internal container user/group ID cache (https://github.com/ansible-collections/community.docker/pull/312)." diff --git a/plugins/connection/docker.py b/plugins/connection/docker.py index 96d1b46f4..267429fcf 100644 --- a/plugins/connection/docker.py +++ b/plugins/connection/docker.py @@ -431,3 +431,7 @@ def close(self): """ Terminate the connection. Nothing to do for Docker""" super(Connection, self).close() self._connected = False + + def reset(self): + # Clear container user cache + self._container_user_cache = {} diff --git a/plugins/connection/docker_api.py b/plugins/connection/docker_api.py index ead345a21..ce3dad13f 100644 --- a/plugins/connection/docker_api.py +++ b/plugins/connection/docker_api.py @@ -352,3 +352,6 @@ def close(self): """ Terminate the connection. Nothing to do for Docker""" super(Connection, self).close() self._connected = False + + def reset(self): + self.ids.clear()