My Open shift Liveness Probe with Exec command is not working , its not giving any error as well means its considering it as success. It's checking cert expiry days from current date and if condition in "if statement" is satisfied then Probe should fail and Container should restart. When I put it in shell script, its working as expected but not with Liveness Probe. Below is Liveness Probe configuration
livenessProbe:
exec:
command:
- /bin/sh
- -c
- |-
cutoff_days=25;
end_date=$(keytool -printcert -file /ama/conf_external/secret/tls.crt|grep "until:"|head -1|sed -n -e 's/^.*until: //p');
end_epoch=$(date +%s -d "$end_date");
epoch_now=$(date +%s);
seconds_to_expire=`expr $end_epoch - $epoch_now`;
days_to_expire=`expr $seconds_to_expire / 86400`;
if [ ${days_to_expire} -gt ${cutoff_days} ]; then exit 1; fi