Skip to content

Commit 5868313

Browse files
author
Osni Oliveira
committed
Add new liveness and readiness probes (Python 3)
Since we started using UBI8 as the base image, Python 2 is not easily available anymore. We chose to port the liveness and readiness probes to use Python 3. References: IBMZP-28, JDG-3368 NOTE: the image should be in a buildable state starting from this commit, after the preparatory changes to introduce UBI8 as base image and the commits in between.
1 parent f596a4a commit 5868313

34 files changed

+1215
-115
lines changed

image.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,10 @@ modules:
195195
- name: jolokia
196196
- name: datagrid.module-overrides
197197
- name: os-eap7-ping
198+
- name: os-eap-python
199+
version: "3.6"
198200
- name: os-eap-probes
201+
version: "3.0"
199202
- name: os-eap-db-drivers
200203
- name: os-partition
201204
- name: openshift-layer

modules/common/os-eap-probes/added/livenessProbe.sh renamed to modules/common/os-eap-probes/1.0/added/livenessProbe.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,3 @@ if [ "$DEBUG_SCRIPT" == "true" ]; then
5050
fi
5151

5252
exit 1
53-

modules/common/os-eap-probes/added/probe_common.sh renamed to modules/common/os-eap-probes/1.0/added/probe_common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ run_cli_cmd() {
1313

1414
#Default for EAP7
1515
cli_port=9990
16-
16+
1717
if [ -f "$JBOSS_HOME/bin/run.sh" ]; then
1818
version=$($JBOSS_HOME/bin/run.sh -V)
1919
if [[ "$version" == *"JBoss Enterprise Application Platform 6"* ]]; then
File renamed without changes.

modules/common/os-eap-probes/added/probes/probe/api.py renamed to modules/common/os-eap-probes/1.0/added/probes/probe/api.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Status(Enum):
4343
FAILURE = 2
4444
NOT_READY = 4
4545
READY = 8
46-
46+
4747
def __str__(self):
4848
return self.name
4949

@@ -81,19 +81,19 @@ class Test(object):
8181

8282
def __init__(self, query):
8383
self.query = query
84-
84+
8585
def getQuery(self):
8686
"""
8787
Returns the query used by this test. The return value is Probe
8888
specific. Many Probe implementations use JSON for submitting queries,
8989
which means this function would return a dict.
9090
"""
9191
return self.query
92-
92+
9393
def evaluate(self, results):
9494
"""
9595
Evaluate the response from the server, returning Status and messages.
96-
messages should be returned as an object, list or dict.
96+
messages should be returned as an object, list or dict.
9797
"""
9898
raise NotImplementedError("Implement evaluate() for Test: " + qualifiedClassName(self))
9999

@@ -113,23 +113,23 @@ def addTest(self, test):
113113
as JSON). The Test must be capable of understanding the results
114114
returned by the Probe (e.g. a JSON response from DMR).
115115
"""
116-
116+
117117
self.tests.append(test)
118118

119119
def execute(self):
120120
"""
121121
Executes the queries and evaluates the tests and returns a set of Status
122122
and messages collected for each test.
123123
"""
124-
124+
125125
raise NotImplementedError("Implement execute() for Probe: " + qualifiedClassName(self))
126126

127127
class BatchingProbe(Probe):
128128
"""
129129
Base class which supports batching queries to be sent to a server and
130130
splitting the results to correspond with the individual tests.
131131
"""
132-
132+
133133
def __init__(self, tests = []):
134134
super(BatchingProbe, self).__init__(tests)
135135
self.logger = logging.getLogger(qualifiedClassName(self))
@@ -166,7 +166,7 @@ def createRequest(self):
166166
Create the request to send to the server. Subclasses should include the
167167
queries from all tests in the request.
168168
"""
169-
169+
170170
raise NotImplementedError("Implement createRequest() for BatchingProbe: " + qualifiedClassName(self))
171171

172172
def sendRequest(self, request):
@@ -180,5 +180,5 @@ def getTestInput(self, results, testIndex):
180180
"""
181181
Return the results specific to the indexed test.
182182
"""
183-
183+
184184
raise NotImplementedError("Implement getTestInput() for BatchingProbe: " + qualifiedClassName(self))

