Skip to content

Fix health check timing logic for StartPeriod and Interval#49035

Open
Kturfah02 wants to merge 2 commits intomoby:masterfrom
Kturfah02:master
Open

Fix health check timing logic for StartPeriod and Interval#49035
Kturfah02 wants to merge 2 commits intomoby:masterfrom
Kturfah02:master

Conversation

@Kturfah02
Copy link
Copy Markdown

@Kturfah02 Kturfah02 commented Dec 5, 2024

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 StartPeriod ends, adhering to the configured interval.

Signed-off-by: Karim Turfah kturfah02@gmail.com

@thaJeztah thaJeztah added this to the 29.0.0 milestone Jan 17, 2025
@thaJeztah thaJeztah added the dco/no Automatically set by a bot when one of the commits lacks proper signature label Jan 17, 2025
@thompson-shaun thompson-shaun modified the milestones: 29.0.0, 29.1.0 Jul 21, 2025
@ctalledo
Copy link
Copy Markdown
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!

@ctalledo ctalledo self-requested a review August 21, 2025 21:51
Copy link
Copy Markdown
Collaborator

@ctalledo ctalledo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diffs look good.

@vvoland vvoland modified the milestones: 29.1.0, v-future Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco/no Automatically set by a bot when one of the commits lacks proper signature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Behaviour when container HealthStartPeriod < HealthStartInterval is unintuitive

5 participants