@@ -617,27 +617,29 @@ check_5_15() {
617
617
for s in $( docker service ls --format ' {{.Name}}' ) ; do
618
618
if echo $container_name | grep -q " $s " ; then
619
619
task_id=$( docker inspect " $c " --format ' {{.Name}}' | awk -F ' .' ' {print $NF}' )
620
- # a container name could arbitrary include a service one: it belongs to a service (created by Docker
620
+ # a container name could arbitrary include a service one: it belongs to a service (created by Docker
621
621
# as part of the service), if the container task ID matches one of the task IDs of the service.
622
622
if docker service ps --no-trunc " $s " --format ' {{.ID}}' | grep -q " $task_id " ; then
623
- spolicy =$( docker inspect --format MaxAttempts= ' {{ .Spec.TaskTemplate.RestartPolicy.MaxAttempts }}' " $s " )
623
+ restart_policy =$( docker inspect --format ' {{ .Spec.TaskTemplate.RestartPolicy.MaxAttempts }}' " $s " )
624
624
break
625
625
fi
626
626
fi
627
627
done
628
628
fi
629
- cpolicy=$( docker inspect --format MaximumRetryCount=' {{ .HostConfig.RestartPolicy.MaximumRetryCount }}' " $c " )
629
+ if docker inspect --format ' {{ .HostConfig.RestartPolicy.MaximumRetryCount }}' " $c " & > /dev/null; then
630
+ restart_policy=$( docker inspect --format ' {{ .HostConfig.RestartPolicy.MaximumRetryCount }}' " $c " )
631
+ fi
630
632
631
- if [ " $cpolicy " != " MaximumRetryCount=5 " ] && [ " $spolicy " != " MaxAttempts= 5" ]; then
633
+ if [ " $restart_policy " -gt " 5" ]; then
632
634
# If it's the first container, fail the test
633
635
if [ $fail -eq 0 ]; then
634
636
warn -s " $check "
635
- warn " * MaximumRetryCount is not set to 5: $c "
637
+ warn " * MaximumRetryCount is not set to 5 or less : $c "
636
638
maxretry_unset_containers=" $maxretry_unset_containers $c "
637
639
fail=1
638
640
continue
639
641
fi
640
- warn " * MaximumRetryCount is not set to 5: $c "
642
+ warn " * MaximumRetryCount is not set to 5 or less : $c "
641
643
maxretry_unset_containers=" $maxretry_unset_containers $c "
642
644
fi
643
645
done
@@ -647,7 +649,7 @@ check_5_15() {
647
649
logcheckresult " PASS"
648
650
return
649
651
fi
650
- logcheckresult " WARN" " Containers with MaximumRetryCount not set to 5" " $maxretry_unset_containers "
652
+ logcheckresult " WARN" " Containers with MaximumRetryCount not set to 5 or less " " $maxretry_unset_containers "
651
653
}
652
654
653
655
check_5_16 () {
0 commit comments