From 1e31e9703e47bca54f4af7c35ed94a68fc8daf75 Mon Sep 17 00:00:00 2001 From: Adam King Date: Thu, 1 Aug 2019 11:09:07 -0400 Subject: [PATCH] Enhance liveness check with @razee/kubernetes-util (#9) --- kubernetes/RemoteResource/resource.yaml | 2 +- package-lock.json | 60 +++++++++++++++++-------- package.json | 2 +- sh/liveness.sh | 15 ++++++- src/index.js | 3 +- 5 files changed, 59 insertions(+), 23 deletions(-) diff --git a/kubernetes/RemoteResource/resource.yaml b/kubernetes/RemoteResource/resource.yaml index 91b7d933..abce1a80 100644 --- a/kubernetes/RemoteResource/resource.yaml +++ b/kubernetes/RemoteResource/resource.yaml @@ -44,7 +44,7 @@ items: command: - sh/liveness.sh initialDelaySeconds: 30 - periodSeconds: 300 + periodSeconds: 150 timeoutSeconds: 30 failureThreshold: 1 volumeMounts: diff --git a/package-lock.json b/package-lock.json index 75c45f90..ca1a464a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -152,9 +152,9 @@ } }, "@razee/kapitan-core": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@razee/kapitan-core/-/kapitan-core-0.3.0.tgz", - "integrity": "sha512-6cV6sxPMwOYcYc7wzCumpMPuw8rtYfiUAYBM1wachVYhxRVTLi11nsukdsebYIXYi3rAQ5H3ZkfU8cWfYuQ7Gg==", + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@razee/kapitan-core/-/kapitan-core-0.3.1.tgz", + "integrity": "sha512-A9XEK59YSyd9DjmCuJjsfM4JkzBXQpK6ALbadUBXy7iRSd4fs979oLVAiDB8XTzNQqcCCRxjTf/lS2WSMQzRxQ==", "requires": { "bunyan": "^1.8.12", "clone": "^2.1.2", @@ -163,19 +163,12 @@ "js-yaml": "^3.13.1", "object-hash": "^1.3.1", "object-path": "^0.11.4" - }, - "dependencies": { - "deepmerge": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.0.0.tgz", - "integrity": "sha512-YZ1rOP5+kHor4hMAH+HRQnBQHg+wvS1un1hAOuIcxcBy0hzcUf6Jg2a1w65kpoOUnurOfZbERwjI1TfZxNjcww==" - } } }, "@razee/kubernetes-util": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/@razee/kubernetes-util/-/kubernetes-util-0.0.4.tgz", - "integrity": "sha512-DHPZb/9z3kTCol8fRceiPoBzNjzjFL0qXD19glRfNh62qERtWK5Ffdr/Ws0sBAbiexjN41N4/s1cK7TmPzGRMA==", + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/@razee/kubernetes-util/-/kubernetes-util-0.0.6.tgz", + "integrity": "sha512-fmeddx1URg1WTxvQIXH5TkhjIhRP5Axy1Uv0HmCwESAf16R7F3A4aWD3pczY9UtP7I5vZLAOk7EdWpLl8zX02g==", "requires": { "@kubernetes/client-node": "^0.8.2", "JSONStream": "^1.3.5", @@ -189,7 +182,15 @@ "object-path": "^0.11.4", "request": "^2.88.0", "request-promise-native": "^1.0.7", + "touch": "^3.1.0", "valid-url": "^1.0.9" + }, + "dependencies": { + "deepmerge": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-3.3.0.tgz", + "integrity": "sha512-GRQOafGHwMHpjPx9iCvTgpu9NojZ49q794EEL94JVEw6VaeA8XTUyBKvAkOOjBX9oJNiV6G3P+T+tihFjo2TqA==" + } } }, "@sindresorhus/is": { @@ -257,9 +258,9 @@ "integrity": "sha512-SGGAhXLHDx+PK4YLNcNGa6goPf9XRWQNAUUbffkwVGGXIxmDKWyGGL4inzq2sPmExu431Ekb9aEMn9BkPqEYFA==" }, "@types/node": { - "version": "10.14.13", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.13.tgz", - "integrity": "sha512-yN/FNNW1UYsRR1wwAoyOwqvDuLDtVXnaJTZ898XIw/Q5cCaeVAlVwvsmXLX5PuiScBYwZsZU4JYSHB3TvfdwvQ==" + "version": "10.14.14", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.14.tgz", + "integrity": "sha512-xXD08vZsvpv4xptQXj1+ky22f7ZoKu5ZNI/4l+/BXG3X+XaeZsmaFbbTKuhSE3NjjvRuZFxFf9sQBMXIcZNFMQ==" }, "@types/request": { "version": "2.48.2", @@ -300,6 +301,11 @@ "through": ">=2.2.7 <3" } }, + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" + }, "acorn": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.2.1.tgz", @@ -1191,9 +1197,9 @@ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=" }, "deepmerge": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-3.3.0.tgz", - "integrity": "sha512-GRQOafGHwMHpjPx9iCvTgpu9NojZ49q794EEL94JVEw6VaeA8XTUyBKvAkOOjBX9oJNiV6G3P+T+tihFjo2TqA==" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.0.0.tgz", + "integrity": "sha512-YZ1rOP5+kHor4hMAH+HRQnBQHg+wvS1un1hAOuIcxcBy0hzcUf6Jg2a1w65kpoOUnurOfZbERwjI1TfZxNjcww==" }, "default-require-extensions": { "version": "2.0.0", @@ -3624,6 +3630,14 @@ "safe-buffer": "^5.1.1" } }, + "nopt": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", + "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=", + "requires": { + "abbrev": "1" + } + }, "normalize-package-data": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", @@ -5612,6 +5626,14 @@ "resolved": "https://registry.npmjs.org/to-readable-stream/-/to-readable-stream-1.0.0.tgz", "integrity": "sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q==" }, + "touch": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", + "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", + "requires": { + "nopt": "~1.0.10" + } + }, "tough-cookie": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", diff --git a/package.json b/package.json index 2b7052d9..08b20cca 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "license": "Apache-2.0", "dependencies": { "@razee/kapitan-core": "^0.3.0", - "@razee/kubernetes-util": "0.0.4", + "@razee/kubernetes-util": "0.0.6", "bunyan": "^1.8.12", "clone": "^2.1.2", "request-promise-native": "^1.0.7" diff --git a/sh/liveness.sh b/sh/liveness.sh index bfb58f1b..dd4914b1 100755 --- a/sh/liveness.sh +++ b/sh/liveness.sh @@ -15,4 +15,17 @@ # limitations under the License. ################################################################################ -exit 0 +HEALTH_FILE=/tmp/liveness +AGE=${1:-'5'} #Default 5 minutes + +findFile=$(find "${HEALTH_FILE}" -mmin "-${AGE}" 2>/dev/null) +if [ $? -ne 0 ]; then + echo "FAILING liveness probe. ${HEALTH_FILE} does not exist." + exit 1 +elif [ "${findFile}" = "" ]; then + echo "FAILING liveness probe. ${HEALTH_FILE} has not been touched in ${AGE} minutes." + exit 1 +else + # echo "file is good" + exit 0 +fi diff --git a/src/index.js b/src/index.js index 866aa527..70a14f85 100644 --- a/src/index.js +++ b/src/index.js @@ -31,7 +31,8 @@ async function main() { kubeResourceMeta: resourceMeta, factory: Controller, kubeClass: kc, - logger: log + logger: log, + livenessInterval:true }; new EventHandler(params); } else {