Skip to content

Conversation

@ipochi
Copy link
Contributor

@ipochi ipochi commented Oct 27, 2025

Currently, the server doesn't do graceful termination upon receiving kill signals. This PR proposes the fix to add a configurable graceful termination to the server.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ipochi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 27, 2025
Signed-off-by: Imran Pochi <imranpochi@microsoft.com>
@ipochi ipochi force-pushed the imran/graceful-termination-for-server branch from c14cffa to dedeefa Compare October 27, 2025 21:52
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 27, 2025
Signed-off-by: Imran Pochi <imranpochi@microsoft.com>
EnableLeaseController: false,
LeaseNamespace: "kube-system",
LeaseLabel: "k8s-app=konnectivity-server",
GracefulShutdownTimeout: 15 * time.Second,
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the feature but I think we need to be backward compatible. We should default to 0 which means shutdown immediately and is the current behavior.


<-stopCh
klog.V(1).Infoln("Shutting down server.")
klog.V(1).Infoln("Received shutdown signal, initiating graceful shutdown.")
Copy link
Contributor

Choose a reason for hiding this comment

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

We should wrap most of this new code in a if graceful timeout != 0 block.

// Wait for all servers to shutdown or timeout
shutdownComplete := make(chan struct{})
go func() {
wg.Wait()
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we know what happens if the other goroutined have completed before this Wait is called? My guess is that is will never trigger. I think it makes more sense to do the non-optional adds. Kick off this goroutines, then kick off the workers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants