SHA256
1
0
forked from pool/salt
salt/batch.py-avoid-exception-when-minion-does-not-respon.patch

47 lines
1.6 KiB
Diff
Raw Normal View History

From 03f0aa44f6963e09a92dd3ea2090ef9ee463cb94 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
<psuarezhernandez@suse.com>
Date: Wed, 5 Jun 2019 15:15:04 +0100
Subject: [PATCH] batch.py: avoid exception when minion does not
respond (bsc#1135507)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We have several issues reporting that salt is throwing exception when
the minion does not respond. This change avoid the exception adding a
default data to the minion when it fails to respond. This patch based
on the patch suggested by @roskens.
Issues #46876 #48509 #50238
bsc#1135507
Signed-off-by: José Guilherme Vanz <jguilhermevanz@suse.com>
---
salt/cli/batch.py | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/salt/cli/batch.py b/salt/cli/batch.py
index 2bc5444aef..6285a45434 100644
--- a/salt/cli/batch.py
+++ b/salt/cli/batch.py
@@ -348,6 +348,14 @@ class Batch:
if self.opts.get("failhard") and data["retcode"] > 0:
failhard = True
+ # avoid an exception if the minion does not respond.
+ if data.get("failed") is True:
+ log.debug("Minion %s failed to respond: data=%s", minion, data)
+ data = {
+ "ret": "Minion did not return. [Failed]",
+ "retcode": salt.defaults.exitcodes.EX_GENERIC,
+ }
+
if self.opts.get("raw"):
ret[minion] = data
yield data
--
2.29.2