diff --git a/changelogs/fragments/312-docker-connection-reset.yml b/changelogs/fragments/312-docker-connection-reset.yml new file mode 100644 index 00000000..fef7ff94 --- /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 e786e931..f039b994 100644 --- a/plugins/connection/docker.py +++ b/plugins/connection/docker.py @@ -435,3 +435,7 @@ class Connection(ConnectionBase): """ 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 65504156..102f9237 100644 --- a/plugins/connection/docker_api.py +++ b/plugins/connection/docker_api.py @@ -383,3 +383,6 @@ class Connection(ConnectionBase): """ Terminate the connection. Nothing to do for Docker""" super(Connection, self).close() self._connected = False + + def reset(self): + self.ids.clear()