From 3469c8ab2bb296f5a5eddc9f320c8b7e121fb38c Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 14 Apr 2021 15:51:18 -0400 Subject: [PATCH] Fix affluent communication Affluent would hang on error, particularly certificate problem. Fix by catching and being explicit about the error, and generically fixing the arguments for 'get' to have the inntended timeout. --- .../confluent/plugins/hardwaremanagement/affluent.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/plugins/hardwaremanagement/affluent.py b/confluent_server/confluent/plugins/hardwaremanagement/affluent.py index 1df4a4bf..bf4e56ae 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/affluent.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/affluent.py @@ -36,7 +36,14 @@ class WebClient(object): self.wc.set_basic_credentials(creds[node]['secret.hardwaremanagementuser']['value'], creds[node]['secret.hardwaremanagementpassword']['value']) def fetch(self, url, results): - rsp, status = self.wc.grab_json_response_with_status(url) + try: + rsp, status = self.wc.grab_json_response_with_status(url) + except exc.PubkeyInvalid: + results.put(msg.ConfluentNodeError(self.node, + 'Extended information unavailable, mismatch detected between ' + 'target certificate fingerprint and ' + 'pubkeys.tls_hardwaremanager attribute')) + return {} if status == 401: results.put(msg.ConfluentTargetInvalidCredentials(self.node, 'Unable to authenticate')) return {} @@ -91,7 +98,7 @@ def retrieve(nodes, element, configmanager, inputdata): return while workers: try: - datum = results.get(10) + datum = results.get(block=True, timeout=10) while datum: if datum: yield datum