From 3c7c496e67135760800b73a0c6c9b6af57ff4612 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 22 Mar 2022 07:13:39 +0100 Subject: [PATCH] Implement connection reset. (#312) --- 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 e786e9314..f039b994b 100644 --- a/plugins/connection/docker.py +++ b/plugins/connection/docker.py @@ -435,3 +435,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 65504156a..102f92377 100644 --- a/plugins/connection/docker_api.py +++ b/plugins/connection/docker_api.py @@ -383,3 +383,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()