Configuring jobs to require certain hosts, or visa-versa
Matchmaking is bilateral — that is, both jobs and hosts can express their own requirements of one another, and can advertise their own attributes for one another’s reference.
A platform_job’s Requirements expression specifies its requirements of a host to run on. In Metronome, you can easily add a new constraint to the platform_job’s Requirements expression via the append_requirements command in the run specification file, like so:
append_requirements = (host_attribute =?= "bar")
This tells Condor to make sure that the job only runs on a host whose host_attribute equals “bar”.
Likewise, a host’s START expression specifies its requirements of a job. To add a new constraint to the host’s START expression, you should edit the host’s condor_config (or condor_config.local) file, like so:
START = ( $(START) && job_attribute =?= "foo" )
This tells Condor to make sure that the host only receives jobs whose job_attribute equals “foo”.
To advertise a new job attribute (so you can reference it in a host’s START expression), just add it via the ++ command in the run specification file, like so:
++job_attribute = "foo"
To advertise a new host atttribute (so you can reference it in a job’s Requirements expression), just add it to the host’s condor_config (or condor_config.local) file. like so:
host_attribute = "bar"
STARTD_EXPRS = $(STARTD_EXPRS) host_attribute
Additional Notes
What is =?= and How Is It Different From ==?
The short answer: Use =?=, not ==.
The long answer: In the boolean logic of Condor classads, expressions can evaluate to True, False, or Undefined. If an expression references an attribute which isn’t defined, the value of that expression becomes Undefined. Therefore, if you say:
START = (job_color == "Red")
...and job_color is not defined in the job ad, then START will evaluate to Undefined rather than false.
To avoid this, Condor classads provides a =?= variant of the equality operator which will evaluate to False if one half is Undefined, rather than evaluating to Undefined. So if you say:
START = (job_color =?= "Red")
...and job_color is not defined in the job ad, then START will evaluate to False rather than Undefined.
Likewise for =!= and !=.
Debugging
Although it’s not needed for correctness, for debugging you might also want to add the following to the host’s condor config_config:
STARTD_JOB_ATTRS = $(STARTD_JOB_ATTRS) job_attribute
This will tell the host to publish the job_owner attribute of any currently running job in its own host classad, so you can see it. This can make it easier to confirm that the job that is currently running has the attribute you expect, without having to look up the jobid and examine its classad separately using condor_q -l. The only thing to be careful about is any attribute names which are present in both the host and job classads, because only one can be published in the machine classad. This is one good reason to name job attributes and host attributes with job_ or host_ prefixes.
- Printer-friendly version
- Login or register to post comments
