def get_element_pids(work_dir, frontend_pid): # get element pids frontendDescript = glideinFrontendConfig.FrontendDescript(work_dir) groups = sorted(string.split(frontendDescript.data['Groups'], ',')) element_pids = {} for group in groups: try: element_pid, element_ppid = glideinFrontendPidLib.get_element_pid( work_dir, group) except RuntimeError as e: print(e) continue # report error and go to next group if element_ppid != frontend_pid: print("Group '%s' has an unexpected Parent PID: %s!=%s" % (group, element_ppid, frontend_pid)) continue # report error and go to next group element_pids[group] = element_pid return element_pids
def __init__(self, frontend_workdir='/var/lib/gwms-frontend/vofrontend'): self.frontend_workdir = frontend_workdir glideinFrontendConfig.frontendConfig.frontend_descript_file = \ os.path.join( self.frontend_workdir, glideinFrontendConfig.frontendConfig.frontend_descript_file) self.frontend_descript = glideinFrontendConfig.FrontendDescript( self.frontend_workdir) self.groups = self.frontend_descript.data['Groups'].split(',') self.groups.sort() self.group_descript = {} self.group_params_descript = {} self.group_sign_descript = {} self.group_attrs_descript = {} self.frontend_config = {'frontend': {}, 'group': {}} self.frontend_config['frontend'] = { 'frontend_name': self.frontend_descript.data['FrontendName'], 'workdir': self.frontend_workdir, 'web_url': self.frontend_descript.data['WebURL'], 'monitoring_web_url': self.frontend_descript.data['MonitoringWebURL'], } for g in self.groups: self.group_descript[ g] = glideinFrontendConfig.ElementMergedDescript( self.frontend_workdir, g) self.group_params_descript[ g] = glideinFrontendConfig.ParamsDescript( self.frontend_workdir, g) self.group_sign_descript[ g] = glideinFrontendConfig.GroupSignatureDescript( self.frontend_workdir, g) self.group_attrs_descript[g] = glideinFrontendConfig.AttrsDescript( self.frontend_workdir, g) self.frontend_config['group'][g] = { 'workdir': glideinFrontendConfig.get_group_dir(self.frontend_workdir, g), 'web_url': os.path.join(self.frontend_descript.data['WebURL'], 'group_%s' % g), 'security_name': self.group_descript[g].merged_data['SecurityName'], 'factory_collectors': self.group_descript[g].merged_data['FactoryCollectors'], 'min_running': self.group_descript[g].element_data['MinRunningPerEntry'], 'max_running': self.group_descript[g].element_data['MaxRunningPerEntry'], 'fraction_running': float(self.group_descript[g]. element_data['FracRunningPerEntry']), 'max_idle': int(self.group_descript[g].element_data['MaxIdlePerEntry']), 'reserve_idle': int(self.group_descript[g].element_data['ReserveIdlePerEntry'] ), #'idle_lifetime': int(self.group_descript[g].element_data['IdleLifetime']), 'max_vms_idle': int(self.group_descript[g].element_data['MaxIdleVMsPerEntry']), 'curb_vms_idle': int(self.group_descript[g].element_data['CurbIdleVMsPerEntry'] ), 'total_max_glideins': int(self.group_descript[g].element_data['MaxRunningTotal']), 'total_curb_glideins': int(self.group_descript[g].element_data['CurbRunningTotal']), 'total_max_vms_idle': int(self.group_descript[g].element_data['MaxIdleVMsTotal']), 'total_curb_vms_idle': int(self.group_descript[g].element_data['CurbIdleVMsTotal']), 'fe_total_max_glideins': int(self.group_descript[g].frontend_data['MaxRunningTotal']), 'fe_total_curb_glideins': int(self.group_descript[g].frontend_data['CurbRunningTotal']), 'fe_total_max_vms_idle': int(self.group_descript[g].frontend_data['MaxIdleVMsTotal']), 'fe_total_curb_vms_idle': int(self.group_descript[g].frontend_data['CurbIdleVMsTotal']), 'global_total_max_glideins': int(self.group_descript[g]. frontend_data['MaxRunningTotalGlobal']), 'global_total_curb_glideins': int(self.group_descript[g]. frontend_data['CurbRunningTotalGlobal']), 'global_total_max_vms_idle': int(self.group_descript[g]. frontend_data['MaxIdleVMsTotalGlobal']), 'global_total_curb_vms_idle': int(self.group_descript[g]. frontend_data['CurbIdleVMsTotalGlobal']), 'max_matchmakers': int(self.group_descript[g].element_data['MaxMatchmakers']), 'proxies': self.group_descript[g].merged_data['Proxies'], 'proxy_selection_plugin': self.group_descript[g].merged_data['ProxySelectionPlugin'], 'condor_config': self.group_descript[g].frontend_data['CondorConfig'], 'condor_mapfile': self.group_descript[g].element_data['MapFile'], 'classad_proxy': self.group_descript[g].frontend_data['ClassAdProxy'], 'schedds': self.group_descript[g].merged_data['JobSchedds'], 'sign_descript': { 'frontend_descript_fname': self.group_sign_descript[g].frontend_descript_fname, 'group_descript_fname': self.group_sign_descript[g].group_descript_fname, 'signature_type': self.group_sign_descript[g].signature_type, 'frontend_descript_signature': self.group_sign_descript[g].frontend_descript_signature, 'group_descript_signature': self.group_sign_descript[g].group_descript_signature, } } self.get_proxy_descript_data(g)
def main(work_dir, action): startup_time = time.time() glideinFrontendConfig.frontendConfig.frontend_descript_file = os.path.join(work_dir, glideinFrontendConfig.frontendConfig.frontend_descript_file) frontendDescript = glideinFrontendConfig.FrontendDescript(work_dir) # the log dir is shared between the frontend main and the groups, so use a subdir logSupport.log_dir = os.path.join(frontendDescript.data['LogDir'], "frontend") # Configure frontend process logging process_logs = eval(frontendDescript.data['ProcessLogs']) for plog in process_logs: logSupport.add_processlog_handler("frontend", logSupport.log_dir, plog['msg_types'], plog['extension'], int(float(plog['max_days'])), int(float(plog['min_days'])), int(float(plog['max_mbytes'])), int(float(plog['backup_count'])), plog['compression']) logSupport.log = logging.getLogger("frontend") logSupport.log.info("Logging initialized") logSupport.log.debug("Frontend startup time: %s" % str(startup_time)) try: cleanup_environ() # we use a dedicated config... ignore the system-wide os.environ['CONDOR_CONFIG'] = frontendDescript.data['CondorConfig'] sleep_time = int(frontendDescript.data['LoopDelay']) advertize_rate = int(frontendDescript.data['AdvertiseDelay']) max_parallel_workers = int(frontendDescript.data['GroupParallelWorkers']) restart_attempts = int(frontendDescript.data['RestartAttempts']) restart_interval = int(frontendDescript.data['RestartInterval']) groups = sorted(frontendDescript.data['Groups'].split(',')) glideinFrontendMonitorAggregator.config_frontend(os.path.join(work_dir, "monitor"), groups) except: logSupport.log.exception("Exception occurred configuring monitoring: ") raise glideinFrontendMonitoring.write_frontend_descript_xml( frontendDescript, os.path.join(work_dir, 'monitor/')) logSupport.log.info("Enabled groups: %s" % groups) # create lock file pid_obj = glideinFrontendPidLib.FrontendPidSupport(work_dir) # start try: pid_obj.register(action) except glideinFrontendPidLib.pidSupport.AlreadyRunning as err: pid_obj.load_registered() logSupport.log.exception("Failed starting Frontend with action %s. Instance with pid %s is aready running for action %s. Exception during pid registration: %s" % (action, pid_obj.mypid, str(pid_obj.action_type), err)) raise try: try: if action == "run": spawn(sleep_time, advertize_rate, work_dir, frontendDescript, groups, max_parallel_workers, restart_interval, restart_attempts) elif action in ('removeWait', 'removeIdle', 'removeAll', 'removeWaitExcess', 'removeIdleExcess', 'removeAllExcess'): spawn_removal(work_dir, frontendDescript, groups, max_parallel_workers, action) else: raise ValueError("Unknown action: %s" % action) except KeyboardInterrupt: logSupport.log.info("Received signal...exit") except HUPException: logSupport.log.info("Received SIGHUP, reload config") pid_obj.relinquish() os.execv( os.path.join(FRONTEND_DIR, "../creation/reconfig_frontend"), ['reconfig_frontend', '-sighupreload', '-xml', '/etc/gwms-frontend/frontend.xml'] ) except: logSupport.log.exception("Exception occurred trying to spawn: ") finally: pid_obj.relinquish()
def get_downtime_fd(work_dir): frontendDescript = glideinFrontendConfig.FrontendDescript(work_dir) fd = glideinFrontendDowntimeLib.DowntimeFile( os.path.join(work_dir, frontendDescript.data['DowntimesFile'])) return fd
def __init__(self, frontend_workdir="/var/lib/gwms-frontend/vofrontend"): self.frontend_workdir = frontend_workdir glideinFrontendConfig.frontendConfig.frontend_descript_file = os.path.join( self.frontend_workdir, glideinFrontendConfig.frontendConfig.frontend_descript_file) self.frontend_descript = glideinFrontendConfig.FrontendDescript( self.frontend_workdir) self.groups = self.frontend_descript.data["Groups"].split(",") self.groups.sort() self.group_descript = {} self.group_params_descript = {} self.group_sign_descript = {} self.group_attrs_descript = {} self.frontend_config = {"frontend": {}, "group": {}} self.frontend_config["frontend"] = { "frontend_name": self.frontend_descript.data["FrontendName"], "workdir": self.frontend_workdir, "web_url": self.frontend_descript.data["WebURL"], "monitoring_web_url": self.frontend_descript.data["MonitoringWebURL"], } for g in self.groups: self.group_descript[ g] = glideinFrontendConfig.ElementMergedDescript( self.frontend_workdir, g) self.group_params_descript[ g] = glideinFrontendConfig.ParamsDescript( self.frontend_workdir, g) self.group_sign_descript[ g] = glideinFrontendConfig.GroupSignatureDescript( self.frontend_workdir, g) self.group_attrs_descript[g] = glideinFrontendConfig.AttrsDescript( self.frontend_workdir, g) self.frontend_config["group"][g] = { "workdir": glideinFrontendConfig.get_group_dir(self.frontend_workdir, g), "web_url": os.path.join(self.frontend_descript.data["WebURL"], f"group_{g}"), "security_name": self.group_descript[g].merged_data["SecurityName"], "factory_collectors": self.group_descript[g].merged_data["FactoryCollectors"], "min_running": self.group_descript[g].element_data["MinRunningPerEntry"], "max_running": self.group_descript[g].element_data["MaxRunningPerEntry"], "fraction_running": float(self.group_descript[g]. element_data["FracRunningPerEntry"]), "max_idle": int(self.group_descript[g].element_data["MaxIdlePerEntry"]), "reserve_idle": int(self.group_descript[g].element_data["ReserveIdlePerEntry"] ), #'idle_lifetime': int(self.group_descript[g].element_data['IdleLifetime']), "max_vms_idle": int(self.group_descript[g].element_data["MaxIdleVMsPerEntry"]), "curb_vms_idle": int(self.group_descript[g].element_data["CurbIdleVMsPerEntry"] ), "total_max_glideins": int(self.group_descript[g].element_data["MaxRunningTotal"]), "total_curb_glideins": int(self.group_descript[g].element_data["CurbRunningTotal"]), "total_max_vms_idle": int(self.group_descript[g].element_data["MaxIdleVMsTotal"]), "total_curb_vms_idle": int(self.group_descript[g].element_data["CurbIdleVMsTotal"]), "fe_total_max_glideins": int(self.group_descript[g].frontend_data["MaxRunningTotal"]), "fe_total_curb_glideins": int(self.group_descript[g].frontend_data["CurbRunningTotal"]), "fe_total_max_vms_idle": int(self.group_descript[g].frontend_data["MaxIdleVMsTotal"]), "fe_total_curb_vms_idle": int(self.group_descript[g].frontend_data["CurbIdleVMsTotal"]), "global_total_max_glideins": int(self.group_descript[g]. frontend_data["MaxRunningTotalGlobal"]), "global_total_curb_glideins": int(self.group_descript[g]. frontend_data["CurbRunningTotalGlobal"]), "global_total_max_vms_idle": int(self.group_descript[g]. frontend_data["MaxIdleVMsTotalGlobal"]), "global_total_curb_vms_idle": int(self.group_descript[g]. frontend_data["CurbIdleVMsTotalGlobal"]), "max_matchmakers": int(self.group_descript[g].element_data["MaxMatchmakers"]), "proxies": self.group_descript[g].merged_data["Proxies"], "proxy_selection_plugin": self.group_descript[g].merged_data["ProxySelectionPlugin"], "condor_config": self.group_descript[g].frontend_data["CondorConfig"], "condor_mapfile": self.group_descript[g].element_data["MapFile"], "classad_proxy": self.group_descript[g].frontend_data["ClassAdProxy"], "schedds": self.group_descript[g].merged_data["JobSchedds"], "sign_descript": { "frontend_descript_fname": self.group_sign_descript[g].frontend_descript_fname, "group_descript_fname": self.group_sign_descript[g].group_descript_fname, "signature_type": self.group_sign_descript[g].signature_type, "frontend_descript_signature": self.group_sign_descript[g].frontend_descript_signature, "group_descript_signature": self.group_sign_descript[g].group_descript_signature, }, } self.get_proxy_descript_data(g)