Skip to content

Commit

Permalink
errors | switch to use the job_summary_region function from the new r…
Browse files Browse the repository at this point in the history
…egion dash
  • Loading branch information
tkorchug committed Apr 20, 2023
1 parent 70a4649 commit cfac98b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 29 deletions.
1 change: 0 additions & 1 deletion core/pandajob/summary_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -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([])
Expand Down
27 changes: 10 additions & 17 deletions core/schedresource/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
31 changes: 20 additions & 11 deletions core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']))

Expand Down

0 comments on commit cfac98b

Please sign in to comment.