Feature: Healthcheck

Summary

The Healthcheck feature provides reports used to verify the health of PolicyEngine.manager in addition to the construction, operation, and deconstruction of HTTP server/client objects.

Usage

When enabled, the feature takes as input a properties file named “feature-healtcheck.properties” (example below). This file should contain configuration properties necessary for the construction of HTTP client and server objects.

Upon initialization, the feature first constructs HTTP server and client objects using the properties from its properties file. A healthCheck operation is then triggered. The logic of the healthCheck verifies that PolicyEngine.manager is alive, and iteratively tests each HTTP server object by sending HTTP GET requests using its respective client object. If a server returns a “200 OK” message, it is marked as “healthy” in its individual report. Any other return code results in an “unhealthy” report.

After the testing of the server objects has completed, the feature returns a single consolidated report.

feature-healthcheck.properties
 1 ###
 2 # ============LICENSE_START=======================================================
 3 # feature-healthcheck
 4 # ================================================================================
 5 # Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 6 # ================================================================================
 7 # Licensed under the Apache License, Version 2.0 (the "License");
 8 # you may not use this file except in compliance with the License.
 9 # You may obtain a copy of the License at
10 #
11 #      http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 # ============LICENSE_END=========================================================
19 ###
20
21 http.server.services=HEALTHCHECK
22 http.server.services.HEALTHCHECK.host=0.0.0.0
23 http.server.services.HEALTHCHECK.port=6969
24 http.server.services.HEALTHCHECK.restClasses=org.onap.policy.drools.healthcheck.RestHealthCheck
25 http.server.services.HEALTHCHECK.managed=false
26 http.server.services.HEALTHCHECK.swagger=true
27 http.server.services.HEALTHCHECK.userName=healthcheck
28 http.server.services.HEALTHCHECK.password=zb!XztG34
29
30 http.client.services=PAP,PDP
31
32 http.client.services.PAP.host=pap
33 http.client.services.PAP.port=9091
34 http.client.services.PAP.contextUriPath=pap/test
35 http.client.services.PAP.https=false
36 http.client.services.PAP.userName=testpap
37 http.client.services.PAP.password=alpha123
38 http.client.services.PAP.managed=true
39
40 http.client.services.PDP.host=pdp
41 http.client.services.PDP.port=8081
42 http.client.services.PDP.contextUriPath=pdp/test
43 http.client.services.PDP.https=false
44 http.client.services.PDP.userName=testpdp
45 http.client.services.PDP.password=alpha123
46 http.client.services.PDP.managed=false

To utilize the healthcheck functionality, first stop policy engine and then enable the feature using the “features” command.

Enabling Healthcheck feature
 policy@hyperion-4:/opt/app/policy$ policy stop
 [drools-pdp-controllers]
  L []: Stopping Policy Management... Policy Management (pid=354) is stopping... Policy Management has stopped.
 policy@hyperion-4:/opt/app/policy$ features enable healthcheck
 name                      version         status
 ----                      -------         ------
 controlloop-utils         1.1.0-SNAPSHOT  disabled
 healthcheck               1.1.0-SNAPSHOT  enabled
 test-transaction          1.1.0-SNAPSHOT  disabled
 eelf                      1.1.0-SNAPSHOT  disabled
 state-management          1.1.0-SNAPSHOT  disabled
 active-standby-management 1.1.0-SNAPSHOT  disabled
 session-persistence       1.1.0-SNAPSHOT  disabled

The output of the enable command will indicate whether or not the feature was enabled successfully.

Policy engine can then be started as usual.

The Healthcheck can also be invoked manually as follows:

Manual Healthcheck invokation
 # Assuming the healthcheck service credentials have not been changed
 # post-installation within the drools container

 source /opt/app/policy/config/feature-healthcheck.conf.environment
 curl -k --silent --user "${HEALTHCHECK_USER}:${HEALTHCHECK_PASSWORD}" -X GET https://localhost:6969/healthcheck | python -m json.tool

End of Document