Flush conntrack entry when UDP service endpoint is deleted (#259)

Fixes #157

kubernetes/kubernetes#19029
kubernetes/kubernetes#22573
This commit is contained in:
Murali Reddy 2017-12-25 02:08:04 +05:30 committed by GitHub
parent 8ce5e4fe3d
commit 94a2ec7e17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -11,6 +11,7 @@ RUN apk add --no-cache \
ipset \
iproute2 \
ipvsadm \
conntrack-tools \
curl \
bash && \
mkdir -p /var/lib/gobgp && \

View File

@ -537,6 +537,15 @@ func (nsc *NetworkServicesController) syncIpvsServices(serviceInfoMap serviceInf
glog.Errorf("Failed to delete destination %s from ipvs service %s",
ipvsDestinationString(dst), ipvsServiceString(ipvsSvc))
}
// flush conntrack when endpoint for a UDP service changes
if ipvsSvc.Protocol == syscall.IPPROTO_UDP {
_, err := exec.Command("conntrack", "-D", "--orig-dst", dst.Address.String(), "-p", "udp", "--dport", strconv.Itoa(int(dst.Port))).Output()
if err != nil {
glog.Error("Failed to delete conntrack entry for endpoint: " + dst.Address.String() + ":" + strconv.Itoa(int(dst.Port)) + " due to " + err.Error())
}
glog.Infof("Deleted conntrack entry for endpoint: " + dst.Address.String() + ":" + strconv.Itoa(int(dst.Port)))
}
}
}
}