modules/common/os-eap-probes/added/probes/probe/dmr.py renamed to modules/common/os-eap-probes/1.0/added/probes/probe/dmr.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(self, tests = []):
3535
super(DmrProbe, self).__init__(tests)
3636
self.logger = logging.getLogger(qualifiedClassName(self))
3737
self.__readConfig()
38-
38+
3939
def __readConfig(self):
4040
"""
4141
Configuration consists of:
@@ -44,7 +44,7 @@ def __readConfig(self):
4444
user: $ADMIN_USERNAME
4545
password: $ADMIN_PASSWORD
4646
"""
47-
47+
4848
self.host = "localhost"
4949
self.port = 9990 + int(os.getenv('PORT_OFFSET', 0))
5050
self.user = os.getenv('ADMIN_USERNAME')
@@ -114,8 +114,9 @@ def failUnusableResponse(self, response):
114114
for index, test in enumerate(self.tests):
115115
if not stepResults[index]:
116116
unusable = True
117-
break;
117+
break
118118

119119
if unusable:
120+
url = "http://%s:%s/management" % (self.host, self.port)
120121
self.logger.error("Probe request failed. Status code: %s", response.status_code)
121-
raise Exception("Probe request failed, code: " + str(response.status_code) + str(url) + str(request) + str(response.json(object_pairs_hook = OrderedDict)))
122+
raise Exception("Probe request failed, code: " + str(response.status_code) + str(url) + str(response.json(object_pairs_hook = OrderedDict)))
File renamed without changes.

modules/common/os-eap-probes/added/probes/probe/eap/dmr.py renamed to modules/common/os-eap-probes/1.0/added/probes/probe/eap/dmr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def evaluate(self, results):
5353
Evaluates the test:
5454
READY for "running"
5555
FAILURE if the query itself failed
56-
NOT_READY for all other states
56+
NOT_READY for all other states
5757
"""
5858

5959
if results["outcome"] != "success" and results.get("failure-description"):
@@ -196,7 +196,7 @@ def evaluate(self, results):
196196
"""
197197
Evaluates the test:
198198
if the overall composite failed with JBAS014883 or WFLYCTL0030
199-
READY as the failure means no health check extension configured on the system
199+
READY as the failure means no health check extension configured on the system
200200
elsif the 'read-resource' step failed:
201201
READY as failure means no health check subsystem configured on the system
202202
elsif the 'check' step succeeded:
File renamed without changes.

modules/common/os-eap-probes/added/probes/probe/jolokia.py renamed to modules/common/os-eap-probes/1.0/added/probes/probe/jolokia.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import os
2020
import requests
2121
import sys
22-
import ConfigParser
23-
import StringIO
22+
import configparser as ConfigParser
23+
from io import StringIO
2424

2525
from collections import OrderedDict
2626

@@ -37,7 +37,7 @@ def __init__(self, tests = []):
3737
super(JolokiaProbe, self).__init__(tests)
3838
self.logger = logging.getLogger(qualifiedClassName(self))
3939
self.__readConfig()
40-
40+
4141
def __readConfig(self):
4242
"""
4343
Configuration is read from /opt/jolokia/etc/jolokia.properties and
@@ -48,7 +48,7 @@ def __readConfig(self):
4848
user: jolokia.user
4949
password: jolokia.password
5050
"""
51-
51+
5252
jolokiaConfig = ConfigParser.ConfigParser(
5353
defaults = {
5454
"port": 8778,
@@ -57,12 +57,12 @@ def __readConfig(self):
5757
"protocol": "http"
5858
}
5959
)
60-
60+
6161
self.logger.info("Reading jolokia properties file")
6262
with open("/opt/jolokia/etc/jolokia.properties") as jolokiaProperties:
6363
# fake a section
64-
jolokiaConfig.readfp(StringIO.StringIO("[jolokia]\n" + jolokiaProperties.read()))
65-
64+
jolokiaConfig.readfp(StringIO("[jolokia]\n" + jolokiaProperties.read()))
65+
6666
self.host = "localhost"
6767
self.port = int(jolokiaConfig.get("jolokia", "port")) + int(os.getenv('PORT_OFFSET', 0))
6868
self.protocol = jolokiaConfig.get("jolokia", "protocol")

0 commit comments

Comments
 (0)