Skip to content

make NSC set net.ipv4.vs.conn_reuse_mode=0 #577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion pkg/controllers/proxy/network_services_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/vishvananda/netlink"
"github.com/vishvananda/netns"
"golang.org/x/net/context"

api "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -295,6 +294,11 @@ func (nsc *NetworkServicesController) Run(healthChan chan<- *healthcheck.Control
return errors.New("Failed to do sysctl net.ipv4.vs.expire_quiescent_template=1 due to: %s" + err.Error())
}

err = ensureIpvsConnReuseMode()
if err != nil {
return fmt.Errorf("failed to set net.ipv4.vs.conn_reuse_mode=0: %s", err)
}

// loop forever unitl notified to stop on stopCh
for {
select {
Expand Down Expand Up @@ -1405,6 +1409,19 @@ func ensureIpvsConntrack() error {
return ioutil.WriteFile("/proc/sys/net/ipv4/vs/conntrack", []byte(strconv.Itoa(1)), 0640)
}

func ensureIpvsConnReuseMode() error {
sysctlPath := "/proc/sys/net/ipv4/vs/conn_reuse_mode"
if _, err := os.Stat(sysctlPath); err != nil {
if os.IsNotExist(err) {
glog.Infof("%s not found, skipping setting net.ipv4.vs.conn_reuse_mode=0 (non fatal error, feature introduced into kernel in 4.1)", sysctlPath)
return nil
}
glog.Errorf("skipping setting net.ipv4.vs.conn_reuse_mode=0, error stating: %s : %s", sysctlPath, err.Error())
return nil
}
return ioutil.WriteFile("sysctlPath", []byte(strconv.Itoa(0)), 0640)
}

func ensureIpvsExpireNodestConn() error {
return ioutil.WriteFile("/proc/sys/net/ipv4/vs/expire_nodest_conn", []byte(strconv.Itoa(1)), 0640)
}
Expand Down