Skip to content

Commit 94a2ec7

Browse files
authored
Flush conntrack entry when UDP service endpoint is deleted (#259)
Fixes #157 kubernetes/kubernetes#19029 kubernetes/kubernetes#22573
1 parent 8ce5e4f commit 94a2ec7

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ RUN apk add --no-cache \
1111
ipset \
1212
iproute2 \
1313
ipvsadm \
14+
conntrack-tools \
1415
curl \
1516
bash && \
1617
mkdir -p /var/lib/gobgp && \

app/controllers/network_services_controller.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,15 @@ func (nsc *NetworkServicesController) syncIpvsServices(serviceInfoMap serviceInf
537537
glog.Errorf("Failed to delete destination %s from ipvs service %s",
538538
ipvsDestinationString(dst), ipvsServiceString(ipvsSvc))
539539
}
540+
541+
// flush conntrack when endpoint for a UDP service changes
542+
if ipvsSvc.Protocol == syscall.IPPROTO_UDP {
543+
_, err := exec.Command("conntrack", "-D", "--orig-dst", dst.Address.String(), "-p", "udp", "--dport", strconv.Itoa(int(dst.Port))).Output()
544+
if err != nil {
545+
glog.Error("Failed to delete conntrack entry for endpoint: " + dst.Address.String() + ":" + strconv.Itoa(int(dst.Port)) + " due to " + err.Error())
546+
}
547+
glog.Infof("Deleted conntrack entry for endpoint: " + dst.Address.String() + ":" + strconv.Itoa(int(dst.Port)))
548+
}
540549
}
541550
}
542551
}

0 commit comments

Comments
 (0)