diff --git a/base/server/healthcheck/pki/server/healthcheck/clones/connectivity_and_data.py b/base/server/healthcheck/pki/server/healthcheck/clones/connectivity_and_data.py index 800046c074f..d9bb480f7f9 100644 --- a/base/server/healthcheck/pki/server/healthcheck/clones/connectivity_and_data.py +++ b/base/server/healthcheck/pki/server/healthcheck/clones/connectivity_and_data.py @@ -21,7 +21,6 @@ class ClonesConnectivyAndDataCheck(ClonesPlugin): Assure master and clones within a pki instance are reachable """ def check_ca_clones(self): - host_error = [] for host in self.clone_cas: cur_clone_msg = ' Host: ' + host.Hostname + ' Port: ' + host.SecurePort # Reach out and get some certs, to serve as a data and connectivity check @@ -41,13 +40,11 @@ def check_ca_clones(self): raise BaseException('CA clone problem reading data.' + cur_clone_msg) except BaseException as e: logger.error("Internal server error %s", e) - host_error.append( - BaseException('Internal error testing CA clone.' + cur_clone_msg)) + raise BaseException('Internal error testing CA clone.' + cur_clone_msg) - return host_error + return def check_kra_clones(self): - host_error = [] for host in self.clone_kras: url = 'https://' + host.Hostname + ':' + host.SecurePort @@ -61,15 +58,13 @@ def check_kra_clones(self): logger.info('KRA at %s is %s', url, status) if status != 'running': - raise BaseException('KRA at %s is %s' % (url, status)) + raise Exception('KRA at %s is %s' % (url, status)) - except BaseException as e: + except Exception as e: logger.error('Unable to reach KRA at %s: %s', url, e) - host_error.append(BaseException('Unable to reach KRA at %s: %s' % (url, e))) - return host_error + raise Exception('Unable to reach KRA at %s: %s' % (url, e)) def check_ocsp_clones(self): - host_error = [] for host in self.clone_ocsps: url = 'https://' + host.Hostname + ':' + host.SecurePort @@ -83,15 +78,13 @@ def check_ocsp_clones(self): logger.info('OCSP at %s is %s', url, status) if status != 'running': - raise BaseException('OCSP at %s is %s' % (url, status)) + raise Exception('OCSP at %s is %s' % (url, status)) - except BaseException as e: + except Exception as e: logger.error('Unable to reach OCSP at %s: %s', url, e) - host_error.append(BaseException('Unable to reach OCSP at %s: %s' % (url, e))) - return host_error + raise Exception('Unable to reach OCSP at %s: %s' % (url, e)) def check_tks_clones(self): - host_error = [] for host in self.clone_tkss: url = 'https://' + host.Hostname + ':' + host.SecurePort @@ -105,15 +98,13 @@ def check_tks_clones(self): logger.info('TKS at %s is %s', url, status) if status != 'running': - raise BaseException('TKS at %s is %s' % (url, status)) + raise Exception('TKS at %s is %s' % (url, status)) - except BaseException as e: + except Exception as e: logger.error('Unable to reach TKS at %s: %s', url, e) - host_error.append(BaseException('Unable to reach TKS at %s: %s' % (url, e))) - return host_error + raise Exception('Unable to reach TKS at %s: %s' % (url, e)) def check_tps_clones(self): - host_error = [] for host in self.clone_tpss: url = 'https://' + host.Hostname + ':' + host.SecurePort @@ -127,12 +118,11 @@ def check_tps_clones(self): logger.info('TPS at %s is %s', url, status) if status != 'running': - raise BaseException('TPS at %s is %s' % (url, status)) + raise Exception('TPS at %s is %s' % (url, status)) - except BaseException as e: + except Exception as e: logger.error('Unable to reach TPS at %s: %s', url, e) - host_error.append(BaseException('Unable to reach TPS at %s: %s' % (url, e))) - return host_error + raise Exception('Unable to reach TPS at %s: %s' % (url, e)) @duration def check(self): @@ -157,55 +147,51 @@ def check(self): logger.info('About to check the subsystem clones') hard_msg = ' Clones tested successfully, or not present.' - host_error = self.check_ca_clones() - if not host_error: + try: + self.check_ca_clones() yield Result(self, constants.SUCCESS, instance_name=self.instance.name, status='CA' + hard_msg) - else: - for err in host_error: - yield Result(self, constants.ERROR, - status='ERROR: %s' % self.instance.name + ' : ' + str(err)) - host_error = self.check_kra_clones() - if not host_error: + except BaseException as e: + yield Result(self, constants.ERROR, + status='ERROR: %s' % self.instance.name + ' : ' + str(e)) + + try: + self.check_kra_clones() yield Result(self, constants.SUCCESS, instance_name=self.instance.name, status='KRA' + hard_msg) - else: - for err in host_error: - yield Result(self, constants.ERROR, - status='ERROR: %s' % self.instance.name + ' : ' + str(err)) + except BaseException as e: + yield Result(self, constants.ERROR, + status='ERROR: %s' % self.instance.name + ' : ' + str(e)) - host_error = self.check_ocsp_clones() - if not host_error: + try: + self.check_ocsp_clones() yield Result(self, constants.SUCCESS, instance_name=self.instance.name, status='OCSP' + hard_msg) - else: - for err in host_error: - yield Result(self, constants.ERROR, - status='ERROR: %s' % self.instance.name + ' : ' + str(err)) + except BaseException as e: + yield Result(self, constants.ERROR, + status='ERROR: %s' % self.instance.name + ' : ' + str(e)) - host_error = self.check_tks_clones() - if not host_error: + try: + self.check_tks_clones() yield Result(self, constants.SUCCESS, instance_name=self.instance.name, status='TKS' + hard_msg) - else: - for err in host_error: - yield Result(self, constants.ERROR, - status='ERROR: %s' % self.instance.name + ' : ' + str(err)) + except BaseException as e: + yield Result(self, constants.ERROR, + status='ERROR: %s' % self.instance.name + ' : ' + str(e)) - host_error = self.check_tps_clones() - if not host_error: + try: + self.check_tps_clones() yield Result(self, constants.SUCCESS, instance_name=self.instance.name, status="TPS Clones tested successfully, or not present.") - else: - for err in host_error: - yield Result(self, constants.ERROR, - status='ERROR: %s' % self.instance.name + ' : ' + str(err)) + except BaseException as e: + yield Result(self, constants.ERROR, + status='ERROR: %s' % self.instance.name + ' : ' + str(e)) else: yield Result(self, constants.SUCCESS, instance_name=self.instance.name,