policy_config.json
The policy_config.json file configures custom policies for resource providers for LSF resource connector. The resource policy plug-in reads this file.
<LSF_TOP>/conf/resource_connector/policy_config.json
The policy_config.json file contains a JSON list of named policies and optimizations. Policies are rules set during the calculation of demand. Optimizations are rules set after the calculation of demand to try to get better results. Each policy contains a name, a consumer, a maximum number of instances that can be launched for the consumer, and maximum number of instances that can be launched in a specified period.
Parameters
- UserDefinedScriptPath
- Optional. Specify the full path to your own resource provider policy script. Your custom policy
script runs after the default plug-in runs with the same input JSON file, and the demand that is
calculated by your script is used. Demand that is calculated by the default plug-in is ignored. If
the UserDefinedScriptPath is defined and it fails to run, the demand is 0,
which means no demand.The following example defines the path to the script userscript.py:
"UserDefinedScriptPath" : "/usr/share/lsf/10.1/scripts/userscript.py"
- Policies
- Optional. A list of policies that apply on the demand calculation. If the policies are not defined, the demand that is calculated by resource connector is used.
- If a consumer is not defined, the following attributes apply to all providers, templates,
accounts defined in the cluster:
- MaxNumber
- Optional. The maximum number of instances a user can create or launch for the consumer.
When specifying the MaxNumber parameter in the Policies parameter, you can also specify values for the perRcAccount, perTemplateName, and perProvider consumer attributes. Additionally, for the perRcAccount attribute, the value cannot be set to all; if the perRcAccount is not defined, the default value will be default.
- StepValue
- Optional. The StepValue parameter has two values, which are separated by a
colon (:). The step index is the maximum number of
instances that can be launched at a time for the defined consumer. The step time
controls how fast the cluster grows. The step time specifies how long the plug-in waits before it
launches another set of instances that are specified by the step value. If the consumer is not
defined, the parameter applies cluster wide.
For example, if step value is defined as 5 and step time is defined as 10 ("StepValue": "5:10") and a request comes in for 20 instances, 5 instances are launched in the first 10 minutes, 5 more in next 10 minutes until the demand is met or the maximum number instances that are specified by the MaxNumber parameter are launched.
The default for step index to launch all the instances at the same time.
Default Value for step time is 10 minutes. The default value that is applied only if a step value is defined but a step time is not defined.
- Optimizations
- Optional. Rules set after the calculation of demand to try to get better results. Optimizations to apply to the provisioning results.
Example
{
"UserDefinedScriptPath" : "/usr/share/lsf/10.1/scripts/userscript.py",
"Policies":
[
{
"Name": "Policy1",
"Consumer":
{
"rcAccount": ["all"],
"templateName": ["all"],
"provider": ["all"]
},
"MaxNumber": "100",
"StepValue": "5:10"
},
{
"Name": "Policy2",
"Consumer":
{
"rcAccount": ["default", "project1"],
"templateName": ["aws_template1"],
"provider": ["aws"]
},
"MaxNumber": "50",
"StepValue": "5:20"
},
{
"Name": "Policy3",
"Consumer":
{
"perRcAccount": ["project1","project2"],
"perTemplateName": ["ibm_template1","ibm_template2"],
"perProvider": ["ibmcloudhpc"]
},
"MaxNumber": "100",
"StepValue": "5:10"
}
],
"Optimizations" : {
"allocRules" : [
{
"fromTemplate": {
"provider" : "aws",
"templateName" : "aws_template1",
"factor" : 4
},
"toTemplate" : {
"provider" : "aws",
"templateName": "aws_template3",
"factor" : 1
}
},
{
"fromTemplate": {
"provider" : "aws",
"templateName" : "aws_template1",
"factor" : 2
},
"toTemplate" : {
"provider" : "aws",
"templateName": "aws_template2",
"factor" : 1
}
}
]
}
}
To view the policies and optimizations that are configured for your resource connector
policy (policy_config.json) file, run the
command:badmin rc view -c policies
An example of the
output:Policies
Name: Policy1
Consumer
rcAccount: ["all"]
templateName: ["all"]
provider: ["all"]
MaxNumber: 100
StepValue: 5:10
Name: Policy2
Consumer
rcAccount: ["default", "project1"]
templateName: ["aws_template1"]
provider: ["aws"]
MaxNumber: 50
StepValue: 5:20
Name: Policy3
Consumer
perRcAccount: ["project1", "project2"]
perTemplateName: ["ibm_template1", "ibm_template2"]
provider: ["ibmcloudhpc"]
MaxNumber: 50
StepValue: 5:20
Optimizations
4 hosts (aws:aws_template1) replaced by 1 hosts (aws:aws_template3)
2 hosts (aws:aws_template1) replaced by 1 hosts (aws:aws_template2)
In addition,
consider the RC_DEMAND_POLICY parameter in the lsf.queues
file contained the following example
configuration:RC_DEMAND_POLICY = THRESHOLD[[2,10] [4,5]]
This
configuration sets optimization to first apply four hosts with aws_template1
VMs
with one host with aws_template3
VM. Then, considers applying two hosts with
aws_template1
VMs with one hosts aws_template2
VM. The
RC_DEMAND_POLICY defined the buffer time for four jobs is shorter than two
jobs, so that when the demand trigger by four or more jobs, then the first optimization rule is
applied; otherwise, the second optimization rule is applied.