Skip to content

Commit

Permalink
HTCONDOR-2688 Fix ClassAd passing in condor_ce_jobmetrics
Browse files Browse the repository at this point in the history
v2 ClassAds can't be pickled, so unparse them to move betwen processes.
Also fix a few imports of v1 bindings missed in previous round and stop
using xquery().
  • Loading branch information
JaimeFrey committed Nov 14, 2024
1 parent 8d0059e commit 627d034
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 7 additions & 3 deletions src/condor_ce_jobmetrics
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def process_one_schedd(ad):
except RuntimeError as e:
print(f"Failure to query CE {ad.get('Name', 'Unknown')}: {e}", file=sys.stderr)
return [total_results, vo_results, job_count,
gpu_total_results, gpu_job_count, ad]
gpu_total_results, gpu_job_count, str(ad)]


def get_ads(spooldir):
Expand Down Expand Up @@ -119,7 +119,7 @@ def list_job_results_final(job_results):
def main():
opts = parse_opts()

htcondor = __import__("htcondor")
htcondor = __import__("htcondor2")
# Check if the CEVIEW daemon is in the daemon list, exit if it is not
if htcondor.param["DAEMON_LIST"].find("CEVIEW") == -1:
print("CEVIEW is not in DAEMON_LIST, exiting...", file=sys.stderr)
Expand All @@ -136,8 +136,10 @@ def main():

map_results = pool.map(process_one_schedd, ads, 1)

import classad2 as classad

for (schedd_total_results, schedd_vo_results, schedd_job_results,
schedd_gpu_total_results, schedd_gpu_job_results, ad) in map_results:
schedd_gpu_total_results, schedd_gpu_job_results, ad_str) in map_results:

dict_sum1(schedd_total_results, total_results)
dict_sum1(schedd_gpu_total_results, gpu_total_results)
Expand All @@ -146,6 +148,8 @@ def main():
dict_sum2(schedd_job_results, job_results)
dict_sum2(schedd_gpu_job_results, gpu_job_results)

ad = classad.ClassAd(ad_str)

total_fname = rrd.check_rrd(environ, ad['Name'], "jobs")
if os.isatty(2):
print(f"Schedd {ad['Name']} totals: {schedd_total_results}", file=sys.stderr)
Expand Down
6 changes: 3 additions & 3 deletions src/htcondorce/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def totals_ce_json(environ, start_response):
objs = htcondorce.web_utils.get_schedd_objs(environ)
results = {"Running": 0, "Idle": 0, "Held": 0, "UpdateDate": time.time()}
for schedd, name in objs:
for job in schedd.xquery("true", ["JobStatus"]):
for job in schedd.query("true", ["JobStatus"]):
if job.get("JobStatus") == 1:
results['Idle'] += 1
elif job.get("JobStatus") == 2:
Expand All @@ -194,7 +194,7 @@ def pilots_ce_json(environ, start_response):
objs = htcondorce.web_utils.get_schedd_objs(environ)
job_count = {}
for schedd, name in objs:
for job in schedd.xquery('true', ['x509UserProxyVOName', 'x509UserProxyFirstFQAN', 'JobStatus', 'x509userproxysubject']):
for job in schedd.query('true', ['x509UserProxyVOName', 'x509UserProxyFirstFQAN', 'JobStatus', 'x509userproxysubject']):
DN = job.get("x509userproxysubject", 'Unknown')
VO = job.get('x509UserProxyVOName', 'Unknown')
VOMS = job.get('x509UserProxyFirstFQAN', '').replace("/Capability=NULL", "").replace("/Role=NULL", "")
Expand Down Expand Up @@ -225,7 +225,7 @@ def vos_ce_json(environ, start_response):
objs = htcondorce.web_utils.get_schedd_objs(environ)
job_count = {}
for schedd, name in objs:
for job in schedd.xquery('true', ['x509UserProxyVOName', 'JobStatus']):
for job in schedd.query('true', ['x509UserProxyVOName', 'JobStatus']):
VO = job.get('x509UserProxyVOName', 'Unknown')
job_key = VO
if job_key not in job_count:
Expand Down
2 changes: 1 addition & 1 deletion src/htcondorce/web_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def check_htcondor():
global htcondor
if not htcondor:
os.environ.setdefault('CONDOR_CONFIG', "/etc/condor-ce/condor_config")
htcondor = __import__("htcondor")
htcondor = __import__("htcondor2")
return htcondor


Expand Down

0 comments on commit 627d034

Please sign in to comment.