Skip to content

Commit 4339994

Browse files
authored
Merge pull request #633 from htcondor/V24_x-HTCONDOR-2688-fix-tests
HTCONDOR-2688 fix-tests
2 parents 5e14c56 + 92a9a97 commit 4339994

File tree

3 files changed

+2
-178
lines changed

3 files changed

+2
-178
lines changed

Diff for: src/htcondorce/web.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
_view = None
2323
_plugins = []
2424
OK_STATUS = '200 OK'
25+
_jinja_env = None
26+
multice = None
2527

2628
log = logging.getLogger(__name__)
2729
log.setLevel(logging.DEBUG)
@@ -90,7 +92,6 @@ def validate_plugin(name, plugin):
9092
def check_initialized(environ):
9193
global _initialized
9294
global _jinja_env
93-
global _cp
9495
global _plugins
9596
global htcondor
9697
global multice

Diff for: src/verify_ce_config.py

-105
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import re
99
import sys
1010

11-
from collections import defaultdict
12-
1311

1412
def error(msg):
1513
"""Exit with error 'msg'
@@ -29,30 +27,8 @@ def debug(msg):
2927
print("DEBUG: " + msg)
3028

3129

32-
def parse_route_names(entries_config):
33-
"""Return names of job routes that can be parsed as proper ClassAds
34-
"""
35-
try:
36-
return [x['Name'] for x in classad.parseAds(entries_config)]
37-
except KeyError:
38-
error("Name is a required field for all entries in JOB_ROUTER_ENTRIES")
39-
40-
41-
def find_malformed_entries(entries_config):
42-
"""Find all unparseable router entries based on the raw JOB_ROUTER_ENTRIES configuration
43-
"""
44-
unparsed_names = [x.replace('"', '')
45-
for x in re.findall(r'''name\s*=\s*["'](\w+)["']''',
46-
entries_config,
47-
re.IGNORECASE)]
48-
parsed_names = parse_route_names(entries_config)
49-
50-
return set(unparsed_names) - set(parsed_names)
51-
52-
5330
# Verify that the HTCondor Python bindings are in the PYTHONPATH
5431
try:
55-
import classad2 as classad
5632
import htcondor2 as htcondor
5733
except ImportError:
5834
error("Could not load HTCondor Python bindings. "
@@ -65,7 +41,6 @@ def main():
6541
is_osg = htcondor.param.get('OSG_CONFIGURE_PRESENT', '').lower() in ('true', 'yes', '1')
6642

6743
# Create dict whose values are lists of ads specified in the relevant JOB_ROUTER_* variables
68-
parsed_jr_ads = defaultdict(list)
6944
jr_transforms = {key : value for key, value in htcondor.param.items() if key.startswith("JOB_ROUTER_ROUTE_")}
7045

7146
# If JOB_ROUTER_ROUTE_<name> rules are defined, verify that these transforms exist
@@ -76,86 +51,6 @@ def main():
7651
if not route_def:
7752
warn(f"The route {name} is specified in JOB_ROUTER_ROUTE_NAMES, but no corresponding JOB_ROUTER_ROUTE_{name} exists")
7853

79-
# If no JOB_ROUTER_ROUTE_<name> rules exist, verify JOB_ROUTER_DEFAULTS and JOB_ROUTER_ENTRIES
80-
else:
81-
used_deprecated_knobs = []
82-
for knob in ['JOB_ROUTER_DEFAULTS', 'JOB_ROUTER_ENTRIES', 'JOB_ROUTER_ENTRIES_CMD','JOB_ROUTER_ENTRIES_FILE']:
83-
if knob in htcondor.param:
84-
used_deprecated_knobs.append(knob)
85-
if len(used_deprecated_knobs) > 0:
86-
warn(f"{', '.join(used_deprecated_knobs)} are deprecated and will be removed for V24 of the HTCondor Software Suite. New configuration"
87-
+ " syntax for the job router is defined using JOB_ROUTER_ROUTE_NAMES and JOB_ROUTER_ROUTE_<name>. For example"
88-
+ " use of new syntax visit:\nhttps://htcondor.readthedocs.io/en/latest/grid-computing/job-router.html#an-example-configuration\n\n"
89-
+ " Note: The removal will occur during the lifetime of the HTCondor V23 feature series.\n")
90-
91-
for attr in ['JOB_ROUTER_DEFAULTS', 'JOB_ROUTER_ENTRIES']:
92-
try:
93-
config_val = htcondor.param[attr]
94-
except KeyError:
95-
error("Missing %s configuration value. " % attr)
96-
continue
97-
98-
# store the ads (iterating through ClassAdStringIterator consumes them)
99-
if attr != "JOB_ROUTER_ENTRIES":
100-
try:
101-
parsed_jr_ads[attr] = list(classad.parseAds(config_val))
102-
except ValueError:
103-
# We shouldn't ever get here since classad.parseAds() only raises ValueError when it's given
104-
# non-string/non-file output and htcondor.param shouldn't contain such values
105-
debug("Failed to parse %s configuration value. " % attr)
106-
107-
# If JRD or JRE can't be parsed, the job router can't function
108-
if not parsed_jr_ads[attr]:
109-
debug("Could not read %s in the HTCondor-CE configuration. " % attr)
110-
111-
if attr == "JOB_ROUTER_ENTRIES":
112-
# Warn about routes we can find in the config that don't result in valid ads
113-
malformed_entry_names = find_malformed_entries(config_val)
114-
if malformed_entry_names:
115-
warn("Could not read JOB_ROUTER_ENTRIES in the HTCondor-CE configuration. " +
116-
"Failed to parse the following routes: %s"
117-
% ', '.join(malformed_entry_names))
118-
119-
# Warn about routes specified by JOB_ROUTER_ROUTE_NAMES that don't appear in the parsed JRE.
120-
# The job router can function this way but it's likely a config error
121-
route_order = htcondor.param.get('JOB_ROUTER_ROUTE_NAMES', '')
122-
if route_order:
123-
missing_route_def = set(route_order.replace(',',' ').split()).difference(set(parse_route_names(config_val)))
124-
if missing_route_def:
125-
warn("The following are specified in JOB_ROUTER_ROUTE_NAMES "
126-
"but cannot be found in JOB_ROUTER_ENTRIES: %s"
127-
% ', '.join(missing_route_def))
128-
129-
# Find all eval_set_ attributes in the JOB_ROUTER_DEFAULTS
130-
eval_set_defaults = set([x.lstrip('eval_') for x in parsed_jr_ads['JOB_ROUTER_DEFAULTS'][0].keys()
131-
if x.startswith('eval_set_')])
132-
133-
# Find all default_ attributes used in expressions in the JOB_ROUTER_DEFAULTS
134-
default_attr = set([re.sub(r'.*(default_\w*).*', 'eval_set_\\1', str(x))
135-
for x in parsed_jr_ads['JOB_ROUTER_DEFAULTS'][0].values()
136-
if isinstance(x, classad.ExprTree) and "default_" in str(x)])
137-
138-
for entry in parsed_jr_ads['JOB_ROUTER_ENTRIES']:
139-
# Warn users if they've set_ attributes that would be overriden by eval_set in the JOB_ROUTER_DEFAULTS
140-
overriden_attr = eval_set_defaults.intersection(set(entry.keys()))
141-
if overriden_attr:
142-
warn("%s in JOB_ROUTER_ENTRIES will be overriden by the JOB_ROUTER_DEFAULTS."
143-
% ', '.join(overriden_attr)
144-
+ " Use the 'eval_set_' prefix instead.")
145-
146-
# Ensure that users don't set the job environment in the Job Router
147-
if is_osg and any(x.endswith('environment') for x in entry.keys()):
148-
warn("Do not use the Job Router to set the environment. See documentation for more details: "
149-
+ "https://htcondor.github.io/htcondor-ce/v5/configuration/writing-job-routes/#setting-job-environments")
150-
151-
# Warn users about eval_set_ default attributes in the ENTRIES since their
152-
# evaluation may occur after the eval_set_ expressions containg them in the
153-
# JOB_ROUTER_DEFAULTS
154-
no_effect_attr = default_attr.intersection(set([x for x in entry.keys() if x.startswith('eval_set_')]))
155-
if no_effect_attr:
156-
warn("%s in JOB_ROUTER_ENTRIES " % ', '.join(no_effect_attr)
157-
+ "may not have any effect. Use the 'set_' prefix instead.")
158-
15954
# Warn users on OSG CEs if osg-configure has not been run
16055
if is_osg:
16156
try:

Diff for: tests/test_verify_ce_config.py

-72
This file was deleted.

0 commit comments

Comments
 (0)