From 8b22cb46969cce6a17a131fda4ceec54001c30f0 Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Fri, 19 Jan 2024 07:54:31 -0800 Subject: [PATCH 1/4] Revert "Make verify-typecheck.sh only check valid targets for a platform" This reverts commit e48aa093402173f03e4e912f1450ee42ea97787e. --- hack/verify-typecheck.sh | 25 +++---------------------- test/typecheck/main.go | 6 +----- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/hack/verify-typecheck.sh b/hack/verify-typecheck.sh index 3c6edea33e2..590a9e75ebd 100755 --- a/hack/verify-typecheck.sh +++ b/hack/verify-typecheck.sh @@ -28,32 +28,13 @@ kube::golang::verify_go_version cd "${KUBE_ROOT}" -ret=0 -TYPECHECK_SERIAL="${TYPECHECK_SERIAL:-false}" - -SERVER_PLATFORMS=$(echo "${KUBE_SUPPORTED_SERVER_PLATFORMS[@]}" | tr ' ' ',') -CLIENT_PLATFORMS=$(echo "${KUBE_SUPPORTED_CLIENT_PLATFORMS[@]}" | tr ' ' ',') -NODE_PLATFORMS=$(echo "${KUBE_SUPPORTED_NODE_PLATFORMS[@]}" | tr ' ' ',') -TEST_PLATFORMS=$(echo "${KUBE_SUPPORTED_TEST_PLATFORMS[@]}" | tr ' ' ',') - # As of June, 2020 the typecheck tool is written in terms of go/packages, but # that library doesn't work well with multiple modules. Until that is done, # force this tooling to run in a fake GOPATH. +ret=0 +TYPECHECK_SERIAL="${TYPECHECK_SERIAL:-false}" hack/run-in-gopath.sh \ - go run test/typecheck/main.go "$@" --serial="${TYPECHECK_SERIAL}" --platform "${SERVER_PLATFORMS}" "${KUBE_SERVER_TARGETS[@]}" \ - || ret=$? -hack/run-in-gopath.sh \ - go run test/typecheck/main.go "$@" --serial="${TYPECHECK_SERIAL}" --platform "${CLIENT_PLATFORMS}" "${KUBE_CLIENT_TARGETS[@]}" \ - || ret=$? -hack/run-in-gopath.sh \ - go run test/typecheck/main.go "$@" --serial="${TYPECHECK_SERIAL}" --platform "${NODE_PLATFORMS}" "${KUBE_NODE_TARGETS[@]}" \ - || ret=$? - -# $KUBE_TEST_TARGETS doesn't seem to work like the other TARGETS variables... -hack/run-in-gopath.sh \ - go run test/typecheck/main.go "$@" --serial="${TYPECHECK_SERIAL}" --platform "${TEST_PLATFORMS}" test/e2e \ - || ret=$? - + go run test/typecheck/main.go "$@" "--serial=$TYPECHECK_SERIAL" || ret=$? if [[ $ret -ne 0 ]]; then echo "!!! Type Check has failed. This may cause cross platform build failures." >&2 echo "!!! Please see https://git.k8s.io/kubernetes/test/typecheck for more information." >&2 diff --git a/test/typecheck/main.go b/test/typecheck/main.go index a2a91059557..eb213293cfd 100644 --- a/test/typecheck/main.go +++ b/test/typecheck/main.go @@ -294,11 +294,7 @@ func main() { }() f := false - if len(args) != 0 { - serialFprintf(os.Stdout, "type-checking %s against %s\n", plat, args) - } else { - serialFprintf(os.Stdout, "type-checking %s\n", plat) - } + serialFprintf(os.Stdout, "type-checking %s\n", plat) errors, err := c.verify(plat) if err != nil { serialFprintf(os.Stderr, "ERROR(%s): failed to verify: %v\n", plat, err) From d2c1a23a8ae035fc88d00ee5037d2e578c7c5a9f Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Fri, 19 Jan 2024 07:58:01 -0800 Subject: [PATCH 2/4] Add stub methods for kube-proxy on non-linux/windows --- cmd/kube-proxy/app/init_other.go | 34 +++++++++++++++++ cmd/kube-proxy/app/server_other.go | 60 ++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 cmd/kube-proxy/app/init_other.go create mode 100644 cmd/kube-proxy/app/server_other.go diff --git a/cmd/kube-proxy/app/init_other.go b/cmd/kube-proxy/app/init_other.go new file mode 100644 index 00000000000..a9fa789926c --- /dev/null +++ b/cmd/kube-proxy/app/init_other.go @@ -0,0 +1,34 @@ +//go:build !windows && !linux +// +build !windows,!linux + +/* +Copyright 2024 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package app + +import ( + "fmt" + "runtime" + + "github.com/spf13/pflag" +) + +func initForOS(windowsService bool) error { + return fmt.Errorf(runtime.GOOS + "/" + runtime.GOARCH + "is unsupported") +} + +func (o *Options) addOSFlags(fs *pflag.FlagSet) { +} diff --git a/cmd/kube-proxy/app/server_other.go b/cmd/kube-proxy/app/server_other.go new file mode 100644 index 00000000000..1603fc7866e --- /dev/null +++ b/cmd/kube-proxy/app/server_other.go @@ -0,0 +1,60 @@ +//go:build !windows && !linux +// +build !windows,!linux + +/* +Copyright 2024 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package app does all of the work necessary to configure and run a +// Kubernetes app process. +package app + +import ( + "fmt" + "runtime" + + "k8s.io/kubernetes/pkg/proxy" + proxyconfigapi "k8s.io/kubernetes/pkg/proxy/apis/config" +) + +// platformApplyDefaults is called after parsing command-line flags and/or reading the +// config file, to apply platform-specific default values to config. +func (o *Options) platformApplyDefaults(config *proxyconfigapi.KubeProxyConfiguration) { +} + +var unsupportedError = fmt.Errorf(runtime.GOOS + "/" + runtime.GOARCH + "is unsupported") + +// platformSetup is called after setting up the ProxyServer, but before creating the +// Proxier. It should fill in any platform-specific fields and perform other +// platform-specific setup. +func (s *ProxyServer) platformSetup() error { + return unsupportedError +} + +// platformCheckSupported is called immediately before creating the Proxier, to check +// what IP families are supported (and whether the configuration is usable at all). +func (s *ProxyServer) platformCheckSupported() (ipv4Supported, ipv6Supported, dualStackSupported bool, err error) { + return false, false, false, unsupportedError +} + +// createProxier creates the proxy.Provider +func (s *ProxyServer) createProxier(config *proxyconfigapi.KubeProxyConfiguration, dualStackMode, initOnly bool) (proxy.Provider, error) { + return nil, unsupportedError +} + +// platformCleanup removes stale kube-proxy rules that can be safely removed. +func platformCleanup(mode proxyconfigapi.ProxyMode, cleanupAndExit bool) error { + return unsupportedError +} From e92a4debcbd80f6e41ef4b3e53785272acc7f3cf Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Fri, 19 Jan 2024 10:13:26 -0800 Subject: [PATCH 3/4] Fix lint warning about unchecked error --- test/typecheck/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/typecheck/main.go b/test/typecheck/main.go index eb213293cfd..9cb1c17a9e1 100644 --- a/test/typecheck/main.go +++ b/test/typecheck/main.go @@ -241,10 +241,10 @@ func dedup(errors []packages.Error) []string { var outMu sync.Mutex -func serialFprintf(w io.Writer, format string, a ...interface{}) (n int, err error) { +func serialFprintf(w io.Writer, format string, a ...interface{}) { outMu.Lock() defer outMu.Unlock() - return fmt.Fprintf(w, format, a...) + _, _ = fmt.Fprintf(w, format, a...) } func main() { From 6a60a1ddaddb3a61fd9b3f27f4ac26accfb93728 Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Thu, 25 Jan 2024 23:15:49 -0500 Subject: [PATCH 4/4] Mark conntrack/fake as linux-only, add non-OS doc.go --- pkg/proxy/conntrack/doc.go | 17 +++++++++++++++++ pkg/proxy/conntrack/fake.go | 3 +++ 2 files changed, 20 insertions(+) create mode 100644 pkg/proxy/conntrack/doc.go diff --git a/pkg/proxy/conntrack/doc.go b/pkg/proxy/conntrack/doc.go new file mode 100644 index 00000000000..f93291b9b75 --- /dev/null +++ b/pkg/proxy/conntrack/doc.go @@ -0,0 +1,17 @@ +/* +Copyright 2024 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package conntrack diff --git a/pkg/proxy/conntrack/fake.go b/pkg/proxy/conntrack/fake.go index 6eb6d11c679..2bc1f2ce518 100644 --- a/pkg/proxy/conntrack/fake.go +++ b/pkg/proxy/conntrack/fake.go @@ -1,3 +1,6 @@ +//go:build linux +// +build linux + /* Copyright 2016 The Kubernetes Authors.