Skip to content

Commit 029b2d2

Browse files
author
Kenichi Omichi
committed
Remove DeprecatedMightBeMasterNode()
This removes DeprecatedGetMasterAndWorkerNodes() usage from vsphere e2e test as deprecated function cleanup. Then all callers of DeprecatedMightBeMasterNode() have been removed. So this removes DeprecatedMightBeMasterNode() itself also.
1 parent c9c5c23 commit 029b2d2

File tree

6 files changed

+27
-136
lines changed

6 files changed

+27
-136
lines changed

test/e2e/framework/node/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ go_library(
2424
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
2525
"//staging/src/k8s.io/client-go/util/retry:go_default_library",
2626
"//test/e2e/framework/log:go_default_library",
27-
"//test/e2e/system:go_default_library",
2827
"//test/utils:go_default_library",
2928
"//test/utils/image:go_default_library",
3029
"//vendor/github.com/onsi/ginkgo:go_default_library",

test/e2e/framework/node/resource.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ import (
4141
clientset "k8s.io/client-go/kubernetes"
4242
clientretry "k8s.io/client-go/util/retry"
4343
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
44-
45-
// TODO remove the direct dependency for internal k8s.io/kubernetes
46-
"k8s.io/kubernetes/test/e2e/system"
4744
)
4845

4946
const (
@@ -363,25 +360,6 @@ func GetReadyNodesIncludingTainted(c clientset.Interface) (nodes *v1.NodeList, e
363360
return nodes, nil
364361
}
365362

366-
// DeprecatedGetMasterAndWorkerNodes will return a list masters and schedulable worker nodes
367-
// NOTE: This function has been deprecated because of calling DeprecatedMightBeMasterNode().
368-
func DeprecatedGetMasterAndWorkerNodes(c clientset.Interface) (sets.String, *v1.NodeList, error) {
369-
nodes := &v1.NodeList{}
370-
masters := sets.NewString()
371-
all, err := c.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})
372-
if err != nil {
373-
return nil, nil, fmt.Errorf("get nodes error: %s", err)
374-
}
375-
for _, n := range all.Items {
376-
if system.DeprecatedMightBeMasterNode(n.Name) {
377-
masters.Insert(n.Name)
378-
} else if isNodeSchedulableWithoutTaints(&n) {
379-
nodes.Items = append(nodes.Items, n)
380-
}
381-
}
382-
return masters, nodes, nil
383-
}
384-
385363
// isNodeUntainted tests whether a fake pod can be scheduled on "node", given its current taints.
386364
// TODO: need to discuss wether to return bool and error type
387365
func isNodeUntainted(node *v1.Node) bool {

test/e2e/storage/vsphere/vsphere_volume_vsan_policy.go

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"fmt"
2222
"hash/fnv"
23+
"regexp"
2324
"time"
2425

2526
"strings"
@@ -81,7 +82,6 @@ var _ = utils.SIGDescribe("Storage Policy Based Volume Provisioning [Feature:vsp
8182
scParameters map[string]string
8283
policyName string
8384
tagPolicy string
84-
masterNode string
8585
)
8686
ginkgo.BeforeEach(func() {
8787
e2eskipper.SkipUnlessProviderIs("vsphere")
@@ -94,10 +94,6 @@ var _ = utils.SIGDescribe("Storage Policy Based Volume Provisioning [Feature:vsp
9494
scParameters = make(map[string]string)
9595
_, err := e2enode.GetRandomReadySchedulableNode(f.ClientSet)
9696
framework.ExpectNoError(err)
97-
masternodes, _, err := e2enode.DeprecatedGetMasterAndWorkerNodes(client)
98-
framework.ExpectNoError(err)
99-
gomega.Expect(masternodes).NotTo(gomega.BeEmpty())
100-
masterNode = masternodes.List()[0]
10197
})
10298

10399
// Valid policy.
@@ -211,7 +207,9 @@ var _ = utils.SIGDescribe("Storage Policy Based Volume Provisioning [Feature:vsp
211207
scParameters[Datastore] = vsanDatastore
212208
framework.Logf("Invoking test for SPBM storage policy: %+v", scParameters)
213209
kubernetesClusterName := GetAndExpectStringEnvVar(KubernetesClusterName)
214-
invokeStaleDummyVMTestWithStoragePolicy(client, masterNode, namespace, kubernetesClusterName, scParameters)
210+
controlPlaneNode, err := getControlPlaneNode(client)
211+
framework.ExpectNoError(err)
212+
invokeStaleDummyVMTestWithStoragePolicy(client, controlPlaneNode, namespace, kubernetesClusterName, scParameters)
215213
})
216214

217215
ginkgo.It("verify if a SPBM policy is not honored on a non-compatible datastore for dynamically provisioned pvc using storageclass", func() {
@@ -309,7 +307,9 @@ func invokeInvalidPolicyTestNeg(client clientset.Interface, namespace string, sc
309307
return fmt.Errorf("Failure message: %+q", eventList.Items[0].Message)
310308
}
311309

312-
func invokeStaleDummyVMTestWithStoragePolicy(client clientset.Interface, masterNode string, namespace string, clusterName string, scParameters map[string]string) {
310+
// invokeStaleDummyVMTestWithStoragePolicy assumes control plane node is present on the datacenter specified in the workspace section of vsphere.conf file.
311+
// With in-tree VCP, when the volume is created using storage policy, shadow (dummy) VM is getting created and deleted to apply SPBM policy on the volume.
312+
func invokeStaleDummyVMTestWithStoragePolicy(client clientset.Interface, controlPlaneNode string, namespace string, clusterName string, scParameters map[string]string) {
313313
ginkgo.By("Creating Storage Class With storage policy params")
314314
storageclass, err := client.StorageV1().StorageClasses().Create(context.TODO(), getVSphereStorageClassSpec("storagepolicysc", scParameters, nil, ""), metav1.CreateOptions{})
315315
framework.ExpectNoError(err, fmt.Sprintf("Failed to create storage class with err: %v", err))
@@ -336,8 +336,27 @@ func invokeStaleDummyVMTestWithStoragePolicy(client clientset.Interface, masterN
336336
fnvHash.Write([]byte(vmName))
337337
dummyVMFullName := dummyVMPrefixName + "-" + fmt.Sprint(fnvHash.Sum32())
338338
errorMsg := "Dummy VM - " + vmName + " is still present. Failing the test.."
339-
nodeInfo := TestContext.NodeMapper.GetNodeInfo(masterNode)
339+
nodeInfo := TestContext.NodeMapper.GetNodeInfo(controlPlaneNode)
340340
isVMPresentFlag, err := nodeInfo.VSphere.IsVMPresent(dummyVMFullName, nodeInfo.DataCenterRef)
341341
framework.ExpectNoError(err)
342342
framework.ExpectEqual(isVMPresentFlag, false, errorMsg)
343343
}
344+
345+
func getControlPlaneNode(client clientset.Interface) (string, error) {
346+
regKubeScheduler := regexp.MustCompile("kube-scheduler-.*")
347+
regKubeControllerManager := regexp.MustCompile("kube-controller-manager-.*")
348+
349+
podList, err := client.CoreV1().Pods(metav1.NamespaceSystem).List(context.TODO(), metav1.ListOptions{})
350+
if err != nil {
351+
return "", err
352+
}
353+
if len(podList.Items) < 1 {
354+
return "", fmt.Errorf("could not find any pods in namespace %s to grab metrics from", metav1.NamespaceSystem)
355+
}
356+
for _, pod := range podList.Items {
357+
if regKubeScheduler.MatchString(pod.Name) || regKubeControllerManager.MatchString(pod.Name) {
358+
return pod.Spec.NodeName, nil
359+
}
360+
}
361+
return "", fmt.Errorf("could not find any nodes where control plane pods are running")
362+
}

test/e2e/system/BUILD

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
2-
3-
go_library(
4-
name = "go_default_library",
5-
srcs = ["system_utils.go"],
6-
importpath = "k8s.io/kubernetes/test/e2e/system",
7-
visibility = ["//visibility:public"],
8-
)
9-
10-
go_test(
11-
name = "go_default_test",
12-
srcs = ["system_utils_test.go"],
13-
embed = [":go_default_library"],
14-
deps = [
15-
"//staging/src/k8s.io/api/core/v1:go_default_library",
16-
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
17-
],
18-
)
19-
201
filegroup(
212
name = "package-srcs",
223
srcs = glob(["**"]),

test/e2e/system/system_utils.go

Lines changed: 0 additions & 39 deletions
This file was deleted.

test/e2e/system/system_utils_test.go

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)