check if the pod is terminating in the healthcheck#431
Merged
Conversation
asloobq
reviewed
May 1, 2025
| private AtomicReference<List<IHealthComponent>> componentList = new AtomicReference(new ArrayList<IHealthComponent>()); | ||
| private AtomicReference<Boolean> cachedPodTerminating = new AtomicReference<>(false); | ||
| private long lastPodCheckTime = 0; | ||
| private static final long FILE_CHECK_INTERVAL_MS = 3000; |
Contributor
There was a problem hiding this comment.
can we make this a configurable setting ?
| boolean componentsHealthy = list.stream().filter(c -> !c.isHealthy()).count() == 0; | ||
| File file = new File("/app/pod_terminating"); | ||
| boolean podTerminating = file.exists(); | ||
| boolean podTerminating = checkPodTerminating(); |
Contributor
There was a problem hiding this comment.
probably don't need a new boolean variable
asloobq
approved these changes
May 1, 2025
mcollins-ttd
reviewed
May 1, 2025
| return componentsHealthy && !checkPodTerminating(); | ||
| } | ||
|
|
||
| private boolean checkPodTerminating() { |
Contributor
There was a problem hiding this comment.
I don't think checking for a pod termination file should be a responsibility of HealthManager. This could be done as its own health check component.
Contributor
Author
There was a problem hiding this comment.
If we reuse the pattern of the named components, then that would have us register to health manager by some string ID. Then we need some background thread monitoring continuously to update the health component right?
Contributor
There was a problem hiding this comment.
You don't need a background thread, you could use a period timer. A simple implementation:
private void periodicallyCheckForShutdownFile(Duration interval, String file) {
this.vertx.setPeriodic(interval.toMillis(), l -> {
if (vertx.fileSystem().existsBlocking(file)) {
healthComponent.setHealthStatus(false, "shutting down");
}
});
}
asloobq
approved these changes
May 2, 2025
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.
No description provided.