mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 12:07:47 +00:00
Merge pull request #104952 from dcantah/cleanup-hcn
Replace custom dualstack support logic in Windows Kube-proxy
This commit is contained in:
commit
86003a2a76
@ -39,7 +39,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
apiutil "k8s.io/apimachinery/pkg/util/net"
|
apiutil "k8s.io/apimachinery/pkg/util/net"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/apimachinery/pkg/util/version"
|
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
"k8s.io/client-go/tools/events"
|
"k8s.io/client-go/tools/events"
|
||||||
@ -188,20 +187,22 @@ func (t DualStackCompatTester) DualStackCompatible(networkName string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
globals, err := hcn.GetGlobals()
|
// First tag of hcsshim that has a proper check for dual stack support is v0.8.22 due to a bug.
|
||||||
if err != nil {
|
if err := hcn.IPv6DualStackSupported(); err != nil {
|
||||||
klog.ErrorS(err, "Unable to determine networking stack version. Falling back to single-stack")
|
// Hcn *can* fail the query to grab the version of hcn itself (which this call will do internally before parsing
|
||||||
return false
|
// to see if dual stack is supported), but the only time this can happen, at least that can be discerned, is if the host
|
||||||
}
|
// is pre-1803 and hcn didn't exist. hcsshim should truthfully return a known error if this happened that we can
|
||||||
|
// check against, and the case where 'err != this known error' would be the 'this feature isn't supported' case, as is being
|
||||||
if !kernelSupportsDualstack(globals.Version) {
|
// used here. For now, seeming as how nothing before ws2019 (1809) is listed as supported for k8s we can pretty much assume
|
||||||
klog.InfoS("This version of Windows does not support dual-stack. Falling back to single-stack")
|
// any error here isn't because the query failed, it's just that dualstack simply isn't supported on the host. With all
|
||||||
|
// that in mind, just log as info and not error to let the user know we're falling back.
|
||||||
|
klog.InfoS("This version of Windows does not support dual-stack. Falling back to single-stack", "err", err.Error())
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if network is using overlay
|
// check if network is using overlay
|
||||||
hns, _ := newHostNetworkService()
|
hns, _ := newHostNetworkService()
|
||||||
networkName, err = getNetworkName(networkName)
|
networkName, err := getNetworkName(networkName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.ErrorS(err, "unable to determine dual-stack status %v. Falling back to single-stack")
|
klog.ErrorS(err, "unable to determine dual-stack status %v. Falling back to single-stack")
|
||||||
return false
|
return false
|
||||||
@ -221,19 +222,6 @@ func (t DualStackCompatTester) DualStackCompatible(networkName string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// The hcsshim version logic has a bug that did not calculate the versioning of DualStack correctly.
|
|
||||||
// DualStack is supported in WS 2004+ (10.0.19041+) where HCN component version is 11.10+
|
|
||||||
// https://github.com/microsoft/hcsshim/pull/1003#issuecomment-827930358
|
|
||||||
func kernelSupportsDualstack(currentVersion hcn.Version) bool {
|
|
||||||
hnsVersion := fmt.Sprintf("%d.%d.0", currentVersion.Major, currentVersion.Minor)
|
|
||||||
v, err := version.ParseSemantic(hnsVersion)
|
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return v.AtLeast(version.MustParseSemantic("11.10.0"))
|
|
||||||
}
|
|
||||||
|
|
||||||
func Log(v interface{}, message string, level klog.Level) {
|
func Log(v interface{}, message string, level klog.Level) {
|
||||||
klog.V(level).InfoS("%s", message, "spewConfig", spewSdump(v))
|
klog.V(level).InfoS("%s", message, "spewConfig", spewSdump(v))
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Microsoft/hcsshim/hcn"
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
discovery "k8s.io/api/discovery/v1"
|
discovery "k8s.io/api/discovery/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@ -931,54 +930,3 @@ func makeTestEndpointSlice(namespace, name string, sliceNum int, epsFunc func(*d
|
|||||||
epsFunc(eps)
|
epsFunc(eps)
|
||||||
return eps
|
return eps
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_kernelSupportsDualstack(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
currentVersion hcn.Version
|
|
||||||
name string
|
|
||||||
want bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
hcn.Version{Major: 10, Minor: 10},
|
|
||||||
"Less than minimal should not be supported",
|
|
||||||
false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
hcn.Version{Major: 9, Minor: 11},
|
|
||||||
"Less than minimal should not be supported",
|
|
||||||
false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
hcn.Version{Major: 11, Minor: 1},
|
|
||||||
"Less than minimal should not be supported",
|
|
||||||
false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
hcn.Version{Major: 11, Minor: 10},
|
|
||||||
"Current version should be supported",
|
|
||||||
true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
hcn.Version{Major: 11, Minor: 11},
|
|
||||||
"Greater than minimal version should be supported",
|
|
||||||
true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
hcn.Version{Major: 12, Minor: 1},
|
|
||||||
"Greater than minimal version should be supported",
|
|
||||||
true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
hcn.Version{Major: 12, Minor: 12},
|
|
||||||
"Greater than minimal should be supported",
|
|
||||||
true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
if got := kernelSupportsDualstack(tt.currentVersion); got != tt.want {
|
|
||||||
t.Errorf("kernelSupportsDualstack on version %v: got %v, want %v", tt.currentVersion, got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user