From 3e14f29e41064c748e655cf1fdff2ad3445babb1 Mon Sep 17 00:00:00 2001 From: Sander Steffann Date: Mon, 10 Jun 2019 20:06:24 +0200 Subject: [PATCH 1/4] Don't warn when trying to read missing cache file --- lib/ansible/plugins/cache/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/plugins/cache/__init__.py b/lib/ansible/plugins/cache/__init__.py index fbc4122aca2b73..5318289d05c563 100644 --- a/lib/ansible/plugins/cache/__init__.py +++ b/lib/ansible/plugins/cache/__init__.py @@ -153,7 +153,7 @@ def get(self, key): raise AnsibleError("The cache file %s was corrupt, or did not otherwise contain valid data. " "It has been removed, so you can re-run your command now." % cachefile) except (OSError, IOError) as e: - display.warning("error in '%s' cache plugin while trying to read %s : %s" % (self.plugin_name, cachefile, to_bytes(e))) + display.v("error in '%s' cache plugin while trying to read %s : %s" % (self.plugin_name, cachefile, to_bytes(e))) raise KeyError except Exception as e: raise AnsibleError("Error while decoding the cache file %s: %s" % (cachefile, to_bytes(e))) From a502a7caac3101fbd9f580e690de6f329c75d8f3 Mon Sep 17 00:00:00 2001 From: Sander Steffann Date: Mon, 10 Jun 2019 20:14:53 +0200 Subject: [PATCH 2/4] Only suppress the warning on errno.ENOENT --- lib/ansible/plugins/cache/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/cache/__init__.py b/lib/ansible/plugins/cache/__init__.py index 5318289d05c563..429c9496d1c828 100644 --- a/lib/ansible/plugins/cache/__init__.py +++ b/lib/ansible/plugins/cache/__init__.py @@ -153,7 +153,10 @@ def get(self, key): raise AnsibleError("The cache file %s was corrupt, or did not otherwise contain valid data. " "It has been removed, so you can re-run your command now." % cachefile) except (OSError, IOError) as e: - display.v("error in '%s' cache plugin while trying to read %s : %s" % (self.plugin_name, cachefile, to_bytes(e))) + if e.errno == errno.ENOENT: + display.v("'%s' cache plugin tried to read non-existent %s" % (self.plugin_name, cachefile)) + else: + display.warning("error in '%s' cache plugin while trying to read %s : %s" % (self.plugin_name, cachefile, to_bytes(e))) raise KeyError except Exception as e: raise AnsibleError("Error while decoding the cache file %s: %s" % (cachefile, to_bytes(e))) From a7ce24a4f2a09c8068f1b996b920db7f85bfe4a8 Mon Sep 17 00:00:00 2001 From: Sander Steffann Date: Mon, 10 Jun 2019 22:56:30 +0200 Subject: [PATCH 3/4] Create cache-file-missing-warning.yaml --- changelogs/fragments/cache-file-missing-warning.yaml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/cache-file-missing-warning.yaml diff --git a/changelogs/fragments/cache-file-missing-warning.yaml b/changelogs/fragments/cache-file-missing-warning.yaml new file mode 100644 index 00000000000000..0b6ec0e7486c58 --- /dev/null +++ b/changelogs/fragments/cache-file-missing-warning.yaml @@ -0,0 +1,2 @@ +minor_changes: + - cache: do not show warning when cache file does not (yet) exist From 06dc61e8bcf3d19e7e3dbd474ed3c542cc473379 Mon Sep 17 00:00:00 2001 From: Sander Steffann Date: Mon, 10 Jun 2019 23:45:50 +0200 Subject: [PATCH 4/4] Fix formatting --- changelogs/fragments/cache-file-missing-warning.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/cache-file-missing-warning.yaml b/changelogs/fragments/cache-file-missing-warning.yaml index 0b6ec0e7486c58..4e4734038e56ce 100644 --- a/changelogs/fragments/cache-file-missing-warning.yaml +++ b/changelogs/fragments/cache-file-missing-warning.yaml @@ -1,2 +1,2 @@ minor_changes: - - cache: do not show warning when cache file does not (yet) exist + - cache - do not show warning when cache file does not (yet) exist