[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [HTCondor-users] Windows: Non-standard installation + config path
- Date: Fri, 19 Feb 2016 12:46:51 -0600
- From: Todd Tannenbaum <tannenba@xxxxxxxxxxx>
- Subject: Re: [HTCondor-users] Windows: Non-standard installation + config path
On 2/19/2016 11:27 AM, Jens Schmaler wrote:
> My idea was to have an additional environment
> variable on machines with non-standard config file location. If this
> variable is set, I would like to use it to define the config file,
> otherwise I would fall back to the default:
> CUSTOM_CONFIG = $ENV(CONDOR_CUSTOM_CONFIG)
> LOCAL_CONFIG_FILE = ifThenElse( $(CUSTOM_CONFIG) =!= Undefined,
> $(CUSTOM_CONFIG), $(DEFAULT_CONFIG) )
> Unfortunately, this does not work. The ifThenElse does not get
> evaluated, so condor_config_val still shows me the literal "ifThenElse"
> expression instead of the desired result. Can someone explain this? Is
> it at all possible to use conditional clauses in config files or is this
> restricted to class ads?
The issue is the "ifthenelse()" function is a ClassAd function; it can only be used in ClassAd expressions.
Conditionals can exist in the config file, but the syntax is different because config files are not ClassAds; see section 3.3.1 of the HTCondor Manual for the config file syntax at URL http://is.gd/ffZbg1.
=== SOLUTION ONE
Here is what I'd suggest to achieve what you want:
Since any config file knob names XXX can be overridden via an environment variable that starts with "_condor_XXX", I'd suggest leaving LOCAL_CONFIG_FILE set to your default. If a machine wants to override it via the environment, just redefine it via an environment variable like so (from bash)
Most people should stop reading here :)
== SOLUTION TWO
You are still reading???
Well, if you want a solution with the approach Jens was pursuing, there are a few things to know:
1) The way you can use all the power of ClassAd expressions inside your condor configuration is via $INT() and $REAL(); these config macros use the ClassAd parser to evaluate their first argument.
2) $ENV(X) will return the string UNDEFINED if X is not defined. Personally I think this is a bug that should someday be fixed so the empty string is returned instead of UNDEFINED.
So you COULD solve the issue as follows:
DEFAULT_CONFIG = $(LOCAL_DIR)/condor_config.local
CUSTOM_CONFIG = $ENV(CONDOR_CUSTOM_CONFIG)
HAVE_CUSTOM_CONFIG = size("$(CUSTOM_CONFIG)") && "$(CUSTOM_CONFIG)"!="UNDEFINED"
LOCAL_CONFIG_FILE = $(CUSTOM_CONFIG)
LOCAL_CONFIG_FILE = $(DEFAULT_CONFIG)
Note in the above I am leveraging the "trick" that $INT() allows me to use ClassAd functions.
Of course, the above is really pretty ugly syntax and rather black magic, which is why sane people would simply go with solution one. But I wrote up solution two just as a learning exercise.
hope the above helps,