mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
gofmt update
This commit is contained in:
parent
e466bdc67e
commit
cbe94df8c6
@ -23,10 +23,10 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/apimachinery/pkg/util/validation"
|
"k8s.io/apimachinery/pkg/util/validation"
|
||||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||||
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
apivalidation "k8s.io/kubernetes/pkg/apis/core/validation"
|
apivalidation "k8s.io/kubernetes/pkg/apis/core/validation"
|
||||||
"k8s.io/kubernetes/pkg/apis/networking"
|
"k8s.io/kubernetes/pkg/apis/networking"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
|
||||||
"k8s.io/kubernetes/pkg/features"
|
"k8s.io/kubernetes/pkg/features"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ func ValidateNetworkPolicyPort(port *networking.NetworkPolicyPort, portPath *fie
|
|||||||
allErrs = append(allErrs, field.NotSupported(portPath.Child("protocol"), *port.Protocol, []string{string(api.ProtocolTCP), string(api.ProtocolUDP), string(api.ProtocolSCTP)}))
|
allErrs = append(allErrs, field.NotSupported(portPath.Child("protocol"), *port.Protocol, []string{string(api.ProtocolTCP), string(api.ProtocolUDP), string(api.ProtocolSCTP)}))
|
||||||
}
|
}
|
||||||
} else if port.Protocol != nil && *port.Protocol != api.ProtocolTCP && *port.Protocol != api.ProtocolUDP {
|
} else if port.Protocol != nil && *port.Protocol != api.ProtocolTCP && *port.Protocol != api.ProtocolUDP {
|
||||||
allErrs = append(allErrs, field.NotSupported(portPath.Child("protocol"), *port.Protocol, []string{string(api.ProtocolTCP), string(api.ProtocolUDP)}))
|
allErrs = append(allErrs, field.NotSupported(portPath.Child("protocol"), *port.Protocol, []string{string(api.ProtocolTCP), string(api.ProtocolUDP)}))
|
||||||
}
|
}
|
||||||
if port.Port != nil {
|
if port.Port != nil {
|
||||||
if port.Port.Type == intstr.Int {
|
if port.Port.Type == intstr.Int {
|
||||||
|
@ -21,10 +21,10 @@ import (
|
|||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/networking"
|
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
utilfeaturetesting "k8s.io/apiserver/pkg/util/feature/testing"
|
utilfeaturetesting "k8s.io/apiserver/pkg/util/feature/testing"
|
||||||
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
|
"k8s.io/kubernetes/pkg/apis/networking"
|
||||||
"k8s.io/kubernetes/pkg/features"
|
"k8s.io/kubernetes/pkg/features"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -422,11 +422,8 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS
|
|||||||
ResourceQuotaScopeSelectors: {Default: true, PreRelease: utilfeature.Beta},
|
ResourceQuotaScopeSelectors: {Default: true, PreRelease: utilfeature.Beta},
|
||||||
CSIBlockVolume: {Default: false, PreRelease: utilfeature.Alpha},
|
CSIBlockVolume: {Default: false, PreRelease: utilfeature.Alpha},
|
||||||
RuntimeClass: {Default: false, PreRelease: utilfeature.Alpha},
|
RuntimeClass: {Default: false, PreRelease: utilfeature.Alpha},
|
||||||
<<<<<<< HEAD
|
|
||||||
NodeLease: {Default: false, PreRelease: utilfeature.Alpha},
|
NodeLease: {Default: false, PreRelease: utilfeature.Alpha},
|
||||||
=======
|
|
||||||
SCTPSupport: {Default: false, PreRelease: utilfeature.Alpha},
|
SCTPSupport: {Default: false, PreRelease: utilfeature.Alpha},
|
||||||
>>>>>>> Changes according to the approved KEP. SCTP is supported for HostPort and LoadBalancer. Alpha feature flag SCTPSupport controls the support of SCTP. Kube-proxy config parameter is removed.
|
|
||||||
|
|
||||||
// inherited features from generic apiserver, relisted here to get a conflict if it is changed
|
// inherited features from generic apiserver, relisted here to get a conflict if it is changed
|
||||||
// unintentionally on either side:
|
// unintentionally on either side:
|
||||||
|
@ -203,10 +203,10 @@ func TestHostportManager(t *testing.T) {
|
|||||||
Protocol: v1.ProtocolUDP,
|
Protocol: v1.ProtocolUDP,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
HostPort: 8083,
|
HostPort: 8083,
|
||||||
ContainerPort: 83,
|
ContainerPort: 83,
|
||||||
Protocol: v1.ProtocolSCTP,
|
Protocol: v1.ProtocolSCTP,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectError: false,
|
expectError: false,
|
||||||
@ -287,29 +287,29 @@ func TestHostportManager(t *testing.T) {
|
|||||||
lines := strings.Split(string(raw.Bytes()), "\n")
|
lines := strings.Split(string(raw.Bytes()), "\n")
|
||||||
expectedLines := map[string]bool{
|
expectedLines := map[string]bool{
|
||||||
`*nat`: true,
|
`*nat`: true,
|
||||||
`:KUBE-HOSTPORTS - [0:0]`: true,
|
`:KUBE-HOSTPORTS - [0:0]`: true,
|
||||||
`:OUTPUT - [0:0]`: true,
|
`:OUTPUT - [0:0]`: true,
|
||||||
`:PREROUTING - [0:0]`: true,
|
`:PREROUTING - [0:0]`: true,
|
||||||
`:POSTROUTING - [0:0]`: true,
|
`:POSTROUTING - [0:0]`: true,
|
||||||
`:KUBE-HP-IJHALPHTORMHHPPK - [0:0]`: true,
|
`:KUBE-HP-IJHALPHTORMHHPPK - [0:0]`: true,
|
||||||
`:KUBE-HP-63UPIDJXVRSZGSUZ - [0:0]`: true,
|
`:KUBE-HP-63UPIDJXVRSZGSUZ - [0:0]`: true,
|
||||||
`:KUBE-HP-WFBOALXEP42XEMJK - [0:0]`: true,
|
`:KUBE-HP-WFBOALXEP42XEMJK - [0:0]`: true,
|
||||||
`:KUBE-HP-XU6AWMMJYOZOFTFZ - [0:0]`: true,
|
`:KUBE-HP-XU6AWMMJYOZOFTFZ - [0:0]`: true,
|
||||||
"-A KUBE-HOSTPORTS -m comment --comment \"pod3_ns1 hostport 8443\" -m tcp -p tcp --dport 8443 -j KUBE-HP-WFBOALXEP42XEMJK": true,
|
"-A KUBE-HOSTPORTS -m comment --comment \"pod3_ns1 hostport 8443\" -m tcp -p tcp --dport 8443 -j KUBE-HP-WFBOALXEP42XEMJK": true,
|
||||||
"-A KUBE-HOSTPORTS -m comment --comment \"pod1_ns1 hostport 8081\" -m udp -p udp --dport 8081 -j KUBE-HP-63UPIDJXVRSZGSUZ": true,
|
"-A KUBE-HOSTPORTS -m comment --comment \"pod1_ns1 hostport 8081\" -m udp -p udp --dport 8081 -j KUBE-HP-63UPIDJXVRSZGSUZ": true,
|
||||||
"-A KUBE-HOSTPORTS -m comment --comment \"pod1_ns1 hostport 8080\" -m tcp -p tcp --dport 8080 -j KUBE-HP-IJHALPHTORMHHPPK": true,
|
"-A KUBE-HOSTPORTS -m comment --comment \"pod1_ns1 hostport 8080\" -m tcp -p tcp --dport 8080 -j KUBE-HP-IJHALPHTORMHHPPK": true,
|
||||||
"-A KUBE-HOSTPORTS -m comment --comment \"pod1_ns1 hostport 8083\" -m sctp -p sctp --dport 8083 -j KUBE-HP-XU6AWMMJYOZOFTFZ": true,
|
"-A KUBE-HOSTPORTS -m comment --comment \"pod1_ns1 hostport 8083\" -m sctp -p sctp --dport 8083 -j KUBE-HP-XU6AWMMJYOZOFTFZ": true,
|
||||||
"-A OUTPUT -m comment --comment \"kube hostport portals\" -m addrtype --dst-type LOCAL -j KUBE-HOSTPORTS": true,
|
"-A OUTPUT -m comment --comment \"kube hostport portals\" -m addrtype --dst-type LOCAL -j KUBE-HOSTPORTS": true,
|
||||||
"-A PREROUTING -m comment --comment \"kube hostport portals\" -m addrtype --dst-type LOCAL -j KUBE-HOSTPORTS": true,
|
"-A PREROUTING -m comment --comment \"kube hostport portals\" -m addrtype --dst-type LOCAL -j KUBE-HOSTPORTS": true,
|
||||||
"-A POSTROUTING -m comment --comment \"SNAT for localhost access to hostports\" -o cbr0 -s 127.0.0.0/8 -j MASQUERADE": true,
|
"-A POSTROUTING -m comment --comment \"SNAT for localhost access to hostports\" -o cbr0 -s 127.0.0.0/8 -j MASQUERADE": true,
|
||||||
"-A KUBE-HP-IJHALPHTORMHHPPK -m comment --comment \"pod1_ns1 hostport 8080\" -s 10.1.1.2/32 -j KUBE-MARK-MASQ": true,
|
"-A KUBE-HP-IJHALPHTORMHHPPK -m comment --comment \"pod1_ns1 hostport 8080\" -s 10.1.1.2/32 -j KUBE-MARK-MASQ": true,
|
||||||
"-A KUBE-HP-IJHALPHTORMHHPPK -m comment --comment \"pod1_ns1 hostport 8080\" -m tcp -p tcp -j DNAT --to-destination 10.1.1.2:80": true,
|
"-A KUBE-HP-IJHALPHTORMHHPPK -m comment --comment \"pod1_ns1 hostport 8080\" -m tcp -p tcp -j DNAT --to-destination 10.1.1.2:80": true,
|
||||||
"-A KUBE-HP-63UPIDJXVRSZGSUZ -m comment --comment \"pod1_ns1 hostport 8081\" -s 10.1.1.2/32 -j KUBE-MARK-MASQ": true,
|
"-A KUBE-HP-63UPIDJXVRSZGSUZ -m comment --comment \"pod1_ns1 hostport 8081\" -s 10.1.1.2/32 -j KUBE-MARK-MASQ": true,
|
||||||
"-A KUBE-HP-63UPIDJXVRSZGSUZ -m comment --comment \"pod1_ns1 hostport 8081\" -m udp -p udp -j DNAT --to-destination 10.1.1.2:81": true,
|
"-A KUBE-HP-63UPIDJXVRSZGSUZ -m comment --comment \"pod1_ns1 hostport 8081\" -m udp -p udp -j DNAT --to-destination 10.1.1.2:81": true,
|
||||||
"-A KUBE-HP-XU6AWMMJYOZOFTFZ -m comment --comment \"pod1_ns1 hostport 8083\" -s 10.1.1.2/32 -j KUBE-MARK-MASQ": true,
|
"-A KUBE-HP-XU6AWMMJYOZOFTFZ -m comment --comment \"pod1_ns1 hostport 8083\" -s 10.1.1.2/32 -j KUBE-MARK-MASQ": true,
|
||||||
"-A KUBE-HP-XU6AWMMJYOZOFTFZ -m comment --comment \"pod1_ns1 hostport 8083\" -m sctp -p sctp -j DNAT --to-destination 10.1.1.2:83": true,
|
"-A KUBE-HP-XU6AWMMJYOZOFTFZ -m comment --comment \"pod1_ns1 hostport 8083\" -m sctp -p sctp -j DNAT --to-destination 10.1.1.2:83": true,
|
||||||
"-A KUBE-HP-WFBOALXEP42XEMJK -m comment --comment \"pod3_ns1 hostport 8443\" -s 10.1.1.4/32 -j KUBE-MARK-MASQ": true,
|
"-A KUBE-HP-WFBOALXEP42XEMJK -m comment --comment \"pod3_ns1 hostport 8443\" -s 10.1.1.4/32 -j KUBE-MARK-MASQ": true,
|
||||||
"-A KUBE-HP-WFBOALXEP42XEMJK -m comment --comment \"pod3_ns1 hostport 8443\" -m tcp -p tcp -j DNAT --to-destination 10.1.1.4:443": true,
|
"-A KUBE-HP-WFBOALXEP42XEMJK -m comment --comment \"pod3_ns1 hostport 8443\" -m tcp -p tcp -j DNAT --to-destination 10.1.1.4:443": true,
|
||||||
`COMMIT`: true,
|
`COMMIT`: true,
|
||||||
}
|
}
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
|
@ -27,9 +27,9 @@ import (
|
|||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
|
"k8s.io/api/core/v1"
|
||||||
iptablesproxy "k8s.io/kubernetes/pkg/proxy/iptables"
|
iptablesproxy "k8s.io/kubernetes/pkg/proxy/iptables"
|
||||||
utiliptables "k8s.io/kubernetes/pkg/util/iptables"
|
utiliptables "k8s.io/kubernetes/pkg/util/iptables"
|
||||||
"k8s.io/api/core/v1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// HostportSyncer takes a list of PodPortMappings and implements hostport all at once
|
// HostportSyncer takes a list of PodPortMappings and implements hostport all at once
|
||||||
|
@ -161,8 +161,8 @@ func newFakeServiceInfo(service proxy.ServicePortName, ip net.IP, port int, prot
|
|||||||
|
|
||||||
func TestDeleteEndpointConnections(t *testing.T) {
|
func TestDeleteEndpointConnections(t *testing.T) {
|
||||||
const (
|
const (
|
||||||
UDP = v1.ProtocolUDP
|
UDP = v1.ProtocolUDP
|
||||||
TCP = v1.ProtocolTCP
|
TCP = v1.ProtocolTCP
|
||||||
SCTP = v1.ProtocolSCTP
|
SCTP = v1.ProtocolSCTP
|
||||||
)
|
)
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
@ -189,14 +189,14 @@ func TestDeleteEndpointConnections(t *testing.T) {
|
|||||||
svcPort: 80,
|
svcPort: 80,
|
||||||
protocol: TCP,
|
protocol: TCP,
|
||||||
endpoint: "10.240.0.4:80",
|
endpoint: "10.240.0.4:80",
|
||||||
},{
|
}, {
|
||||||
description: "V4 SCTP",
|
description: "V4 SCTP",
|
||||||
svcName: "v4-sctp",
|
svcName: "v4-sctp",
|
||||||
svcIP: "10.96.3.3",
|
svcIP: "10.96.3.3",
|
||||||
svcPort: 80,
|
svcPort: 80,
|
||||||
protocol: SCTP,
|
protocol: SCTP,
|
||||||
endpoint: "10.240.0.5:80",
|
endpoint: "10.240.0.5:80",
|
||||||
},{
|
}, {
|
||||||
description: "V4 UDP, nothing to delete, benign error",
|
description: "V4 UDP, nothing to delete, benign error",
|
||||||
svcName: "v4-udp-nothing-to-delete",
|
svcName: "v4-udp-nothing-to-delete",
|
||||||
svcIP: "10.96.1.1",
|
svcIP: "10.96.1.1",
|
||||||
|
@ -47,8 +47,6 @@ import (
|
|||||||
utilnet "k8s.io/kubernetes/pkg/util/net"
|
utilnet "k8s.io/kubernetes/pkg/util/net"
|
||||||
utilsysctl "k8s.io/kubernetes/pkg/util/sysctl"
|
utilsysctl "k8s.io/kubernetes/pkg/util/sysctl"
|
||||||
utilexec "k8s.io/utils/exec"
|
utilexec "k8s.io/utils/exec"
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -811,8 +809,8 @@ func (proxier *Proxier) syncProxyRules() {
|
|||||||
for _, externalIP := range svcInfo.ExternalIPs {
|
for _, externalIP := range svcInfo.ExternalIPs {
|
||||||
if local, err := utilproxy.IsLocalIP(externalIP); err != nil {
|
if local, err := utilproxy.IsLocalIP(externalIP); err != nil {
|
||||||
glog.Errorf("can't determine if IP is local, assuming not: %v", err)
|
glog.Errorf("can't determine if IP is local, assuming not: %v", err)
|
||||||
// We do not start listening on SCTP ports, according to our agreement in the
|
// We do not start listening on SCTP ports, according to our agreement in the
|
||||||
// SCTP support KEP
|
// SCTP support KEP
|
||||||
} else if local && (svcInfo.GetProtocol() != v1.ProtocolSCTP) {
|
} else if local && (svcInfo.GetProtocol() != v1.ProtocolSCTP) {
|
||||||
lp := utilproxy.LocalPort{
|
lp := utilproxy.LocalPort{
|
||||||
Description: "externalIP for " + svcNameString,
|
Description: "externalIP for " + svcNameString,
|
||||||
@ -1012,8 +1010,8 @@ func (proxier *Proxier) syncProxyRules() {
|
|||||||
if proxier.portsMap[lp] != nil {
|
if proxier.portsMap[lp] != nil {
|
||||||
glog.V(4).Infof("Port %s was open before and is still needed", lp.String())
|
glog.V(4).Infof("Port %s was open before and is still needed", lp.String())
|
||||||
replacementPortsMap[lp] = proxier.portsMap[lp]
|
replacementPortsMap[lp] = proxier.portsMap[lp]
|
||||||
// We do not start listening on SCTP ports, according to our agreement in the
|
// We do not start listening on SCTP ports, according to our agreement in the
|
||||||
// SCTP support KEP
|
// SCTP support KEP
|
||||||
} else if svcInfo.GetProtocol() != v1.ProtocolSCTP {
|
} else if svcInfo.GetProtocol() != v1.ProtocolSCTP {
|
||||||
socket, err := proxier.portMapper.OpenLocalPort(&lp)
|
socket, err := proxier.portMapper.OpenLocalPort(&lp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1425,11 +1425,11 @@ func TestValidateEntry(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{ // case[19]
|
{ // case[19]
|
||||||
entry: &Entry{
|
entry: &Entry{
|
||||||
SetType: HashIPPortIP,
|
SetType: HashIPPortIP,
|
||||||
IP: "10.20.30.40",
|
IP: "10.20.30.40",
|
||||||
Protocol: ProtocolSCTP,
|
Protocol: ProtocolSCTP,
|
||||||
Port: 8090,
|
Port: 8090,
|
||||||
IP2: "10.20.30.41",
|
IP2: "10.20.30.41",
|
||||||
},
|
},
|
||||||
set: &IPSet{
|
set: &IPSet{
|
||||||
Name: "sctp",
|
Name: "sctp",
|
||||||
|
@ -252,7 +252,7 @@ func stringToProtocol(protocol string) uint16 {
|
|||||||
return uint16(syscall.IPPROTO_TCP)
|
return uint16(syscall.IPPROTO_TCP)
|
||||||
case "udp":
|
case "udp":
|
||||||
return uint16(syscall.IPPROTO_UDP)
|
return uint16(syscall.IPPROTO_UDP)
|
||||||
case "sctp":
|
case "sctp":
|
||||||
return uint16(syscall.IPPROTO_SCTP)
|
return uint16(syscall.IPPROTO_SCTP)
|
||||||
}
|
}
|
||||||
return uint16(0)
|
return uint16(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user