I am running this in Azure DevOps pipeline.

I have a healthcheck in my docker compose like so:

    healthcheck:
      test: "ps aux | grep 'dotnet test' | grep -v grep | tr -d '\n' && exit 0 || exit 1" #check if dotnet test process is running
      interval: 2s
      timeout: 5s
      retries: 20
      start_period: 1s

When I inspect the status using docker inspect --format "{{json .State.Health }}" my-service-name | jq

{
  "Status": "unhealthy",
  "FailingStreak": 0,
  "Log": [
    {
      "Start": "2023-04-11T01:23:19.629448812Z",
      "End": "2023-04-11T01:23:19.730674224Z",
      "ExitCode": 0,
      "Output": "root           1 20.0  2.6 274357724 186164 ?    Ssl  01:22   0:06 dotnet test ./FunctionalTests.csproj -c Release --collect:XPlat Code Coverage --settings ../coverlet.runsettings.xml --results-directory:/TestResults"
    },
    {
      "Start": "2023-04-11T01:23:21.733819151Z",
      "End": "2023-04-11T01:23:21.805409101Z",
      "ExitCode": 0,
      "Output": "root           1 18.7  2.6 274357728 186292 ?    Ssl  01:22   0:06 dotnet test ./FunctionalTests.csproj -c Release --collect:XPlat Code Coverage --settings ../coverlet.runsettings.xml --results-directory:/TestResults"
    },
    {
      "Start": "2023-04-11T01:23:23.809734109Z",
      "End": "2023-04-11T01:23:23.911799349Z",
      "ExitCode": 0,
      "Output": "root           1 17.7  2.6 274324644 186236 ?    Ssl  01:22   0:06 dotnet test ./FunctionalTests.csproj -c Release --collect:XPlat Code Coverage --settings ../coverlet.runsettings.xml --results-directory:/TestResults"
    },
    {
      "Start": "2023-04-11T01:23:25.915794952Z",
      "End": "2023-04-11T01:23:26.020336032Z",
      "ExitCode": 0,
      "Output": "root           1 16.7  2.6 274324644 186236 ?    Ssl  01:22   0:06 dotnet test ./FunctionalTests.csproj -c Release --collect:XPlat Code Coverage --settings ../coverlet.runsettings.xml --results-directory:/TestResults"
    },
    {
      "Start": "2023-04-11T01:23:28.024208233Z",
      "End": "2023-04-11T01:23:28.146991706Z",
      "ExitCode": 0,
      "Output": "root           1 15.8  2.6 274308240 186208 ?    Ssl  01:22   0:06 dotnet test ./FunctionalTests.csproj -c Release --collect:XPlat Code Coverage --settings ../coverlet.runsettings.xml --results-directory:/TestResults"
    }
  ]
}

See the "Status" there says "unhealthy", even though all the exit codes are 0 and "FailingStreak" is 0.

My question is why?

The healthcheck seems to work though, it correctly notices the required service is up, so everything works fine.

But that Status 'unhealthy' is keeping me awake at night.

0

There are 0 best solutions below