I am trying to use this startup probe
startupProbe:
exec:
command:
- >-
test $(java -cp /the/path/to/the/app.jar app.Controller port=4990 cmd="v" | grep -E 'r5|v5' | wc -l) -eq 2 && echo $? || echo $?
initialDelaySeconds: 5 #How many seconds to wait after the container has started
timeoutSeconds: 1 #Timeout of the probe
successThreshold: 1 #Threshold needed to mark the container healthy
periodSeconds : 10 #Wait time between probe executions
failureThreshold: 110 #Threshold needed to mark the container unhealthy.
It is a java app that can take a long time (~15 mins) to load some components. It is a legacy app, not much I can do about it.
I am greping the response, trying to get two lines as a result, and then returning 0 or 1 as exit codes for the probe to decide.
I get his error though
Startup probe errored: rpc error: code = Unknown desc = failed to exec in container: failed to start exec "8ad860ffc7a87e95fb65e37dc14945c04fa205f9a524c7f7f08f9d6ef7d75": OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "test $(java -cp /the/path/to/the/app.jar app.Controller port=4990 cmd=\"v\" | grep -E 'r5|v5' | wc -l) -eq 2 && echo $? || echo $?": stat test $(java -cp /the/path/to/the/app.jar app.Controller port=4990 cmd="v" | grep -E 'r5|v5' | wc -l) -eq 2 && echo $? || echo $?: no such file or directory: unknown
If I dont use the && echo $? || echo $?
part, the probe throws error that the exit code is 2
and not 1
.
What is going on ??
CodePudding user response:
You need to start a shell to run your script:
startupProbe:
exec:
command:
- sh
- -c
- >-
...