Closed junger-dev closed 7 months ago
Is this causing a problem? The situation is that the informer is waiting for an event. When you chose to shutdown, that wait needs to be broken, or the shutdown will hang until another event comes.
I suppose we could deliver a "watch stopping" event or something like that on shutdown, but this really shouldn't cause any problems (other than printing the exception into the logs) if you are shutting down your application anyway.
cc @yue9944882 for thoughts.
@brendandburns Thank you for the swift response.
Is this causing a problem?
: There are no issues with the application.
I understand that the informer waits for an event and needs to be interrupted to ensure the application doesn't hang during shutdown. My primary concern arises from the exception being logged, even if the application seems to shut down properly. In an environment where monitoring and alerting tools are sensitive to such exceptions, this can trigger false alarms — and it currently does.
Is there an existing configuration or workaround to address this behavior in the current version? If not, would excluding this error log from our monitoring alert tool be the best approach?
Thank you again.
The SharedIndexInformerFactory class allows you to pass in a custom exception handler:
Which will control what happens when an exception is thrown (or at least it should)
It's possible that not all of the right plumbing is in the right places to make this happen from Spring.
Please take a look at that code and see if it works for you. If not, can you add more details here about what is needed?
Thanks!
@brendandburns
Thank you for pointing out the SharedIndexInformerFactory class and its capabilities. While the SharedIndexInformerFactory class provides an option to pass in a custom exception handler to deal with the InterruptedException, I believe a more desirable approach would be to ensure that the informer and associated resources are terminated properly before the application shuts down. This preventive approach could lead to a more stable and predictable behavior during the shutdown process, rather than addressing the exception after it occurs.
Given that Kubernetes already has a preStop hook functionality, we can leverage this by triggering an endpoint like /kubernetes-client/informers/stop before the actual application shutdown. It would be beneficial if a future release of the Kubernetes Client could introduce methods like stop() or something similar for components like Controller. This would enable applications to shut down these components gracefully and release the associated resources.
Given that interrupting the wait as you suggest is complicated to implement and we have a custom exception handler to suppress the log, I don't think this is a high priority to fix. However, if you want to send a PR implementing the approach that you suggest we would be happy to review that PR.
Thanks!
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle stale
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle rotten
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/reopen
/remove-lifecycle rotten
Please send feedback to sig-contributor-experience at kubernetes/community.
/close not-planned
@k8s-triage-robot: Closing this issue, marking it as "Not Planned".
Issue Description:
During the graceful shutdown process of my Spring Boot application in a Kubernetes environment, I noticed that the Kubernetes Client's informer and related threads are getting interrupted. Here's a snippet of the logs during the shutdown process:
Environment:
Expected Behavior:
The Kubernetes Client's threads (like the informer) should not be interrupted during a graceful shutdown, or should be able to handle interruptions more gracefully.
Actual Behavior:
The threads are getting interrupted and are throwing InterruptedException.
Question:
Is there a recommended way to cleanup Kubernetes Client resources during a pod's preStop hook or any other mechanism to avoid such interruptions?
Any insights or recommendations on how to handle this situation would be greatly appreciated.