Skip to content

Commit a466ace

Browse files
roffemurali-reddy
authored andcommitted
Nsc conntrack fix (#305)
* added conntrack exit handling logic * fixed regex * regex fix again
1 parent e25c174 commit a466ace

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

app/controllers/network_services_controller.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"os"
1111
"os/exec"
1212
"reflect"
13+
"regexp"
1314
"runtime"
1415
"strconv"
1516
"strings"
@@ -295,6 +296,10 @@ type externalIPService struct {
295296
func (nsc *NetworkServicesController) syncIpvsServices(serviceInfoMap serviceInfoMap, endpointsInfoMap endpointsInfoMap) error {
296297

297298
var ipvsSvcs []*ipvs.Service
299+
300+
// Conntrack exits with non zero exit code when exiting if 0 flow entries have been deleted, use regex to check output and don't Error when matching
301+
re := regexp.MustCompile("([[:space:]]0 flow entries have been deleted.)")
302+
298303
start := time.Now()
299304

300305
defer func() {
@@ -615,9 +620,11 @@ func (nsc *NetworkServicesController) syncIpvsServices(serviceInfoMap serviceInf
615620

616621
// flush conntrack when endpoint for a UDP service changes
617622
if ipvsSvc.Protocol == syscall.IPPROTO_UDP {
618-
_, err := exec.Command("conntrack", "-D", "--orig-dst", dst.Address.String(), "-p", "udp", "--dport", strconv.Itoa(int(dst.Port))).Output()
623+
out, err := exec.Command("conntrack", "-D", "--orig-dst", dst.Address.String(), "-p", "udp", "--dport", strconv.Itoa(int(dst.Port))).CombinedOutput()
619624
if err != nil {
620-
glog.Error("Failed to delete conntrack entry for endpoint: " + dst.Address.String() + ":" + strconv.Itoa(int(dst.Port)) + " due to " + err.Error())
625+
if matched := re.MatchString(string(out)); !matched {
626+
glog.Error("Failed to delete conntrack entry for endpoint: " + dst.Address.String() + ":" + strconv.Itoa(int(dst.Port)) + " due to " + err.Error())
627+
}
621628
}
622629
glog.V(1).Infof("Deleted conntrack entry for endpoint: " + dst.Address.String() + ":" + strconv.Itoa(int(dst.Port)))
623630
}

0 commit comments

Comments
 (0)