Guidelines for PDP-PAP interaction

A PDP (Policy Decision Point) is where the policy execution happens. The administrative actions such as managing the PDPs, deploying or undeploying policies to these PDPs etc. are handled by PAP (Policy Administration Point). Any PDP should follow certain behavior to be registered and functional in the Policy Framework. All the communications between PAP and PDP happen over DMaaP on topic POLICY-PDP-PAP. The below diagram shows how a PDP interacts with PAP.

../../_images/PDP_PAP.svg

1. Start PDP

A PDP should be configured to start with the below information in its startup configuration file.

  • pdpGroup to which the PDP should belong to.

  • DMaaP topic ‘POLICY-PDP-PAP’ which should be the source and sink for communicating with PAP.

2. PDP sends PDP_STATUS (registration message)

As soon as a PDP is up, it sends a registration message to POLICY-PDP-PAP topic. Some of the information included in the message are:

  • pdpType the type of the PDP (apex/drools/xacml etc.).

  • pdpGroup to which the PDP should belong to.

  • state the initial state of the PDP which is PASSIVE.

  • healthy whether the PDP is “HEALTHY” or not.

  • name a name that is unique to the PDP instance.

Sample PDP_STATUS Registration message (from APEX-PDP)
 1  {
 2    "pdpType": "apex",
 3    "state": "PASSIVE",
 4    "healthy": "HEALTHY",
 5    "description": "Pdp Heartbeat",
 6    "statistics": {
 7      ..... Omitted for brevity
 8    },
 9    "messageName": "PDP_STATUS",
10    "requestId": "54926ad0-440f-4b40-9237-40ca754ad00d",
11    "timestampMs": 1632325024286,
12    "name": "apex-45c6b266-a5fa-4534-b22c-33c2f9a45d02",
13    "pdpGroup": "defaultGroup"
14  }

3. PAP sends PDP_UPDATE message

On receiving the registration message from a PDP, PAP checks and assigns it to a subgroup under the group. If there are policies that were already deployed (for e.g. previously deployed, and the PDP is restarted) under the subgroup, then the policiesToBeDeployed are also sent along with the subgroup it is assigned to. PAP also sends the pdpHeartbeatIntervalMs which is the time interval in which PDPs should send heartbeats to PAP.

Sample PDP_UPDATE message (for APEX-PDP)
 1  {
 2    "source": "pap-56c8531d-5376-4e53-a820-6973c62bfb9a",
 3    "pdpHeartbeatIntervalMs": 120000,
 4    "policiesToBeDeployed": [],
 5    "messageName": "PDP_UPDATE",
 6    "requestId": "3534e54f-4432-4c68-81c8-a6af07e59fb2",
 7    "timestampMs": 1632325037040,
 8    "name": "apex-45c6b266-a5fa-4534-b22c-33c2f9a45d02",
 9    "pdpGroup": "defaultGroup",
10    "pdpSubgroup": "apex"
11  }

4. PDP sends PDP_STATUS response to PDP_UPDATE

PDP on receiving the PDP_UPDATE message from the DMaaP topic, it first checks if the message is intended for the PDP. If so, it updates itself with the information in PDP_UPDATE message from PAP such as pdpSubgroup, pdpHeartbeatIntervalMs and policiesToBeDeployed (if any). After handling the PDP_UPDATE message, the PDP sends a response message back to PAP with the current status of the PDP along with the result of the PDP_UPDATE operation.

Sample PDP_STATUS response message (from APEX-PDP)
 1  {
 2    "pdpType": "apex",
 3    "state": "PASSIVE",
 4    "healthy": "HEALTHY",
 5    "description": "Pdp status response message for PdpUpdate",
 6    "policies": [],
 7    "statistics": {
 8      ..... Omitted for brevity
 9    },
10    "response": {
11      "responseTo": "3534e54f-4432-4c68-81c8-a6af07e59fb2",
12      "responseStatus": "SUCCESS",
13      "responseMessage": "Pdp update successful."
14    },
15    "messageName": "PDP_STATUS",
16    "requestId": "e3c72783-4e91-4cb5-8140-e4ac0630706d",
17    "timestampMs": 1632325038075,
18    "name": "apex-45c6b266-a5fa-4534-b22c-33c2f9a45d02",
19    "pdpGroup": "defaultGroup",
20    "pdpSubgroup": "apex"
21  }

5. PAP sends PDP_STATE_CHANGE message

PAP sends PDP_STATE_CHANGE message to PDPs to change the state from PASSIVE to active or ACTIVE to PASSIVE. When a PDP is in PASSIVE state, the policy execution will not happen. All PDPs start up in PASSIVE state, and they can be changed to ACTIVE/PASSIVE using PAP. After registration is complete, PAP makes a PDP ACTIVE by default.

Sample PDP_STATE_CHANGE message
 1  {
 2    "source": "pap-56c8531d-5376-4e53-a820-6973c62bfb9a",
 3    "state": "ACTIVE",
 4    "messageName": "PDP_STATE_CHANGE",
 5    "requestId": "90eada6d-bb98-4750-a4e1-b439cb5e041d",
 6    "timestampMs": 1632325037040,
 7    "name": "apex-45c6b266-a5fa-4534-b22c-33c2f9a45d02",
 8    "pdpGroup": "defaultGroup",
 9    "pdpSubgroup": "apex"
10  }

6. PDP sends PDP_STATUS response to PDP_STATE_CHANGE

PDP updates its state as per the PDP_STATE_CHANGE received from PAP. When a PDP is changed to ACTIVE, any policies that are already pushed to the PDP start execution and start processing events as per the policies deployed. If no policies are running in a PDP, then it waits in ACTIVE state, ready to execute any policies as and when they are pushed to them from PAP. After handling the PDP_STATE_CHANGE message, the PDP sends a response message back to PAP with the current status of the PDP along with the result of the PDP_STATE_CHANGE operation.

Sample PDP_STATUS response message (from APEX-PDP)
 1  {
 2    "pdpType": "apex",
 3    "state": "ACTIVE",
 4    "healthy": "HEALTHY",
 5    "description": "Pdp status response message for PdpStateChange",
 6    "policies": [],
 7    "statistics": {
 8      ..... Omitted for brevity
 9    },
10    "response": {
11      "responseTo": "90eada6d-bb98-4750-a4e1-b439cb5e041d",
12      "responseStatus": "SUCCESS",
13      "responseMessage": "State changed to active. No policies are running."
14    },
15    "messageName": "PDP_STATUS",
16    "requestId": "8a88806c-4d3e-4c80-8048-dc85d4bb75dd",
17    "timestampMs": 1632325043068,
18    "name": "apex-45c6b266-a5fa-4534-b22c-33c2f9a45d02",
19    "pdpGroup": "defaultGroup",
20    "pdpSubgroup": "apex"
21  }

7. PDP sends PDP_STATUS Heartbeat messages

A PDP has to send Heartbeat messages to PAP periodically with the current status information of the PDP. PAP receives this information and makes sure they are updated. In case of any mismatch with the data in the database, PAP sends out a PDP_UPDATE message to update the PDP. PAP considers a PDP as expired if three consecutive heartbeats are missing from the PDP, and removes the PDP instance details from the database.

Sample PDP_STATUS response message (from APEX-PDP)
 1  {
 2    "pdpType": "apex",
 3    "state": "ACTIVE",
 4    "healthy": "HEALTHY",
 5    "description": "Pdp Heartbeat",
 6    "policies": [],
 7    "statistics": {
 8      ..... Omitted for brevity
 9    },
10    "messageName": "PDP_STATUS",
11    "requestId": "e3c72783-4e91-4cb5-8140-e4ac0630706d",
12    "timestampMs": 1632325038075,
13    "name": "apex-45c6b266-a5fa-4534-b22c-33c2f9a45d02",
14    "pdpGroup": "defaultGroup",
15    "pdpSubgroup": "apex"
16  }

8. Deploy/Undeploy Policy using PAP

