Sonarqube Helm chart probe issue

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Docker image: sonarqube:8.9.10-community

  • what are you trying to achieve
    I’m trying to setup Sonarqube in my Kubernetes cluster using the official Helm Chart.

The sonarqube pod starts and runs normally (I can access it through the sonarqube service) but after about 2 minutes, it gets stopped and then a new pod starts and it continues looping like this.

  • what have you tried so far to achieve this
    I checked the sonarqube pod logs, but nothing seems to be wrong, no errors.
    I check the events and I can see the the liveness probes fails, so I checked the probe command and it looks like this:
exec [sh -c host="$(hostname -i || echo '127.0.0.1')"
reply=$(wget -qO- --header="X-Sonar-Passcode: $SONAR_WEB_SYSTEMPASSCODE" http://${host}:9000/sonarqube/api/system/liveness 2>&1)
if [ -z "$reply" ]; then exit 0; else exit 1; fi

What I understand is it tests if the response of the http call is empty or not, if it’s empty it exits 0 (ok) and if it’s not empty it exists 1 (ko). So it looks like it should be reversed no ?
As this looks quite big, I guess I don’t understand it correctly, so I would like somebody to explain the idea behind this probe command.

Thanks a lot !

Hi @edouardp and welcome to the community!

Actually, the “wget” command returns an empty result for a successful call with the option -qO, and the error message otherwise.
So it checks if the result of the command is empty (0 → OK) or not (1 → NOK) as per Kubernetes documentation :

If the command succeeds, it returns 0, and the kubelet considers the container to be alive and healthy. If the command returns a non-zero value, the kubelet kills the container and restarts it.

So to understand what is happening in your environment, you can try to go into the SonarQube container (kubectl exec) and try to replicate the liveness command, to see what is the value of “$reply” variable.

Hi Leo,

Thanks for your answer.

Ok make a lot of sense, I’m not a wget expert !

Thanks,
Ed

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.