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()