Skip to content

Commit

Permalink
Merge pull request #71515 from DataDog/lbernail/udp-graceful
Browse files Browse the repository at this point in the history
Enable graceful termination for UDP flows when using kube-proxy in IPVS mode
  • Loading branch information
k8s-ci-robot committed Nov 30, 2018
2 parents 16c0f3c + b11233a commit 25c9ac6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions pkg/proxy/ipvs/graceful_termination.go
Expand Up @@ -75,10 +75,10 @@ func (q *graceTerminateRSList) remove(rs *listItem) bool {

uniqueRS := rs.String()
if _, ok := q.list[uniqueRS]; ok {
return false
delete(q.list, uniqueRS)
return true
}
delete(q.list, uniqueRS)
return true
return false
}

func (q *graceTerminateRSList) flushList(handler func(rsToDelete *listItem) (bool, error)) bool {
Expand Down Expand Up @@ -164,7 +164,10 @@ func (m *GracefulTerminationManager) deleteRsFunc(rsToDelete *listItem) (bool, e
}
for _, rs := range rss {
if rsToDelete.RealServer.Equal(rs) {
if rs.ActiveConn != 0 {
// Delete RS with no connections
// For UDP, ActiveConn is always 0
// For TCP, InactiveConn are connections not in ESTABLISHED state
if rs.ActiveConn+rs.InactiveConn != 0 {
return false, nil
}
klog.Infof("Deleting rs: %s", rsToDelete.String())
Expand Down
2 changes: 1 addition & 1 deletion pkg/proxy/ipvs/proxier.go
Expand Up @@ -1602,7 +1602,7 @@ func (proxier *Proxier) syncEndpoint(svcPortName proxy.ServicePortName, onlyNode
Port: uint16(portNum),
}

klog.V(5).Infof("Using graceful delete to delete: %v", delDest)
klog.V(5).Infof("Using graceful delete to delete: %v", uniqueRS)
err = proxier.gracefuldeleteManager.GracefulDeleteRS(appliedVirtualServer, delDest)
if err != nil {
klog.Errorf("Failed to delete destination: %v, error: %v", delDest, err)
Expand Down

0 comments on commit 25c9ac6

Please sign in to comment.