Skip to content

Commit 8230ed1

Browse files
authored
templates: use pg_isready as liveness probe (#206)
* templates: use pg_isready as liveness probe * templates: Use 9.6 as the default version * tests: use local namespace instead of openshift * tests: set the image version for the template * tests: explicitly state tag during pure image test * Update to latest commons
1 parent 036810a commit 8230ed1

File tree

5 files changed

+38
-31
lines changed

5 files changed

+38
-31
lines changed

common

examples/postgresql-ephemeral-template.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "postgresql-ephemeral",
66
"annotations": {
77
"openshift.io/display-name": "PostgreSQL (Ephemeral)",
8-
"description": "PostgreSQL database service, without persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/9.5.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing",
8+
"description": "PostgreSQL database service, without persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing",
99
"iconClass": "icon-postgresql",
1010
"tags": "database,postgresql",
1111
"template.openshift.io/long-description": "This template provides a standalone PostgreSQL server with a database created. The database is not stored on persistent storage, so any restart of the service will result in all data being lost. The database name, username, and password are chosen via parameters when provisioning this service.",
@@ -14,7 +14,7 @@
1414
"template.openshift.io/support-url": "https://access.redhat.com"
1515
}
1616
},
17-
"message": "The following service(s) have been created in your project: ${DATABASE_SERVICE_NAME}.\n\n Username: ${POSTGRESQL_USER}\n Password: ${POSTGRESQL_PASSWORD}\n Database Name: ${POSTGRESQL_DATABASE}\n Connection URL: postgresql://${DATABASE_SERVICE_NAME}:5432/\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/9.5.",
17+
"message": "The following service(s) have been created in your project: ${DATABASE_SERVICE_NAME}.\n\n Username: ${POSTGRESQL_USER}\n Password: ${POSTGRESQL_PASSWORD}\n Database Name: ${POSTGRESQL_DATABASE}\n Connection URL: postgresql://${DATABASE_SERVICE_NAME}:5432/\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/.",
1818
"labels": {
1919
"template": "postgresql-ephemeral-template"
2020
},
@@ -127,11 +127,11 @@
127127
}
128128
},
129129
"livenessProbe": {
130+
"exec": {
131+
"command": [ "/bin/sh", "-i", "-c", "pg_isready -h 127.0.0.1 -p 5432" ]
132+
},
130133
"timeoutSeconds": 1,
131-
"initialDelaySeconds": 30,
132-
"tcpSocket": {
133-
"port": 5432
134-
}
134+
"initialDelaySeconds": 30
135135
},
136136
"env": [
137137
{
@@ -245,8 +245,8 @@
245245
{
246246
"name": "POSTGRESQL_VERSION",
247247
"displayName": "Version of PostgreSQL Image",
248-
"description": "Version of PostgreSQL image to be used (9.2, 9.4, 9.5 or latest).",
249-
"value": "9.5",
248+
"description": "Version of PostgreSQL image to be used (9.4, 9.5, 9.6 or latest).",
249+
"value": "9.6",
250250
"required": true
251251
}
252252
]

examples/postgresql-persistent-template.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "postgresql-persistent",
66
"annotations": {
77
"openshift.io/display-name": "PostgreSQL (Persistent)",
8-
"description": "PostgreSQL database service, with persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/9.5.\n\nNOTE: Scaling to more than one replica is not supported. You must have persistent volumes available in your cluster to use this template.",
8+
"description": "PostgreSQL database service, with persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/.\n\nNOTE: Scaling to more than one replica is not supported. You must have persistent volumes available in your cluster to use this template.",
99
"iconClass": "icon-postgresql",
1010
"tags": "database,postgresql",
1111
"template.openshift.io/long-description": "This template provides a standalone PostgreSQL server with a database created. The database is stored on persistent storage. The database name, username, and password are chosen via parameters when provisioning this service.",
@@ -14,7 +14,7 @@
1414
"template.openshift.io/support-url": "https://access.redhat.com"
1515
}
1616
},
17-
"message": "The following service(s) have been created in your project: ${DATABASE_SERVICE_NAME}.\n\n Username: ${POSTGRESQL_USER}\n Password: ${POSTGRESQL_PASSWORD}\n Database Name: ${POSTGRESQL_DATABASE}\n Connection URL: postgresql://${DATABASE_SERVICE_NAME}:5432/\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/9.5.",
17+
"message": "The following service(s) have been created in your project: ${DATABASE_SERVICE_NAME}.\n\n Username: ${POSTGRESQL_USER}\n Password: ${POSTGRESQL_PASSWORD}\n Database Name: ${POSTGRESQL_DATABASE}\n Connection URL: postgresql://${DATABASE_SERVICE_NAME}:5432/\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/.",
1818
"labels": {
1919
"template": "postgresql-persistent-template"
2020
},
@@ -144,11 +144,11 @@
144144
}
145145
},
146146
"livenessProbe": {
147+
"exec": {
148+
"command": [ "/bin/sh", "-i", "-c", "pg_isready -h 127.0.0.1 -p 5432" ]
149+
},
147150
"timeoutSeconds": 1,
148-
"initialDelaySeconds": 30,
149-
"tcpSocket": {
150-
"port": 5432
151-
}
151+
"initialDelaySeconds": 30
152152
},
153153
"env": [
154154
{
@@ -269,8 +269,8 @@
269269
{
270270
"name": "POSTGRESQL_VERSION",
271271
"displayName": "Version of PostgreSQL Image",
272-
"description": "Version of PostgreSQL image to be used (9.2, 9.4, 9.5 or latest).",
273-
"value": "9.5",
272+
"description": "Version of PostgreSQL image to be used (9.4, 9.5, 9.6 or latest).",
273+
"value": "9.6",
274274
"required": true
275275
}
276276
]

examples/replica/postgresql_replica.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"name": "IMAGESTREAMTAG",
7272
"displayName": "ImageStreamTag",
7373
"description": "The OpenShift ImageStreamTag to use for PostgreSQL.",
74-
"value": "postgresql:9.5"
74+
"value": "postgresql:9.6"
7575
},
7676
{
7777
"name": "NAMESPACE",
@@ -211,11 +211,11 @@
211211
}
212212
},
213213
"livenessProbe": {
214+
"exec": {
215+
"command": [ "/bin/sh", "-i", "-c", "pg_isready -h 127.0.0.1 -p 5432" ]
216+
},
214217
"timeoutSeconds": 1,
215-
"initialDelaySeconds": 30,
216-
"tcpSocket": {
217-
"port": 5432
218-
}
218+
"initialDelaySeconds": 30
219219
},
220220
"env": [
221221
{
@@ -322,11 +322,11 @@
322322
}
323323
},
324324
"livenessProbe": {
325+
"exec": {
326+
"command": [ "/bin/sh", "-i", "-c", "pg_isready -h 127.0.0.1 -p 5432" ]
327+
},
325328
"timeoutSeconds": 1,
326-
"initialDelaySeconds": 30,
327-
"tcpSocket": {
328-
"port": 5432
329-
}
329+
"initialDelaySeconds": 30
330330
},
331331
"env": [
332332
{

test/run-openshift

+12-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ source "$THISDIR"/test-lib-openshift.sh
1212

1313
set -exo nounset
1414

15+
test -n "${IMAGE_NAME-}" || false 'make sure $IMAGE_NAME is defined'
16+
test -n "${VERSION-}" || false 'make sure $VERSION is defined'
17+
1518
function check_postgresql_os_service_connection() {
1619
local util_image_name=$1 ; shift
1720
local service_name=$1 ; shift
@@ -52,8 +55,10 @@ function test_postgresql_pure_image() {
5255

5356
ct_os_new_project
5457
ct_os_upload_image "${image_name}"
58+
# Create a specific imagestream tag for the image so that oc cannot use anything else
59+
ct_os_upload_image "${image_name}" "$image_name_no_namespace:testing"
5560

56-
ct_os_deploy_pure_image "${image_name}" \
61+
ct_os_deploy_pure_image "$image_name_no_namespace:testing" \
5762
--name "${service_name}" \
5863
--env POSTGRESQL_ADMIN_PASSWORD=test
5964

@@ -69,9 +74,11 @@ function test_postgresql_template() {
6974
local service_name=${image_name_no_namespace}
7075

7176
ct_os_new_project
72-
ct_os_upload_image "${image_name}"
77+
ct_os_upload_image "${image_name}" "postgresql:$VERSION"
7378

74-
ct_os_deploy_template_image ${THISDIR}/postgresql-ephemeral-template.json \
79+
ct_os_deploy_template_image "$THISDIR/postgresql-ephemeral-template.json" \
80+
NAMESPACE="$(oc project -q)" \
81+
POSTGRESQL_VERSION="$VERSION" \
7582
DATABASE_SERVICE_NAME="${service_name}" \
7683
POSTGRESQL_USER=testu \
7784
POSTGRESQL_PASSWORD=testp \
@@ -84,5 +91,5 @@ function test_postgresql_template() {
8491
}
8592

8693
ct_os_cluster_up
87-
test_postgresql_pure_image ${IMAGE_NAME}
88-
test_postgresql_template ${IMAGE_NAME}
94+
test_postgresql_pure_image "${IMAGE_NAME}"
95+
test_postgresql_template "${IMAGE_NAME}"

0 commit comments

Comments
 (0)