(self, api, base_tags)
Submits service checks for Harbor individual components.
Submits service checks for Harbor individual components.
Submits service checks for Harbor individual components .
def _check_health(self, api, base_tags):
        """Submits service checks for Harbor individual components."""
        if api.harbor_version >= VERSION_1_8:
            health = api.health()
            for el in health['components']:
                component_status = AgentCheck.OK if el['status'] == HEALTHY else AgentCheck.CRITICAL
                tags = base_tags + ['component:{}'.format(el['name'])]
                self.service_check(STATUS, component_status, tags=tags)
        elif api.harbor_version >= VERSION_1_5:
            ping = api.ping()
            overall_status = AgentCheck.OK if ping == 'Pong' else AgentCheck.CRITICAL
            self.service_check(STATUS, overall_status, tags=base_tags)
            if api.with_chartrepo:
                try:
                    chartrepo_health = api.chartrepo_health()[HEALTHY]
                except HTTPError as e:
                    if e.response.status_code in (401, 403):
                        self.log.info(
                            "Provided user in harbor integration config is not an admin user. Ignoring chartrepo health"
                        )
                        self.log.debug(e, exc_info=True)
                        return
                    raise e
                chartrepo_status = AgentCheck.OK if chartrepo_health else AgentCheck.CRITICAL
                tags = base_tags + ['component:chartmuseum']
                self.service_check(STATUS, chartrepo_status, tags=tags)
        else:
            # Before version 1.5, there is no support for a health check.
            self.service_check(STATUS, AgentCheck.UNKNOWN, tags=base_tags)
def _check_health ( self , api , base_tags ) : if api . harbor_version >= VERSION_1_8 : health = api . health ( ) for el in health [ 'components' ] : component_status = AgentCheck . OK if el [ 'status' ] == HEALTHY else AgentCheck . CRITICAL tags = base_tags + [ 'component:{}' . format ( el [ 'name' ] ) ] self . service_check ( STATUS , component_status , tags = tags ) elif api . harbor_version >= VERSION_1_5 : ping = api . ping ( ) overall_status = AgentCheck . OK if ping == 'Pong' else AgentCheck . CRITICAL self . service_check ( STATUS , overall_status , tags = base_tags ) if api . with_chartrepo : try : chartrepo_health = api . chartrepo_health ( ) [ HEALTHY ] except HTTPError as e : if e . response . status_code in ( 401 , 403 ) : self . log . info ( "Provided user in harbor integration config is not an admin user. Ignoring chartrepo health" ) self . log . debug ( e , exc_info = True ) return raise e chartrepo_status = AgentCheck . OK if chartrepo_health else AgentCheck . CRITICAL tags = base_tags + [ 'component:chartmuseum' ] self . service_check ( STATUS , chartrepo_status , tags = tags ) else : # Before version 1.5, there is no support for a health check. self . service_check ( STATUS , AgentCheck . UNKNOWN , tags = base_tags )