Conversation
There was a problem hiding this comment.
Pull request overview
Adds graceful shutdown handling to the heartbeat container entrypoint so it can terminate cleanly (e.g., during Pod termination) instead of continuing to wait/start work after receiving SIGTERM.
Changes:
- Added
SIGTERM/SIGINTtrap and a shutdown flag checked during the initialization/clone wait loops. - Switched to
exec pt-heartbeatsopt-heartbeatbecomes PID 1 and receives termination signals directly.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
This PR improves shutdown behavior for the heartbeat sidecar/utility by handling SIGTERM in build/heartbeat-entrypoint.sh so the script can exit cleanly while waiting on MySQL init/clone, and ensures pt-heartbeat receives termination signals directly.
Changes:
- Add
SIGTERM/SIGINTtrap and early-exit checks during MySQL init/clone wait loops. - Improve clone-wait loop robustness (quoting in numeric comparisons; 1-second sleep intervals for responsiveness).
- Run
pt-heartbeatviaexecso it becomes PID 1 and receives shutdown signals directly.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| until [ ! -f "$DATA_DIR/bootstrap.lock" ] && [ ! -f "$DATA_DIR/clone.lock" ] && [ -S "$DATA_DIR/mysql.sock" ]; do | ||
| if [ "$shutdown_requested" -eq 1 ]; then | ||
| exit 0 | ||
| fi | ||
| echo '[INFO] Waiting for MySQL initialization ...' | ||
| sleep 10 |
| if [ "$shutdown_requested" -eq 1 ]; then | ||
| exit 0 | ||
| fi | ||
| sleep 10 |
There was a problem hiding this comment.
computer has a point, please consider implementing this
commit: 862a05f |
https://perconadev.atlassian.net/browse/K8SPS-497
DESCRIPTION
This PR handle SIGTERM in the
heartbeat-entrypoint.shand exits while waiting for MySQL initialization or clone completion. It also runspt-heartbeatwithexecso it receives shutdown signals directlyCHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
Config/Logging/Testability