Browse Source

Merge pull request #14092 from richardkchapman/readiness

HPCC-24633 Add readiness/startup probes to helm charts

Reviewed-by: Jake Smith
Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Merged-by: Gavin Halliday <ghalliday@hpccsystems.com>
Gavin Halliday 4 years ago
parent
commit
0369ad4657

+ 1 - 3
dali/server/daserver.cpp

@@ -384,9 +384,9 @@ int main(int argc, const char* argv[])
         setAllocHook(true);
 
         serverConfig.setown(loadConfiguration(defaultYaml, argv, "dali", "DALI", DALICONF, nullptr));
-#ifndef _CONTAINERIZED
         Owned<IFile> sentinelFile = createSentinelTarget();
         removeSentinelFile(sentinelFile);
+#ifndef _CONTAINERIZED
 	
         for (unsigned i=1;i<(unsigned)argc;i++) {
             if (streq(argv[i],"--daemon") || streq(argv[i],"-d")) {
@@ -700,9 +700,7 @@ int main(int argc, const char* argv[])
 
         }
         if (ok) {
-#ifndef _CONTAINERIZED
             writeSentinelFile(sentinelFile);
-#endif
             covenMain();
             removeAbortHandler(actionOnAbort);
         }

+ 22 - 0
helm/hpcc/templates/_helpers.tpl

@@ -314,6 +314,28 @@ Add Secret volume for a component
 {{- end -}}
 
 {{/*
+Add sentinel-based probes for a component
+*/}}
+{{- define "hpcc.addSentinelProbes" -}}
+env:
+- name: "SENTINEL"
+  value: "{{ .name }}.sentinel"
+startupProbe:
+  exec:
+    command:
+    - cat
+    - "{{ .name }}.sentinel"
+  failureThreshold: 30
+  periodSeconds: 10
+readinessProbe:
+  exec:
+    command:
+    - cat
+    - "{{ .name }}.sentinel"
+  periodSeconds: 10
+{{ end -}}
+
+{{/*
 Return a value indicating whether a storage plane is defined or not.
 */}}
 {{- define "hpcc.isValidStoragePlane" -}}

+ 1 - 0
helm/hpcc/templates/dali.yaml

@@ -24,6 +24,7 @@ spec:
         args: [
                 {{ include "hpcc.configArg" . }}
               ]
+{{ include "hpcc.addSentinelProbes" . | indent 8 }}
 {{- include "hpcc.addSecurityContext" (dict "root" $ "me" .) | indent 8 }}
 {{ include "hpcc.addImageAttrs" (dict "root" $ "me" .) | indent 8 }}
         volumeMounts:

+ 1 - 0
helm/hpcc/templates/esp.yaml

@@ -25,6 +25,7 @@ spec:
                 {{ include "hpcc.configArg" . }},
                 {{ include "hpcc.daliArg" $ }}
               ]
+{{ include "hpcc.addSentinelProbes" . | indent 8 }}
 {{- include "hpcc.addSecurityContext" (dict "root" $ "me" .) | indent 8 }}
 {{ include "hpcc.addImageAttrs" (dict "root" $ "me" .) | indent 8 }}
         volumeMounts:

+ 3 - 0
helm/hpcc/templates/roxie.yaml

@@ -24,6 +24,7 @@ spec:
       serviceAccountName: "hpcc-default"
       containers:
       - name: {{ $toponame | quote }}
+{{ include "hpcc.addSentinelProbes" $roxie | indent 8 }}
 {{- include "hpcc.addSecurityContext" (dict "root" $ "me" .) | indent 8 }}
 {{ include "hpcc.addImageAttrs" (dict "root" $ "me" $roxie) | indent 8 }}
         workingDir: /var/lib/HPCCSystems
@@ -127,6 +128,7 @@ spec:
           containerPort: {{ $service.port }}
 {{- end }}
 {{- end }}
+{{ include "hpcc.addSentinelProbes" $roxie | indent 8 }}
 {{ include "hpcc.addSecurityContext" (dict "root" $ "me" .) | indent 8 }}
 {{ include "hpcc.addImageAttrs" (dict "root" $ "me" $roxie) | indent 8 }}
         volumeMounts:
@@ -188,6 +190,7 @@ spec:
           containerPort: {{ $service.port }}
 {{- end }}
 {{- end }}
+{{ include "hpcc.addSentinelProbes" $roxie | indent 8 }}
 {{- end }}
 {{ include "hpcc.addSecurityContext" (dict "root" $ "me" .) | indent 8 }}
 {{ include "hpcc.addImageAttrs" (dict "root" $ "me" $roxie) | indent 8 }}

+ 0 - 4
system/jlib/jfile.cpp

@@ -6816,7 +6816,6 @@ extern jlib_decl IFile * createSentinelTarget()
 
 extern jlib_decl void removeSentinelFile(IFile * sentinelFile)
 {
-#ifndef _CONTAINERIZED
     if (sentinelFile)
     {
         if(sentinelFile->exists() && sentinelFile->isDirectory()!=fileBool::foundYes)
@@ -6835,12 +6834,10 @@ extern jlib_decl void removeSentinelFile(IFile * sentinelFile)
             }
         }
     }
-#endif
 }
 
 extern jlib_decl void writeSentinelFile(IFile * sentinelFile)
 {
-#ifndef _CONTAINERIZED
     if ( sentinelFile )
     {
         DBGLOG("Creating sentinel file %s for rerun from script", sentinelFile->queryFilename());
@@ -6857,7 +6854,6 @@ extern jlib_decl void writeSentinelFile(IFile * sentinelFile)
             throw makeOsException(errno, "writeSentinelFile - file not created.");
         }
     }
-#endif
 }
 
 jlib_decl StringBuffer & appendCurrentDirectory(StringBuffer & target, bool blankIfFails)