Support for Context Albums across policy sets in Apex
POLICY-4765: Support for Context Albums across policy sets in ApexClosed
Description
apex-pdp has a concept of global context but doesn't have a mechanism for declaring and sharing context across policy sets in the same JVM.
If policies are deployed independently they should be able to share context between them.
Technically this should not be an issue in the Apex,but currently there is no way of declaring and/or passing a reference to the context hashmaps between apex engines.
In this story we investigate and implement this improvement.
Investigation
Procedure
Spin up docker-compose environment for testing
Create two policies that share a context album
Deploy both policies
Determine is Policy A can access context modified by Policy B
Steps
Modify DecisionMaker Policy
Split into two seperate policies:
One which contains the answer logic
One which contains the decision logic
Deploy both policies in single Apex engine
Policy A and Policy B will both share the AnswerAlbum Context
Set the answers using Policy A which contains the logic to set the answers. Policy B does not contain this logic.
Make a decision using Policy B. This will choose an answer from the AnswerAlbum.
Step | Description | Result |
|---|---|---|
Modify DecisionMaker Policy |
| |
Other Changes |
| |
Deploy both policies | Deploy both policies on single Apex instance | Result{
"groups": [
{
"name": "defaultGroup",
"description": "The default group that registers all supported policy types and pdps.",
"pdpGroupState": "ACTIVE",
"properties": {},
"pdpSubgroups": [
{
"pdpType": "apex",
"supportedPolicyTypes": [
{
"name": "onap.policies.controlloop.operational.common.Apex",
"version": "1.0.0"
},
{
"name": "onap.policies.native.Apex",
"version": "1.0.0"
}
],
"policies": [
{
"name": "onap.policies.native.apex.DecisionMakerTwo",
"version": "1.0.0"
},
{
"name": "onap.policies.native.apex.DecisionMaker",
"version": "1.0.0"
}
],
"currentInstanceCount": 1,
"desiredInstanceCount": 1,
"properties": {},
"pdpInstances": [
{
"instanceId": "apex-a309a391-a1d3-4a90-8acb-07cfc2326c9b",
"pdpState": "ACTIVE",
"healthy": "HEALTHY",
"message": "Pdp Heartbeat",
"lastUpdate": "2023-09-13T11:16:13Z"
}
]
}
]
}
]
} |
Set Answers (Policy A) | Use Policy A to set the answers | Logs[2023-09-13T11:18:13.556+00:00|INFO|RequestLog|qtp1245550638-104] 172.30.0.1 - - [13/Sep/2023:11:18:13 +0000] "OPTIONS /apex/RESTConsumer/EventIn HTTP/1.1" 200 1022 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0"
[2023-09-13T11:18:13.565+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-5:0] AnswerInitTask:0.0.1
[2023-09-13T11:18:13.565+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-5:0] {a0=Never Ever Answer01, a1=No Answer01, a2=Maybe not Answer01, a3=Waiting Answer01, a4=Maybe Answer01, a5=Yes Answer01, a6=Absolutely Answer01}
[2023-09-13T11:18:13.566+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-5:0] {a0=Never Ever Answer01, a1=No Answer01, a2=Maybe not Answer01, a3=Waiting Answer01, a4=Maybe Answer01, a5=Yes Answer01, a6=Absolutely Answer01}
[2023-09-13T11:18:13.666+00:00|INFO|RequestLog|qtp1245550638-82] 172.30.0.1 - - [13/Sep/2023:11:18:13 +0000] "POST /apex/RESTConsumer/EventIn HTTP/1.1" 200 369 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0"
|
Make Decision (Policy B) | Use Policy B to select an answer |
|
|
|
|
Conclusion
Apex-pdp engine is capable of sharing context across separate policy sets running in the same apex-pdp engine.
No further changes are required.