def shouldHibernate(frontendDescript, work_dir, ha, mode, groups): """ Check if the frontend is running in HA mode. If run in master mode never hibernate. If run in slave mode, hiberate if master is active. @rtype: bool @return: True if we should hibernate else False """ if mode == "slave": master_frontend_name = ha.get("ha_frontends")[0].get("frontend_name") for group in groups: element = glideinFrontendElement(os.getpid(), work_dir, group, "run") # Set environment required to query factory collector set_frontend_htcondor_env(work_dir, frontendDescript, element) for factory_pool in element.factory_pools: try: factory_pool_node = factory_pool[0] master_classads = glideinFrontendInterface.findMasterFrontendClassads( factory_pool_node, master_frontend_name ) if master_classads: # Found some classads in one of the collectors # Cleanup the env and return True clean_htcondor_env() return True except RuntimeError: # Failed to talk if not factory_pool_node: factory_pool_node = "" msg = "Failed to talk to the factory_pool %s to get the status of Master frontend %s" % ( factory_pool_node, master_frontend_name, ) logSupport.log.warn(msg) msg = "Exception talking to the factory_pool %s to get the status of Master frontend %s: " % ( factory_pool_node, master_frontend_name, ) logSupport.log.exception(msg) # Cleanup the env clean_htcondor_env() # NOTE: # If we got this far with no errors then we could not find # active master frontend. We should not hibernate as slave # However, if there were errors checking with factory pool # then the master frontend could be down so its safe to wake # up and start advertising. return False
def set_frontend_htcondor_env(work_dir, frontendDescript, element=None): # Collector DN is only in the group's mapfile. Just get first one. groups = frontendDescript.data["Groups"].split(",") if groups: if element is None: element = glideinFrontendElement(os.getpid(), work_dir, groups[0], "run") htc_env = { "CONDOR_CONFIG": frontendDescript.data["CondorConfig"], "X509_USER_PROXY": frontendDescript.data["ClassAdProxy"], "_CONDOR_CERTIFICATE_MAPFILE": element.elementDescript.element_data["MapFile"], } set_env(htc_env)
def set_frontend_htcondor_env(work_dir, frontendDescript, element=None): # Collector DN is only in the group's mapfile. Just get first one. groups = frontendDescript.data['Groups'].split(',') if groups: if element is None: element = glideinFrontendElement(os.getpid(), work_dir, groups[0], "run") htc_env = { 'CONDOR_CONFIG': frontendDescript.data['CondorConfig'], 'X509_USER_PROXY': frontendDescript.data['ClassAdProxy'], '_CONDOR_CERTIFICATE_MAPFILE': element.elementDescript.element_data['MapFile'] } set_env(htc_env)
def shouldHibernate(frontendDescript, work_dir, ha, mode, groups): """ Check if the frontend is running in HA mode. If run in master mode never hibernate. If run in slave mode, hiberate if master is active. @rtype: bool @return: True if we should hibernate else False """ if mode == 'slave': master_frontend_name = ha.get('ha_frontends')[0].get('frontend_name') for group in groups: element = glideinFrontendElement(os.getpid(), work_dir, group, "run") os.environ['CONDOR_CONFIG'] = element.elementDescript.frontend_data['CondorConfig'] os.environ['_CONDOR_CERTIFICATE_MAPFILE'] = element.elementDescript.element_data['MapFile'] os.environ['X509_USER_PROXY'] = element.elementDescript.frontend_data['ClassAdProxy'] for factory_pool in element.factory_pools: factory_pool_node = factory_pool[0] master_classads = glideinFrontendInterface.findMasterFrontendClassads(factory_pool_node, master_frontend_name) if master_classads: # Found some classads in one of the collectors # Cleanup the env and return True clean_htcondor_env() return True # Cleanup the env clean_htcondor_env() return False