Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Worker pod liveness probe unstable behavior #149

Open
ilya-vasiuk opened this issue Feb 1, 2025 · 2 comments
Open

Worker pod liveness probe unstable behavior #149

ilya-vasiuk opened this issue Feb 1, 2025 · 2 comments

Comments

@ilya-vasiuk
Copy link

Describe the bug
The liveness probe in the lago-events-worker container fails when using the command with direct command substitution (grep $(hostname)). The probe times out even though the process is running correctly. This is due to the way the shell handles the command substitution in the current configuration.

To Reproduce
Steps to reproduce the behavior:

  • Deploy the Lago application in a Kubernetes cluster.
  • Observe that the liveness probe fails with a timeout, causing the container to restart even though the process is healthy.
  • Verify by manually executing the command via kubectl exec to see that the command fails to find the hostname when using direct substitution.

$ kubectl exec -it lago-events-worker-xxxxxxx-yyyyy -n lago -- /bin/bash -l -c "bundle exec sidekiqmon processes | grep $(hostname) || exit 1"
Defaulted container "lago-events-worker" out of: lago-events-worker, wait-for-redis (init), wait-for-migrations (init)
command terminated with exit code 1

Expected behavior
The liveness probe should correctly verify that the process corresponding to the current hostname is running. When executed properly, the probe should succeed without timing out.

Support
Version: 1.17.4

Additional context
The issue appears to be related to the way command substitution is handled when passed directly as part of the liveness probe command. A working fix is to wrap the command in single quotes and assign the output of hostname to a variable within the shell:

livenessProbe:
  exec:
    command:
      - /bin/bash
      - -l
      - -c
      - 'host=$(hostname); bundle exec sidekiqmon processes | grep -q "$host" || exit 1'

This change prevents the premature interpolation of $(hostname) and allows the command to execute correctly within the container.

@jdenquin
Copy link
Contributor

jdenquin commented Feb 7, 2025

👋 @ilya-vasiuk, we added an other healthcheck for workers, its not documented right now.
You can do an http healthcheck on http://localhost instead of the sidekiqmon method

@ilya-vasiuk
Copy link
Author

Thanks, @jdenquin, I'll try this approach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants