Fix health check timing logic for StartPeriod and Interval#49035
Open
Kturfah02 wants to merge 2 commits intomoby:masterfrom
Open
Fix health check timing logic for StartPeriod and Interval#49035Kturfah02 wants to merge 2 commits intomoby:masterfrom
Kturfah02 wants to merge 2 commits intomoby:masterfrom
Conversation
Collaborator
|
Looks like we never reviewed this PR, but it looks good. @Kturfah02: thanks for working on this; are you willing to refresh the PR and we will take a look right away? Otherwise I can open a new one and take it to complettion. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #46747
How I did it
Updated the monitor function in health.go to correctly calculate the interval after the StartPeriod ends.
Ensured that the health checks respect the configured HealthStartPeriod and HealthInterval.
Added logic to dynamically adjust the scheduling of health checks based on elapsed time and configuration.
How to verify it
Run a container with the following health check configuration:
docker run -d --name health-test
--health-cmd "/bin/false"
--health-interval=2s
--health-start-period=2s
--health-retries=1
alpine:latest sleep 60
Inspect the health check logs with:
docker inspect --format='{{json .State.Health}}' health-test
Confirm that the first health check occurs immediately after the StartPeriod ends.
Confirm subsequent checks occur at the configured HealthInterval.
Verify the container's health status transitions to "unhealthy" after a failing health check.
Description for the changelog:
Fixed health check timing to ensure probes begin immediately after the
StartPeriodends, adhering to the configured interval.Signed-off-by: Karim Turfah kturfah02@gmail.com