diff --git a/docker/Dockerfile b/docker/Dockerfile index 3bbe2852..4795b98d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -18,7 +18,8 @@ RUN apt update && apt -y install \ nano #Add a user & group with id=1001 and name=d1indexer -RUN groupadd -g 1000 d1indexer && useradd -u 1000 -g 1000 d1indexer +RUN groupadd -g 1000 d1indexer && useradd -u 1000 -g 1000 d1indexer \ + && touch ./livenessprobe # The most recently built jar file is copied from the maven build directory to this dir by maven, so that # it can be copied to the image. @@ -28,6 +29,7 @@ COPY ./docker/entrypoint.sh . # Change the ownership of the jar and sh files RUN chown d1indexer dataone-index-worker-${TAG}-shaded.jar RUN chown d1indexer entrypoint.sh +RUN chown d1indexer livenessprobe #Run Container as d1indexer USER 1000 diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml index 7823dc71..fa2859d1 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/deployment.yaml @@ -25,8 +25,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} {{- if .Values.affinity }} - affinity: {{- include "idxhelpers.tplvalues.render" (dict "value" .Values.affinity "context" - $) | nindent 8 }} + affinity: {{- include "idxhelpers.tplvalues.render" (dict "value" .Values.affinity "context" $) | nindent 8 }} {{- end }} {{- if .Values.nodeSelector }} nodeSelector: {{- include "idxhelpers.tplvalues.render" (dict "value" .Values.nodeSelector "context" $) | nindent 8 }} @@ -52,15 +51,14 @@ spec: {{- toYaml .Values.securityContext | nindent 12 }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} - # livenessProbe: - # httpGet: - # path: / - # port: http - # readinessProbe: - # httpGet: - # path: / - # port: http - # initialDelaySeconds: + livenessProbe: + exec: + command: + - /bin/sh + - -c + - test $(($(date +%s) - $(stat -f %m /var/lib/dataone-indexer/livenessprobe))) -lt 20 + initialDelaySeconds: 20 + periodSeconds: 10 resources: {{- toYaml .Values.resources | nindent 12 }} volumeMounts: @@ -130,18 +128,6 @@ spec: | grep -c " { + Path path = Paths.get("./livenessprobe"); + try { + Files.createFile(path); + Files.setLastModifiedTime(path, FileTime.fromMillis(System.currentTimeMillis())); + logger.info("IndexWorker.startLivenessProbe - starting livenessProbe"); + } catch (IOException e) { + logger.error("IndexWorker.startLivenessProbe - failed to touch file: " + path, e); + } + }; + scheduler.scheduleAtFixedRate(task, 0, 10, TimeUnit.SECONDS); + } + /** * Initialize the RabbitMQ service * @throws IOException