From cfac98b2b7daffb8a19dd31444c9fc9b7cfc750d Mon Sep 17 00:00:00 2001 From: Tatiana Korchuganova Date: Thu, 20 Apr 2023 11:48:51 +0200 Subject: [PATCH] errors | switch to use the job_summary_region function from the new region dash --- core/pandajob/summary_site.py | 1 - core/schedresource/utils.py | 27 ++++++++++----------------- core/views.py | 31 ++++++++++++++++++++----------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/core/pandajob/summary_site.py b/core/pandajob/summary_site.py index 6a7a8c3a..a1329d3e 100644 --- a/core/pandajob/summary_site.py +++ b/core/pandajob/summary_site.py @@ -69,7 +69,6 @@ def cloud_site_summary(query, extra='(1=1)', view='all', cloudview='region', not start_time = time.time() ucoreComputingSites, harvesterComputingSites, typeComputingSites, _ = getCRICSites() - _logger.debug('Got CRIC json: {}'.format(time.time() - start_time)) siteinfol = get_basic_info_for_pqs([]) diff --git a/core/schedresource/utils.py b/core/schedresource/utils.py index 5e3d0641..03f6fc69 100644 --- a/core/schedresource/utils.py +++ b/core/schedresource/utils.py @@ -284,24 +284,17 @@ def getCRICSites(): if not (sitesUcore and sitesHarvester and computevsAtlasCE and sitesType): sitesUcore, sitesHarvester = [], [] computevsAtlasCE, sitesType = {}, {} - url = "https://atlas-cric.cern.ch/api/atlas/pandaqueue/query/?json" - http = urllib3.PoolManager() - data = {} - try: - r = http.request('GET', url) - data = json.loads(r.data.decode('utf-8')) - for cs in data.keys(): - if 'unifiedPandaQueue' in data[cs]['catchall'] or 'ucore' in data[cs]['capability']: - sitesUcore.append(data[cs]['siteid']) - if 'harvester' in data[cs] and len(data[cs]['harvester']) != 0: - sitesHarvester.append(data[cs]['siteid']) - if 'panda_site' in data[cs]: - computevsAtlasCE[cs] = data[cs]['atlas_site'] - if 'type' in data[cs]: - sitesType[cs] = data[cs]['type'] - except Exception as exc: - print(exc) + data = get_panda_queues() + for cs in data: + if 'unifiedPandaQueue' in data[cs]['catchall'] or 'ucore' in data[cs]['capability']: + sitesUcore.append(data[cs]['siteid']) + if 'harvester' in data[cs] and len(data[cs]['harvester']) != 0: + sitesHarvester.append(data[cs]['siteid']) + if 'panda_site' in data[cs]: + computevsAtlasCE[cs] = data[cs]['atlas_site'] + if 'type' in data[cs]: + sitesType[cs] = data[cs]['type'] cache.set('sitesUcore', sitesUcore, 3600) cache.set('sitesHarvester', sitesHarvester, 3600) diff --git a/core/views.py b/core/views.py index f1af33ac..b87250f6 100644 --- a/core/views.py +++ b/core/views.py @@ -6420,25 +6420,34 @@ def errorSummary(request): _logger.info('Error summary built: {}'.format(time.time() - request.session['req_init_time'])) - # Build the state summary and add state info to site error summary + # Build the state summary by computingsite to give perspective notime = False # behave as it used to before introducing notime for dashboards. Pull only 12hrs. - statesummary = cloud_site_summary(query, extra=wildCardExtension, view=jobtype, cloudview='region', notime=notime) + # remove jobstatus from query + squery = copy.deepcopy(query) + if 'jobstatus__in' in squery: + del squery['jobstatus__in'] + jsr_queues_dict, _, _ = get_job_summary_region(squery, extra=wildCardExtension) sitestates = {} savestates = ['finished', 'failed', 'cancelled', 'holding', ] - for cloud in statesummary: - for site in cloud['sites']: - sitename = cloud['sites'][site]['name'] - sitestates[sitename] = {} - for s in savestates: - sitestates[sitename][s] = cloud['sites'][site]['states'][s]['count'] - sitestates[sitename]['pctfail'] = cloud['sites'][site]['pctfail'] + for pq, data in jsr_queues_dict.items(): + sitestates[pq] = {} + for s in savestates: + sitestates[pq][s] = 0 + if 'summary' in data and 'all' in data['summary'] and 'all' in data['summary']['all'] and s in data['summary']['all']['all']: + sitestates[pq][s] += data['summary']['all']['all'][s] + if sitestates[pq]['failed'] > 0: + sitestates[pq]['pctfail'] = round(100.0*sitestates[pq]['finished']/(sitestates[pq]['finished'] + sitestates[pq]['failed']), 2) + else: + sitestates[pq]['pctfail'] = 0 for site in errsBySite: sitename = site['name'] if sitename in sitestates: for s in savestates: - if s in sitestates[sitename]: site[s] = sitestates[sitename][s] - if 'pctfail' in sitestates[sitename]: site['pctfail'] = sitestates[sitename]['pctfail'] + if s in sitestates[sitename]: + site[s] = sitestates[sitename][s] + if 'pctfail' in sitestates[sitename]: + site['pctfail'] = sitestates[sitename]['pctfail'] _logger.info('Built errors by site summary: {}'.format(time.time() - request.session['req_init_time']))