Details
-
Type:
Bug
-
Status: Done
-
Priority:
High
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 3.6.1
-
Component/s: Environment Detection
-
Labels:None
Description
Consider the following policy, reported by a customer:
- @runme.cf@
<pre>
body common control
{
bundlesequence =>
;
inputs =>
{ "test_modular_def.cf", "test_modular_$(def.app).cf" };
version => "Promises.cf 3.0.3";
}
</pre>
- @def.cf@
<pre>
bundle common def
{
vars:
any::
"app" string => ifelse("am_policy_hub", "hub",
"app");
reports:
"Running $(app) policy";
}
</pre>
- @hub.cf@
<pre>
bundle agent app
{
reports:
any::
"Running the hub app policy";
}
</pre>
- @app.cf@
<pre>
bundle agent app
{
reports:
any::
"Running the default app policy";
}
</pre>
Running on the policy hub, you expect it to produce @Running the hub app policy@ but instead it produces @Running the default app policy@. If you use @-Dam_policy_hub@ instead, the policy works as expected. This only happens with @am_policy_hub@; other classes unique to the hub work properly.
The reason, I believe, is that @am_policy_hub@ is discovered too late in the agent, after @GenericAgentLoadPolicy@. This is not easy to simulate in an acceptance test, unfortunately, so I wanted to check first of all if the @CheckForPolicyHub(ctx)@ call in @cf-agent/cf-agent.c@ can be moved up or maybe the policy hub check can be made earlier. If it could be done that way, the resolution of this bug is trivial.