Skip to content
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

[v1.18] Move ipvs lib to third_party/forked and fix address family bug present in old kernels #90678

Merged
merged 9 commits into from May 9, 2020
Merged
210 changes: 0 additions & 210 deletions Godeps/LICENSES

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion cluster/gce/gci/configure-helper.sh
Expand Up @@ -1497,7 +1497,15 @@ function prepare-kube-proxy-manifest-variables {
params+=" --feature-gates=${FEATURE_GATES}"
fi
if [[ "${KUBE_PROXY_MODE:-}" == "ipvs" ]];then
sudo modprobe -a ip_vs ip_vs_rr ip_vs_wrr ip_vs_sh nf_conntrack_ipv4
# use 'nf_conntrack' instead of 'nf_conntrack_ipv4' for linux kernel >= 4.19
# https://github.com/kubernetes/kubernetes/pull/70398
local -r kernel_version=$(uname -r | cut -d\. -f1,2)
local conntrack_module="nf_conntrack"
if [[ $(printf "${kernel_version}\n4.18\n" | sort -V | tail -1) == "4.18" ]]; then
conntrack_module="nf_conntrack_ipv4"
fi

sudo modprobe -a ip_vs ip_vs_rr ip_vs_wrr ip_vs_sh ${conntrack_module}
if [[ $? -eq 0 ]];
then
params+=" --proxy-mode=ipvs"
Expand Down
5 changes: 2 additions & 3 deletions go.mod
Expand Up @@ -48,7 +48,6 @@ require (
github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0
github.com/docker/go-connections v0.3.0
github.com/docker/go-units v0.4.0
github.com/docker/libnetwork v0.8.0-dev.2.0.20190925143933-c8a5fca4a652
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153
github.com/emicklei/go-restful v2.9.5+incompatible
github.com/euank/go-kmsg-parser v2.0.0+incompatible // indirect
Expand Down Expand Up @@ -106,6 +105,7 @@ require (
github.com/quobyte/api v0.1.2
github.com/robfig/cron v1.1.0
github.com/seccomp/libseccomp-golang v0.9.1 // indirect
github.com/sirupsen/logrus v1.4.2
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/spf13/afero v1.2.2
github.com/spf13/cobra v0.0.5
Expand All @@ -118,7 +118,7 @@ require (
github.com/thecodeteam/goscaleio v0.1.0
github.com/urfave/negroni v1.0.0 // indirect
github.com/vishvananda/netlink v1.0.0
github.com/vishvananda/netns v0.0.0-20171111001504-be1fbeda1936 // indirect
github.com/vishvananda/netns v0.0.0-20171111001504-be1fbeda1936
github.com/vmware/govmomi v0.20.3
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738
golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975
Expand Down Expand Up @@ -251,7 +251,6 @@ replace (
github.com/docker/docker => github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0
github.com/docker/go-connections => github.com/docker/go-connections v0.3.0
github.com/docker/go-units => github.com/docker/go-units v0.4.0
github.com/docker/libnetwork => github.com/docker/libnetwork v0.8.0-dev.2.0.20190925143933-c8a5fca4a652
github.com/docker/spdystream => github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96
github.com/dustin/go-humanize => github.com/dustin/go-humanize v1.0.0
github.com/elazarl/goproxy => github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153 // 947c36da3153 is the SHA for git tag v1.11
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Expand Up @@ -140,8 +140,6 @@ github.com/docker/go-connections v0.3.0 h1:3lOnM9cSzgGwx8VfK/NGOW5fLQ0GjIlCkaktF
github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/docker/libnetwork v0.8.0-dev.2.0.20190925143933-c8a5fca4a652 h1:alzR0hpQ/vaeYQAiqpCzrcbDbGMBAghmjT8nYe0To3I=
github.com/docker/libnetwork v0.8.0-dev.2.0.20190925143933-c8a5fca4a652/go.mod h1:93m0aTqz6z+g32wla4l4WxTrdtvBRmVzYRkYvasA5Z8=
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 h1:cenwrSVm+Z7QLSV/BsnenAOcDXdX4cMv4wP0B/5QbPg=
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
Expand Down
8 changes: 4 additions & 4 deletions pkg/util/ipvs/BUILD
Expand Up @@ -17,10 +17,10 @@ go_test(
"//staging/src/k8s.io/apimachinery/pkg/util/version:go_default_library",
] + select({
"@io_bazel_rules_go//go/platform:android": [
"//vendor/github.com/docker/libnetwork/ipvs:go_default_library",
"//third_party/forked/ipvs:go_default_library",
],
"@io_bazel_rules_go//go/platform:linux": [
"//vendor/github.com/docker/libnetwork/ipvs:go_default_library",
"//third_party/forked/ipvs:go_default_library",
],
"//conditions:default": [],
}),
Expand All @@ -39,7 +39,7 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/util/version:go_default_library",
] + select({
"@io_bazel_rules_go//go/platform:android": [
"//vendor/github.com/docker/libnetwork/ipvs:go_default_library",
"//third_party/forked/ipvs:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/utils/exec:go_default_library",
],
Expand All @@ -56,7 +56,7 @@ go_library(
"//vendor/k8s.io/utils/exec:go_default_library",
],
"@io_bazel_rules_go//go/platform:linux": [
"//vendor/github.com/docker/libnetwork/ipvs:go_default_library",
"//third_party/forked/ipvs:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/utils/exec:go_default_library",
],
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/ipvs/ipvs_linux.go
Expand Up @@ -27,8 +27,8 @@ import (
"syscall"
"time"

libipvs "github.com/docker/libnetwork/ipvs"
"k8s.io/klog"
libipvs "k8s.io/kubernetes/third_party/forked/ipvs"
utilexec "k8s.io/utils/exec"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/util/ipvs/ipvs_linux_test.go
Expand Up @@ -25,7 +25,7 @@ import (
"syscall"
"testing"

libipvs "github.com/docker/libnetwork/ipvs"
libipvs "k8s.io/kubernetes/third_party/forked/ipvs"
)

func Test_toVirtualServer(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/framework/.import-restrictions
Expand Up @@ -270,7 +270,8 @@
{
"SelectorRegexp": "k8s[.]io/kubernetes/third_party/",
"AllowedPrefixes": [
"k8s.io/kubernetes/third_party/forked/golang/expansion"
"k8s.io/kubernetes/third_party/forked/golang/expansion",
"k8s.io/kubernetes/third_party/forked/ipvs"
],
"ForbiddenPrefixes": []
},
Expand Down
12 changes: 12 additions & 0 deletions test/e2e/network/service.go
Expand Up @@ -3067,6 +3067,18 @@ func execAffinityTestForSessionAffinityTimeout(f *framework.Framework, cs client
serviceType := svc.Spec.Type
// set an affinity timeout equal to the number of connection requests
svcSessionAffinityTimeout := int32(AffinityConfirmCount)
if proxyMode, err := proxyMode(f); err == nil {
if proxyMode == "ipvs" {
// session affinity timeout must be greater than 120 in ipvs mode,
// because IPVS module has a hardcoded TIME_WAIT timeout of 120s,
// and that value can't be sysctl'ed now.
// Ref: https://github.com/torvalds/linux/blob/master/net/netfilter/ipvs/ip_vs_proto_tcp.c
// TODO: remove this to speed up testing when IPVS does really respect session affinity timeout
svcSessionAffinityTimeout = int32(125)
}
} else {
framework.Logf("Couldn't detect KubeProxy mode - test failure may be expected: %v", err)
}
svc.Spec.SessionAffinity = v1.ServiceAffinityClientIP
svc.Spec.SessionAffinityConfig = &v1.SessionAffinityConfig{
ClientIP: &v1.ClientIPConfig{TimeoutSeconds: &svcSessionAffinityTimeout},
Expand Down
1 change: 1 addition & 0 deletions third_party/BUILD
Expand Up @@ -22,6 +22,7 @@ filegroup(
"//third_party/forked/golang/reflect:all-srcs",
"//third_party/forked/golang/template:all-srcs",
"//third_party/forked/gonum/graph:all-srcs",
"//third_party/forked/ipvs:all-srcs",
"//third_party/go-srcimporter:all-srcs",
],
tags = ["automanaged"],
Expand Down
@@ -1,4 +1,6 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

licenses(["notice"])

go_library(
name = "go_default_library",
Expand All @@ -7,8 +9,7 @@ go_library(
"ipvs.go",
"netlink.go",
],
importmap = "k8s.io/kubernetes/vendor/github.com/docker/libnetwork/ipvs",
importpath = "github.com/docker/libnetwork/ipvs",
importpath = "k8s.io/kubernetes/third_party/forked/ipvs",
visibility = ["//visibility:public"],
deps = select({
"@io_bazel_rules_go//go/platform:android": [
Expand Down Expand Up @@ -40,3 +41,9 @@ filegroup(
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

go_test(
name = "go_default_test",
srcs = ["netlink_test.go"],
embed = [":go_default_library"],
)
@@ -1,5 +1,8 @@
// +build linux

// Code and documentation copyright 2015 Docker, inc.
// Code released under the Apache 2.0 license. Docs released under Creative commons.

package ipvs

const (
Expand Down