diff --git a/staging/src/k8s.io/legacy-cloud-providers/gce/gce_healthchecks.go b/staging/src/k8s.io/legacy-cloud-providers/gce/gce_healthchecks.go index f905a6e8afe..6409e4979e4 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/gce/gce_healthchecks.go +++ b/staging/src/k8s.io/legacy-cloud-providers/gce/gce_healthchecks.go @@ -20,8 +20,6 @@ limitations under the License. package gce import ( - "k8s.io/klog/v2" - computealpha "google.golang.org/api/compute/v0.alpha" computebeta "google.golang.org/api/compute/v0.beta" compute "google.golang.org/api/compute/v1" @@ -29,8 +27,6 @@ import ( "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud" "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter" "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta" - v1 "k8s.io/api/core/v1" - utilversion "k8s.io/apimachinery/pkg/util/version" ) const ( @@ -42,18 +38,6 @@ const ( lbNodesHealthCheckPort = 10256 ) -var ( - minNodesHealthCheckVersion *utilversion.Version -) - -func init() { - if v, err := utilversion.ParseGeneric("1.7.2"); err != nil { - klog.Fatalf("Failed to parse version for minNodesHealthCheckVersion: %v", err) - } else { - minNodesHealthCheckVersion = v - } -} - func newHealthcheckMetricContext(request string) *metricContext { return newHealthcheckMetricContextWithVersion(request, computeV1Version) } @@ -274,25 +258,3 @@ func GetNodesHealthCheckPort() int32 { func GetNodesHealthCheckPath() string { return nodesHealthCheckPath } - -// isAtLeastMinNodesHealthCheckVersion checks if a version is higher than -// `minNodesHealthCheckVersion`. -func isAtLeastMinNodesHealthCheckVersion(vstring string) bool { - version, err := utilversion.ParseGeneric(vstring) - if err != nil { - klog.Errorf("vstring (%s) is not a valid version string: %v", vstring, err) - return false - } - return version.AtLeast(minNodesHealthCheckVersion) -} - -// supportsNodesHealthCheck returns false if anyone of the nodes has version -// lower than `minNodesHealthCheckVersion`. -func supportsNodesHealthCheck(nodes []*v1.Node) bool { - for _, node := range nodes { - if !isAtLeastMinNodesHealthCheckVersion(node.Status.NodeInfo.KubeProxyVersion) { - return false - } - } - return true -} diff --git a/staging/src/k8s.io/legacy-cloud-providers/gce/gce_healthchecks_test.go b/staging/src/k8s.io/legacy-cloud-providers/gce/gce_healthchecks_test.go deleted file mode 100644 index a3b5cbe36e2..00000000000 --- a/staging/src/k8s.io/legacy-cloud-providers/gce/gce_healthchecks_test.go +++ /dev/null @@ -1,127 +0,0 @@ -//go:build !providerless -// +build !providerless - -/* -Copyright 2017 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 gce - -import ( - "testing" - - "k8s.io/api/core/v1" -) - -func TestIsAtLeastMinNodesHealthCheckVersion(t *testing.T) { - testCases := []struct { - version string - expect bool - }{ - {"v1.7.3", true}, - {"v1.7.2", true}, - {"v1.7.2-alpha.2.597+276d289b90d322", true}, - {"v1.6.0-beta.3.472+831q821c907t31a", false}, - {"v1.5.2", false}, - } - - for _, tc := range testCases { - if res := isAtLeastMinNodesHealthCheckVersion(tc.version); res != tc.expect { - t.Errorf("%v: want %v, got %v", tc.version, tc.expect, res) - } - } -} - -func TestSupportsNodesHealthCheck(t *testing.T) { - testCases := []struct { - desc string - nodes []*v1.Node - expect bool - }{ - { - "All nodes support nodes health check", - []*v1.Node{ - { - Status: v1.NodeStatus{ - NodeInfo: v1.NodeSystemInfo{ - KubeProxyVersion: "v1.7.2", - }, - }, - }, - { - Status: v1.NodeStatus{ - NodeInfo: v1.NodeSystemInfo{ - KubeProxyVersion: "v1.7.2-alpha.2.597+276d289b90d322", - }, - }, - }, - }, - true, - }, - { - "All nodes don't support nodes health check", - []*v1.Node{ - { - Status: v1.NodeStatus{ - NodeInfo: v1.NodeSystemInfo{ - KubeProxyVersion: "v1.6.0-beta.3.472+831q821c907t31a", - }, - }, - }, - { - Status: v1.NodeStatus{ - NodeInfo: v1.NodeSystemInfo{ - KubeProxyVersion: "v1.5.2", - }, - }, - }, - }, - false, - }, - { - "One node doesn't support nodes health check", - []*v1.Node{ - { - Status: v1.NodeStatus{ - NodeInfo: v1.NodeSystemInfo{ - KubeProxyVersion: "v1.7.3", - }, - }, - }, - { - Status: v1.NodeStatus{ - NodeInfo: v1.NodeSystemInfo{ - KubeProxyVersion: "v1.7.2-alpha.2.597+276d289b90d322", - }, - }, - }, - { - Status: v1.NodeStatus{ - NodeInfo: v1.NodeSystemInfo{ - KubeProxyVersion: "v1.5.2", - }, - }, - }, - }, - false, - }, - } - - for _, tc := range testCases { - if res := supportsNodesHealthCheck(tc.nodes); res != tc.expect { - t.Errorf("%v: want %v, got %v", tc.desc, tc.expect, res) - } - } -} diff --git a/staging/src/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_external.go b/staging/src/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_external.go index b95ad4166c0..b4f451cbd7b 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_external.go +++ b/staging/src/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_external.go @@ -63,7 +63,6 @@ func (g *Cloud) ensureExternalLoadBalancer(clusterName string, clusterID string, } hostNames := nodeNames(nodes) - supportsNodesHealthCheck := supportsNodesHealthCheck(nodes) hosts, err := g.getInstancesByNames(hostNames) if err != nil { return nil, err @@ -229,9 +228,7 @@ func (g *Cloud) ensureExternalLoadBalancer(clusterName string, clusterID string, // turn on the tpNeedsRecreation flag to delete/recreate fwdrule/tpool updating the // target pool to use local traffic health check. klog.V(2).Infof("ensureExternalLoadBalancer(%s): Updating from nodes health checks to local traffic health checks.", lbRefStr) - if supportsNodesHealthCheck { - hcToDelete = makeHTTPHealthCheck(MakeNodesHealthCheckName(clusterID), GetNodesHealthCheckPath(), GetNodesHealthCheckPort()) - } + hcToDelete = makeHTTPHealthCheck(MakeNodesHealthCheckName(clusterID), GetNodesHealthCheckPath(), GetNodesHealthCheckPort()) tpNeedsRecreation = true } hcToCreate = makeHTTPHealthCheck(loadBalancerName, path, healthCheckNodePort) @@ -245,9 +242,7 @@ func (g *Cloud) ensureExternalLoadBalancer(clusterName string, clusterID string, hcToDelete = hcLocalTrafficExisting tpNeedsRecreation = true } - if supportsNodesHealthCheck { - hcToCreate = makeHTTPHealthCheck(MakeNodesHealthCheckName(clusterID), GetNodesHealthCheckPath(), GetNodesHealthCheckPort()) - } + hcToCreate = makeHTTPHealthCheck(MakeNodesHealthCheckName(clusterID), GetNodesHealthCheckPath(), GetNodesHealthCheckPort()) } // Now we get to some slightly more interesting logic. // First, neither target pools nor forwarding rules can be updated in place - diff --git a/staging/src/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_utils_test.go b/staging/src/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_utils_test.go index 3871eeb5fb1..35f9eae8de8 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_utils_test.go +++ b/staging/src/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_utils_test.go @@ -114,11 +114,6 @@ func createAndInsertNodes(gce *Cloud, nodeNames []string, zoneName string) ([]*v v1.LabelFailureDomainBetaZone: zoneName, }, }, - Status: v1.NodeStatus{ - NodeInfo: v1.NodeSystemInfo{ - KubeProxyVersion: "v1.7.2", - }, - }, }, )