Policies can be deployed or undeployed using PAP APIs. PAP fetches the policies to be deployed from the database, and send the whole policies’ list under policiesToBeDeployed field. In case of undeployment, PAP sends the list of policies with their name and version under policiesToBeUndeployed in the PDP_UPDATE message.

9. PAP sends PDP_UPDATE message with policiesToBeDeployed/Undeployed

PAP sends a PDP_UPDATE message with information about policies to be deployed and undeployed. If there are some policies that are already deployed, then only the new ones are sent under the policiesToBeDeployed field.

Sample PDP_STATUS response message (from APEX-PDP)
 1  {
 2    "source": "pap-56c8531d-5376-4e53-a820-6973c62bfb9a",
 3    "pdpHeartbeatIntervalMs": 120000,
 4    "policiesToBeDeployed": [
 5      {
 6        "type": "onap.policies.native.Apex",
 7        "type_version": "1.0.0",
 8        "properties": {
 9        ..... Omitted for brevity
10        },
11        "name": "onap.policies.apex.Simplecontrolloop",
12        "version": "1.0.0",
13        "metadata": {
14          "policy-id": "onap.policies.apex.Simplecontrolloop",
15          "policy-version": "1.0.0"
16        }
17      }
18    ],
19    "policiesToBeUndeployed":[],
20    "messageName": "PDP_UPDATE",
21    "requestId": "3534e54f-4432-4c68-81c8-a6af07e59fb2",
22    "timestampMs": 1632325037040,
23    "name": "apex-45c6b266-a5fa-4534-b22c-33c2f9a45d02",
24    "pdpGroup": "defaultGroup",
25    "pdpSubgroup": "apex"
26  }

10. PDP sends PDP_STATUS response to PDP_UPDATE

All policies to be deployed/undeployed are updated in the PDP engine. Policies that are part of policiesToBeDeployed are updated to the engine, and all policies under policiesToBeUndeployed are removed from the PDP engine. Once the processing of PDP_UPDATE message is complete, PDP sends back a PDP_STATUS message with the updated status, the current list of policies that are in the engine, and the result of the PDP_UPDATE operation.

Sample PDP_STATUS response message (from APEX-PDP)
 1  {
 2    "pdpType": "apex",
 3    "state": "ACTIVE",
 4    "healthy": "HEALTHY",
 5    "description": "Pdp status response message for PdpUpdate",
 6    "policies": [
 7      {
 8        "name": "onap.policies.apex.Simplecontrolloop",
 9        "version": "1.0.0"
10      }
11    ],
12    "statistics": {
13      "pdpInstanceId": "apex-45c6b266-a5fa-4534-b22c-33c2f9a45d02",
14      "timeStamp": "2021-09-22T15:37:18.075436Z",
15      "pdpGroupName": "defaultGroup",
16      "pdpSubGroupName": "apex",
17      "policyExecutedCount": 0,
18      "policyExecutedSuccessCount": 0,
19      "policyExecutedFailCount": 0,
20      "policyDeployCount": 1,
21      "policyDeploySuccessCount": 1,
22      "policyDeployFailCount": 0,
23      "policyUndeployCount": 0,
24      "policyUndeploySuccessCount": 0,
25      "policyUndeployFailCount": 0
26    },
27    "response": {
28      "responseTo": "4534e54f-4432-4c68-81c8-a6af07e59fb2",
29      "responseStatus": "SUCCESS",
30      "responseMessage": "Apex engine started. Deployed policies are: onap.policies.apex.Simplecontrolloop:1.0.0"
31    },
32    "messageName": "PDP_STATUS",
33    "requestId": "e3c72783-4e91-4cb5-8140-e4ac0630706d",
34    "timestampMs": 1632325038075,
35    "name": "apex-45c6b266-a5fa-4534-b22c-33c2f9a45d02",
36    "pdpGroup": "defaultGroup",
37    "pdpSubgroup": "apex"
38  }

More details about the messages used for PDP-PAP internal communication and their structure can be found here The Internal Policy Framework PAP-PDP API.