From 74055d74ce20f3cb70acfe47c4201b3040b653be Mon Sep 17 00:00:00 2001 From: Quan Tian Date: Thu, 6 Aug 2020 13:56:06 +0800 Subject: [PATCH] Enable linter goimports to tidy imports (#1037) goimports makes imports deterministic, putting them in 3 sections: builtin, 3rd-party, local packages. It saves reviewers's effort to comment the order of imports. It doesn't allow imports named "v1" unless the alias name is specified as "v1", this patch adds the parent packages of v1 packages as the prefix of the import names. --- .golangci.yml | 5 ++ cmd/antrea-cni/main.go | 8 +- pkg/agent/cniserver/ipam/ipam_service.go | 1 + .../noderoute/node_route_controller.go | 18 ++-- .../traceflow/traceflow_controller.go | 6 +- .../certificate/cacert_controller.go | 10 +-- .../networkpolicy/addressgroup/rest.go | 6 +- .../networkpolicy/appliedtogroup/rest.go | 6 +- .../networkpolicy/networkpolicy/rest.go | 6 +- .../registry/system/controllerinfo/rest.go | 6 +- .../networkpolicy_controller_perf_test.go | 32 +++---- pkg/controller/traceflow/controller.go | 8 +- pkg/monitor/controller.go | 6 +- test/e2e/connectivity_test.go | 6 +- test/e2e/framework.go | 86 +++++++++---------- test/e2e/performance_test.go | 3 +- test/e2e/providers/kind.go | 3 +- test/e2e/proxy_test.go | 6 +- test/e2e/reachability.go | 3 +- test/e2e/traceflow_test.go | 7 +- test/e2e/utils/cnpspecbuilder.go | 1 - test/e2e/utils/networkpolicyspecbuilder.go | 1 - 22 files changed, 119 insertions(+), 115 deletions(-) mode change 100755 => 100644 test/e2e/connectivity_test.go diff --git a/.golangci.yml b/.golangci.yml index cf95d9b7257..5599a87c6d1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -6,6 +6,10 @@ run: - ".*\\.pb\\.go" skip-dirs-use-default: true +linters-settings: + goimports: + local-prefixes: github.com/vmware-tanzu/antrea + linters: disable-all: true enable: @@ -14,3 +18,4 @@ linters: - deadcode - staticcheck - gosec + - goimports diff --git a/cmd/antrea-cni/main.go b/cmd/antrea-cni/main.go index 1186acad597..416c9cb910e 100644 --- a/cmd/antrea-cni/main.go +++ b/cmd/antrea-cni/main.go @@ -17,12 +17,12 @@ package main import ( "fmt" + "github.com/containernetworking/cni/pkg/skel" + cniversion "github.com/containernetworking/cni/pkg/version" + "github.com/vmware-tanzu/antrea/pkg/cni" "github.com/vmware-tanzu/antrea/pkg/log" "github.com/vmware-tanzu/antrea/pkg/version" - - "github.com/containernetworking/cni/pkg/skel" - cni_version "github.com/containernetworking/cni/pkg/version" ) func init() { @@ -34,7 +34,7 @@ func main() { cni.ActionAdd.Request, cni.ActionCheck.Request, cni.ActionDel.Request, - cni_version.All, + cniversion.All, fmt.Sprintf("Antrea CNI %s", version.GetFullVersionWithRuntimeInfo()), ) } diff --git a/pkg/agent/cniserver/ipam/ipam_service.go b/pkg/agent/cniserver/ipam/ipam_service.go index 1198a49002a..b5e07c6cd93 100644 --- a/pkg/agent/cniserver/ipam/ipam_service.go +++ b/pkg/agent/cniserver/ipam/ipam_service.go @@ -20,6 +20,7 @@ import ( "github.com/containernetworking/cni/pkg/invoke" "github.com/containernetworking/cni/pkg/types/current" + cnipb "github.com/vmware-tanzu/antrea/pkg/apis/cni/v1beta1" ) diff --git a/pkg/agent/controller/noderoute/node_route_controller.go b/pkg/agent/controller/noderoute/node_route_controller.go index 9e59b1cddbf..d1f2fe579d8 100644 --- a/pkg/agent/controller/noderoute/node_route_controller.go +++ b/pkg/agent/controller/noderoute/node_route_controller.go @@ -21,7 +21,7 @@ import ( "time" "github.com/containernetworking/plugins/pkg/ip" - "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/informers" @@ -115,16 +115,16 @@ func NewNodeRouteController( } // enqueueNode adds an object to the controller work queue -// obj could be an *v1.Node, or a DeletionFinalStateUnknown item. +// obj could be an *corev1.Node, or a DeletionFinalStateUnknown item. func (c *Controller) enqueueNode(obj interface{}) { - node, isNode := obj.(*v1.Node) + node, isNode := obj.(*corev1.Node) if !isNode { deletedState, ok := obj.(cache.DeletedFinalStateUnknown) if !ok { klog.Errorf("Received unexpected object: %v", obj) return } - node, ok = deletedState.Obj.(*v1.Node) + node, ok = deletedState.Obj.(*corev1.Node) if !ok { klog.Errorf("DeletedFinalStateUnknown contains non-Node object: %v", deletedState.Obj) return @@ -384,7 +384,7 @@ func (c *Controller) deleteNodeRoute(nodeName string) error { return nil } -func (c *Controller) addNodeRoute(nodeName string, node *v1.Node) error { +func (c *Controller) addNodeRoute(nodeName string, node *corev1.Node) error { if _, installed := c.installedNodes.Load(nodeName); installed { // Route is already added for this Node. return nil @@ -523,15 +523,15 @@ func ParseTunnelInterfaceConfig( // GetNodeAddr gets the available IP address of a Node. GetNodeAddr will first try to get the // NodeInternalIP, then try to get the NodeExternalIP. -func GetNodeAddr(node *v1.Node) (net.IP, error) { - addresses := make(map[v1.NodeAddressType]string) +func GetNodeAddr(node *corev1.Node) (net.IP, error) { + addresses := make(map[corev1.NodeAddressType]string) for _, addr := range node.Status.Addresses { addresses[addr.Type] = addr.Address } var ipAddrStr string - if internalIP, ok := addresses[v1.NodeInternalIP]; ok { + if internalIP, ok := addresses[corev1.NodeInternalIP]; ok { ipAddrStr = internalIP - } else if externalIP, ok := addresses[v1.NodeExternalIP]; ok { + } else if externalIP, ok := addresses[corev1.NodeExternalIP]; ok { ipAddrStr = externalIP } else { return nil, fmt.Errorf("node %s has neither external ip nor internal ip", node.Name) diff --git a/pkg/agent/controller/traceflow/traceflow_controller.go b/pkg/agent/controller/traceflow/traceflow_controller.go index 1166c2c0782..cf0ecd037a2 100644 --- a/pkg/agent/controller/traceflow/traceflow_controller.go +++ b/pkg/agent/controller/traceflow/traceflow_controller.go @@ -23,7 +23,7 @@ import ( "sync" "time" - "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" clientset "k8s.io/client-go/kubernetes" @@ -291,7 +291,7 @@ func (c *Controller) injectPacket(tf *opsv1alpha1.Traceflow) error { dstMAC = dstPodInterfaces[0].MAC.String() dstIP = dstPodInterfaces[0].IP.String() } else { - dstPod, err := c.kubeClient.CoreV1().Pods(tf.Spec.Destination.Namespace).Get(context.TODO(), tf.Spec.Destination.Pod, v1.GetOptions{}) + dstPod, err := c.kubeClient.CoreV1().Pods(tf.Spec.Destination.Namespace).Get(context.TODO(), tf.Spec.Destination.Pod, metav1.GetOptions{}) if err != nil { return err } @@ -367,7 +367,7 @@ func (c *Controller) errorTraceflowCRD(tf *opsv1alpha1.Traceflow, reason string) } patchData := Traceflow{Status: opsv1alpha1.TraceflowStatus{Phase: tf.Status.Phase, Reason: reason}} payloads, _ := json.Marshal(patchData) - return c.traceflowClient.OpsV1alpha1().Traceflows().Patch(context.TODO(), tf.Name, types.MergePatchType, payloads, v1.PatchOptions{}, "status") + return c.traceflowClient.OpsV1alpha1().Traceflows().Patch(context.TODO(), tf.Name, types.MergePatchType, payloads, metav1.PatchOptions{}, "status") } // Deallocate tag from cache. Ignore DataplaneTag == 0 which is invalid case. diff --git a/pkg/apiserver/certificate/cacert_controller.go b/pkg/apiserver/certificate/cacert_controller.go index e2737fe7f9f..6f54a4eb93e 100644 --- a/pkg/apiserver/certificate/cacert_controller.go +++ b/pkg/apiserver/certificate/cacert_controller.go @@ -20,7 +20,7 @@ import ( "fmt" "time" - "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/apiserver/pkg/server/dynamiccertificates" "k8s.io/client-go/kubernetes" @@ -109,7 +109,7 @@ func (c *CACertController) syncCACert() error { func (c *CACertController) syncAPIServices(caCert []byte) error { klog.Info("Syncing CA certificate with APIServices") for _, name := range apiServiceNames { - apiService, err := c.aggregatorClient.ApiregistrationV1().APIServices().Get(context.TODO(), name, v1.GetOptions{}) + apiService, err := c.aggregatorClient.ApiregistrationV1().APIServices().Get(context.TODO(), name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("error getting APIService %s: %v", name, err) } @@ -117,7 +117,7 @@ func (c *CACertController) syncAPIServices(caCert []byte) error { continue } apiService.Spec.CABundle = caCert - if _, err := c.aggregatorClient.ApiregistrationV1().APIServices().Update(context.TODO(), apiService, v1.UpdateOptions{}); err != nil { + if _, err := c.aggregatorClient.ApiregistrationV1().APIServices().Update(context.TODO(), apiService, metav1.UpdateOptions{}); err != nil { return fmt.Errorf("error updating antrea CA cert of APIService %s: %v", name, err) } } @@ -129,7 +129,7 @@ func (c *CACertController) syncConfigMap(caCert []byte) error { klog.Info("Syncing CA certificate with ConfigMap") // Use the Antrea Pod Namespace for the CA cert ConfigMap. caConfigMapNamespace := GetCAConfigMapNamespace() - caConfigMap, err := c.client.CoreV1().ConfigMaps(caConfigMapNamespace).Get(context.TODO(), CAConfigMapName, v1.GetOptions{}) + caConfigMap, err := c.client.CoreV1().ConfigMaps(caConfigMapNamespace).Get(context.TODO(), CAConfigMapName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("error getting ConfigMap %s: %v", CAConfigMapName, err) } @@ -139,7 +139,7 @@ func (c *CACertController) syncConfigMap(caCert []byte) error { caConfigMap.Data = map[string]string{ CAConfigMapKey: string(caCert), } - if _, err := c.client.CoreV1().ConfigMaps(caConfigMapNamespace).Update(context.TODO(), caConfigMap, v1.UpdateOptions{}); err != nil { + if _, err := c.client.CoreV1().ConfigMaps(caConfigMapNamespace).Update(context.TODO(), caConfigMap, metav1.UpdateOptions{}); err != nil { return fmt.Errorf("error updating ConfigMap %s: %v", CAConfigMapName, err) } return nil diff --git a/pkg/apiserver/registry/networkpolicy/addressgroup/rest.go b/pkg/apiserver/registry/networkpolicy/addressgroup/rest.go index 8cc11386a6d..e9b2abb0174 100644 --- a/pkg/apiserver/registry/networkpolicy/addressgroup/rest.go +++ b/pkg/apiserver/registry/networkpolicy/addressgroup/rest.go @@ -19,7 +19,7 @@ import ( "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/apis/meta/internalversion" - "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/apiserver/pkg/registry/rest" @@ -57,7 +57,7 @@ func (r *REST) NewList() runtime.Object { return &networking.AddressGroupList{} } -func (r *REST) Get(ctx context.Context, name string, options *v1.GetOptions) (runtime.Object, error) { +func (r *REST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { addressGroup, exists, err := r.addressGroupStore.Get(name) if err != nil { return nil, errors.NewInternalError(err) @@ -89,6 +89,6 @@ func (r *REST) Watch(ctx context.Context, options *internalversion.ListOptions) return r.addressGroupStore.Watch(ctx, key, label, field) } -func (r *REST) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*v1.Table, error) { +func (r *REST) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { return rest.NewDefaultTableConvertor(networking.Resource("addressgroup")).ConvertToTable(ctx, obj, tableOptions) } diff --git a/pkg/apiserver/registry/networkpolicy/appliedtogroup/rest.go b/pkg/apiserver/registry/networkpolicy/appliedtogroup/rest.go index cfe5d80b997..4c306198646 100644 --- a/pkg/apiserver/registry/networkpolicy/appliedtogroup/rest.go +++ b/pkg/apiserver/registry/networkpolicy/appliedtogroup/rest.go @@ -19,7 +19,7 @@ import ( "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/apis/meta/internalversion" - "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/apiserver/pkg/registry/rest" @@ -57,7 +57,7 @@ func (r *REST) NewList() runtime.Object { return &networking.AppliedToGroupList{} } -func (r *REST) Get(ctx context.Context, name string, options *v1.GetOptions) (runtime.Object, error) { +func (r *REST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { appliedToGroup, exists, err := r.appliedToGroupStore.Get(name) if err != nil { return nil, errors.NewInternalError(err) @@ -89,6 +89,6 @@ func (r *REST) Watch(ctx context.Context, options *internalversion.ListOptions) return r.appliedToGroupStore.Watch(ctx, key, label, field) } -func (r *REST) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*v1.Table, error) { +func (r *REST) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { return rest.NewDefaultTableConvertor(networking.Resource("appliedtogroup")).ConvertToTable(ctx, obj, tableOptions) } diff --git a/pkg/apiserver/registry/networkpolicy/networkpolicy/rest.go b/pkg/apiserver/registry/networkpolicy/networkpolicy/rest.go index 94e49df42e4..3c377cae899 100644 --- a/pkg/apiserver/registry/networkpolicy/networkpolicy/rest.go +++ b/pkg/apiserver/registry/networkpolicy/networkpolicy/rest.go @@ -19,7 +19,7 @@ import ( "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/apis/meta/internalversion" - "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/apiserver/pkg/endpoints/request" @@ -59,7 +59,7 @@ func (r *REST) NewList() runtime.Object { return &networking.NetworkPolicyList{} } -func (r *REST) Get(ctx context.Context, name string, options *v1.GetOptions) (runtime.Object, error) { +func (r *REST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { ns, ok := request.NamespaceFrom(ctx) if !ok || len(ns) == 0 { return nil, errors.NewBadRequest("Namespace parameter required.") @@ -107,6 +107,6 @@ func (r *REST) Watch(ctx context.Context, options *internalversion.ListOptions) return r.networkPolicyStore.Watch(ctx, key, label, field) } -func (r *REST) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*v1.Table, error) { +func (r *REST) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { return rest.NewDefaultTableConvertor(networking.Resource("networkpolicy")).ConvertToTable(ctx, obj, tableOptions) } diff --git a/pkg/apiserver/registry/system/controllerinfo/rest.go b/pkg/apiserver/registry/system/controllerinfo/rest.go index db6eff848ba..438f5ed5f30 100644 --- a/pkg/apiserver/registry/system/controllerinfo/rest.go +++ b/pkg/apiserver/registry/system/controllerinfo/rest.go @@ -19,7 +19,7 @@ import ( "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/apis/meta/internalversion" - "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apiserver/pkg/registry/rest" @@ -59,7 +59,7 @@ func (r *REST) getControllerInfo() *clusterinfo.AntreaControllerInfo { return info } -func (r *REST) Get(ctx context.Context, name string, options *v1.GetOptions) (runtime.Object, error) { +func (r *REST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { info := r.getControllerInfo() // The provided name should match the AntreaControllerInfo.Name. if info.Name != name { @@ -82,6 +82,6 @@ func (r *REST) NamespaceScoped() bool { return false } -func (r *REST) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*v1.Table, error) { +func (r *REST) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { return rest.NewDefaultTableConvertor(system.Resource("clusterinfos")).ConvertToTable(ctx, obj, tableOptions) } diff --git a/pkg/controller/networkpolicy/networkpolicy_controller_perf_test.go b/pkg/controller/networkpolicy/networkpolicy_controller_perf_test.go index c30eb0501b9..660cef900f3 100644 --- a/pkg/controller/networkpolicy/networkpolicy_controller_perf_test.go +++ b/pkg/controller/networkpolicy/networkpolicy_controller_perf_test.go @@ -25,7 +25,7 @@ import ( "time" "github.com/google/uuid" - "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" networkingv1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" @@ -47,9 +47,9 @@ NAMESPACES PODS NETWORK-POLICIES TIME(s) MEMORY(M) EXECUTIONS E The metrics are not accurate under the race detector, and will be skipped when testing with "-race". */ func TestInitXLargeScaleWithSmallNamespaces(t *testing.T) { - getObjects := func() ([]*v1.Namespace, []*networkingv1.NetworkPolicy, []*v1.Pod) { + getObjects := func() ([]*corev1.Namespace, []*networkingv1.NetworkPolicy, []*corev1.Pod) { namespace := rand.String(8) - namespaces := []*v1.Namespace{ + namespaces := []*corev1.Namespace{ { ObjectMeta: metav1.ObjectMeta{Name: namespace, Labels: map[string]string{"app": namespace}}, }, @@ -99,26 +99,26 @@ func TestInitXLargeScaleWithSmallNamespaces(t *testing.T) { }, }, } - pods := []*v1.Pod{ + pods := []*corev1.Pod{ { ObjectMeta: metav1.ObjectMeta{Namespace: namespace, Name: "pod1", UID: types.UID(uuid.New().String()), Labels: map[string]string{"app-1": "scale-1"}}, - Spec: v1.PodSpec{NodeName: getRandomNodeName()}, - Status: v1.PodStatus{PodIP: getRandomIP()}, + Spec: corev1.PodSpec{NodeName: getRandomNodeName()}, + Status: corev1.PodStatus{PodIP: getRandomIP()}, }, { ObjectMeta: metav1.ObjectMeta{Namespace: namespace, Name: "pod2", UID: types.UID(uuid.New().String()), Labels: map[string]string{"app-1": "scale-1"}}, - Spec: v1.PodSpec{NodeName: getRandomNodeName()}, - Status: v1.PodStatus{PodIP: getRandomIP()}, + Spec: corev1.PodSpec{NodeName: getRandomNodeName()}, + Status: corev1.PodStatus{PodIP: getRandomIP()}, }, { ObjectMeta: metav1.ObjectMeta{Namespace: namespace, Name: "pod3", UID: types.UID(uuid.New().String()), Labels: map[string]string{"app-2": "scale-2"}}, - Spec: v1.PodSpec{NodeName: getRandomNodeName()}, - Status: v1.PodStatus{PodIP: getRandomIP()}, + Spec: corev1.PodSpec{NodeName: getRandomNodeName()}, + Status: corev1.PodStatus{PodIP: getRandomIP()}, }, { ObjectMeta: metav1.ObjectMeta{Namespace: namespace, Name: "pod4", UID: types.UID(uuid.New().String()), Labels: map[string]string{"app-2": "scale-2"}}, - Spec: v1.PodSpec{NodeName: getRandomNodeName()}, - Status: v1.PodStatus{PodIP: getRandomIP()}, + Spec: corev1.PodSpec{NodeName: getRandomNodeName()}, + Status: corev1.PodStatus{PodIP: getRandomIP()}, }, } return namespaces, networkPolicies, pods @@ -127,7 +127,7 @@ func TestInitXLargeScaleWithSmallNamespaces(t *testing.T) { testComputeNetworkPolicy(t, 10*time.Second, namespaces, networkPolicies, pods) } -func testComputeNetworkPolicy(t *testing.T, maxExecutionTime time.Duration, namespaces []*v1.Namespace, networkPolicies []*networkingv1.NetworkPolicy, pods []*v1.Pod) { +func testComputeNetworkPolicy(t *testing.T, maxExecutionTime time.Duration, namespaces []*corev1.Namespace, networkPolicies []*networkingv1.NetworkPolicy, pods []*corev1.Pod) { objs := make([]runtime.Object, 0, len(namespaces)+len(networkPolicies)+len(pods)) for i := range namespaces { objs = append(objs, namespaces[i]) @@ -264,10 +264,10 @@ func getRandomNodeName() string { } // getXObjects calls the provided getObjectsFunc x times and aggregate the objects. -func getXObjects(x int, getObjectsFunc func() ([]*v1.Namespace, []*networkingv1.NetworkPolicy, []*v1.Pod)) ([]*v1.Namespace, []*networkingv1.NetworkPolicy, []*v1.Pod) { - var namespaces []*v1.Namespace +func getXObjects(x int, getObjectsFunc func() ([]*corev1.Namespace, []*networkingv1.NetworkPolicy, []*corev1.Pod)) ([]*corev1.Namespace, []*networkingv1.NetworkPolicy, []*corev1.Pod) { + var namespaces []*corev1.Namespace var networkPolicies []*networkingv1.NetworkPolicy - var pods []*v1.Pod + var pods []*corev1.Pod for i := 0; i < x; i++ { newNamespaces, newNetworkPolicies, newPods := getObjectsFunc() namespaces = append(namespaces, newNamespaces...) diff --git a/pkg/controller/traceflow/controller.go b/pkg/controller/traceflow/controller.go index b098b655776..462a200b54a 100644 --- a/pkg/controller/traceflow/controller.go +++ b/pkg/controller/traceflow/controller.go @@ -21,7 +21,7 @@ import ( "sync" "time" - "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" @@ -236,7 +236,7 @@ func (c *Controller) checkTraceflowStatus(tf *opsv1alpha1.Traceflow) (retry bool } if sender && receiver { tf.Status.Phase = opsv1alpha1.Succeeded - _, err = c.client.OpsV1alpha1().Traceflows().UpdateStatus(context.TODO(), tf, v1.UpdateOptions{}) + _, err = c.client.OpsV1alpha1().Traceflows().UpdateStatus(context.TODO(), tf, metav1.UpdateOptions{}) return } if time.Now().UTC().Sub(tf.CreationTimestamp.UTC()).Seconds() > timeout { @@ -256,7 +256,7 @@ func (c *Controller) runningTraceflowCRD(tf *opsv1alpha1.Traceflow, dataPlaneTag } patchData := Traceflow{Status: opsv1alpha1.TraceflowStatus{Phase: tf.Status.Phase, DataplaneTag: dataPlaneTag}} payloads, _ := json.Marshal(patchData) - return c.client.OpsV1alpha1().Traceflows().Patch(context.TODO(), tf.Name, types.MergePatchType, payloads, v1.PatchOptions{}, "status") + return c.client.OpsV1alpha1().Traceflows().Patch(context.TODO(), tf.Name, types.MergePatchType, payloads, metav1.PatchOptions{}, "status") } func (c *Controller) errorTraceflowCRD(tf *opsv1alpha1.Traceflow, reason string) (*opsv1alpha1.Traceflow, error) { @@ -267,7 +267,7 @@ func (c *Controller) errorTraceflowCRD(tf *opsv1alpha1.Traceflow, reason string) } patchData := Traceflow{Status: opsv1alpha1.TraceflowStatus{Phase: tf.Status.Phase, Reason: reason}} payloads, _ := json.Marshal(patchData) - return c.client.OpsV1alpha1().Traceflows().Patch(context.TODO(), tf.Name, types.MergePatchType, payloads, v1.PatchOptions{}, "status") + return c.client.OpsV1alpha1().Traceflows().Patch(context.TODO(), tf.Name, types.MergePatchType, payloads, metav1.PatchOptions{}, "status") } func (c *Controller) occupyTag(tf *opsv1alpha1.Traceflow) error { diff --git a/pkg/monitor/controller.go b/pkg/monitor/controller.go index 6544a885d5d..97c840eec12 100644 --- a/pkg/monitor/controller.go +++ b/pkg/monitor/controller.go @@ -18,7 +18,7 @@ import ( "context" "time" - "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" @@ -143,14 +143,14 @@ func (monitor *controllerMonitor) deleteStaleAgentCRDs() { } func (monitor *controllerMonitor) deleteStaleAgentCRD(old interface{}) { - node, ok := old.(*v1.Node) + node, ok := old.(*corev1.Node) if !ok { tombstone, ok := old.(cache.DeletedFinalStateUnknown) if !ok { klog.Errorf("Error decoding object when deleting Node, invalid type: %v", old) return } - node, ok = tombstone.Obj.(*v1.Node) + node, ok = tombstone.Obj.(*corev1.Node) if !ok { klog.Errorf("Error decoding object tombstone when deleting Node, invalid type: %v", tombstone.Obj) return diff --git a/test/e2e/connectivity_test.go b/test/e2e/connectivity_test.go old mode 100755 new mode 100644 index 19c4ed01b5f..6c196ac289f --- a/test/e2e/connectivity_test.go +++ b/test/e2e/connectivity_test.go @@ -20,7 +20,7 @@ import ( "testing" "time" - "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" "github.com/vmware-tanzu/antrea/pkg/agent/config" ) @@ -101,8 +101,8 @@ func (data *TestData) testHostPortPodConnectivity(t *testing.T) { } defer deletePodWrapper(t, data, hpPodName) // Retrieve the IP Address of the Node on which the Pod is scheduled. - hpPod, err := data.podWaitFor(defaultTimeout, hpPodName, testNamespace, func(pod *v1.Pod) (bool, error) { - return pod.Status.Phase == v1.PodRunning, nil + hpPod, err := data.podWaitFor(defaultTimeout, hpPodName, testNamespace, func(pod *corev1.Pod) (bool, error) { + return pod.Status.Phase == corev1.PodRunning, nil }) if err != nil { t.Fatalf("Error when waiting for Pod '%s': %v", hpPodName, err) diff --git a/test/e2e/framework.go b/test/e2e/framework.go index 846474aaa50..943617e3af0 100644 --- a/test/e2e/framework.go +++ b/test/e2e/framework.go @@ -26,7 +26,7 @@ import ( "strings" "time" - "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" networkingv1 "k8s.io/api/networking/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -216,7 +216,7 @@ func collectClusterInfo() error { // createNamespace creates the provided namespace. func (data *TestData) createNamespace(namespace string) error { - ns := v1.Namespace{ + ns := corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ Name: namespace, }, @@ -227,7 +227,7 @@ func (data *TestData) createNamespace(namespace string) error { return fmt.Errorf("error when creating '%s' Namespace: %v", namespace, err) } // When namespace already exists, check phase - if ns.Status.Phase == v1.NamespaceTerminating { + if ns.Status.Phase == corev1.NamespaceTerminating { return fmt.Errorf("error when creating '%s' Namespace: namespace exists but is in 'Terminating' phase", namespace) } } @@ -261,7 +261,7 @@ func (data *TestData) deleteNamespace(namespace string, timeout time.Duration) e return true, nil } return false, fmt.Errorf("error when getting Namespace '%s' after delete: %v", namespace, err) - } else if ns.Status.Phase != v1.NamespaceTerminating { + } else if ns.Status.Phase != corev1.NamespaceTerminating { return false, fmt.Errorf("deleted Namespace '%s' should be in 'Terminating' phase", namespace) } @@ -467,23 +467,23 @@ func getImageName(uri string) string { // createPodOnNode creates a pod in the test namespace with a container whose type is decided by imageName. // Pod will be scheduled on the specified Node (if nodeName is not empty). -func (data *TestData) createPodOnNode(name string, nodeName string, image string, command []string, args []string, env []v1.EnvVar, ports []v1.ContainerPort) error { +func (data *TestData) createPodOnNode(name string, nodeName string, image string, command []string, args []string, env []corev1.EnvVar, ports []corev1.ContainerPort) error { // image could be a fully qualified URI which can't be used as container name and label value, // extract the image name from it. imageName := getImageName(image) - podSpec := v1.PodSpec{ - Containers: []v1.Container{ + podSpec := corev1.PodSpec{ + Containers: []corev1.Container{ { Name: imageName, Image: image, - ImagePullPolicy: v1.PullIfNotPresent, + ImagePullPolicy: corev1.PullIfNotPresent, Command: command, Args: args, Env: env, Ports: ports, }, }, - RestartPolicy: v1.RestartPolicyNever, + RestartPolicy: corev1.RestartPolicyNever, } if nodeName != "" { podSpec.NodeSelector = map[string]string{ @@ -492,14 +492,14 @@ func (data *TestData) createPodOnNode(name string, nodeName string, image string } if nodeName == masterNodeName() { // tolerate NoSchedule taint if we want Pod to run on master node - noScheduleToleration := v1.Toleration{ + noScheduleToleration := corev1.Toleration{ Key: "node-role.kubernetes.io/master", - Operator: v1.TolerationOpExists, - Effect: v1.TaintEffectNoSchedule, + Operator: corev1.TolerationOpExists, + Effect: corev1.TaintEffectNoSchedule, } - podSpec.Tolerations = []v1.Toleration{noScheduleToleration} + podSpec.Tolerations = []corev1.Toleration{noScheduleToleration} } - pod := &v1.Pod{ + pod := &corev1.Pod{ ObjectMeta: metav1.ObjectMeta{ Name: name, Labels: map[string]string{ @@ -530,11 +530,11 @@ func (data *TestData) createBusyboxPod(name string) error { // createNginxPodOnNode creates a Pod in the test namespace with a single nginx container. The // Pod will be scheduled on the specified Node (if nodeName is not empty). func (data *TestData) createNginxPodOnNode(name string, nodeName string) error { - return data.createPodOnNode(name, nodeName, "nginx", []string{}, nil, nil, []v1.ContainerPort{ + return data.createPodOnNode(name, nodeName, "nginx", []string{}, nil, nil, []corev1.ContainerPort{ { Name: "http", ContainerPort: 80, - Protocol: v1.ProtocolTCP, + Protocol: corev1.ProtocolTCP, }, }) } @@ -549,13 +549,13 @@ func (data *TestData) createServerPod(name string, portName string, portNum int, // See https://github.com/kubernetes/kubernetes/blob/master/test/images/agnhost/porter/porter.go#L17 for the image's detail. image := "gcr.io/kubernetes-e2e-test-images/agnhost:2.8" cmd := "porter" - env := v1.EnvVar{Name: fmt.Sprintf("SERVE_PORT_%d", portNum), Value: "foo"} - port := v1.ContainerPort{Name: portName, ContainerPort: int32(portNum)} + env := corev1.EnvVar{Name: fmt.Sprintf("SERVE_PORT_%d", portNum), Value: "foo"} + port := corev1.ContainerPort{Name: portName, ContainerPort: int32(portNum)} if setHostPort { // If hostPort is to be set, it must match the container port number. port.HostPort = int32(portNum) } - return data.createPodOnNode(name, "", image, nil, []string{cmd}, []v1.EnvVar{env}, []v1.ContainerPort{port}) + return data.createPodOnNode(name, "", image, nil, []string{cmd}, []corev1.EnvVar{env}, []corev1.ContainerPort{port}) } // deletePod deletes a Pod in the test namespace. @@ -595,11 +595,11 @@ func (data *TestData) deletePodAndWait(timeout time.Duration, name string) error } } -type PodCondition func(*v1.Pod) (bool, error) +type PodCondition func(*corev1.Pod) (bool, error) // podWaitFor polls the K8s apiserver until the specified Pod is found (in the test Namespace) and // the condition predicate is met (or until the provided timeout expires). -func (data *TestData) podWaitFor(timeout time.Duration, name, namespace string, condition PodCondition) (*v1.Pod, error) { +func (data *TestData) podWaitFor(timeout time.Duration, name, namespace string, condition PodCondition) (*corev1.Pod, error) { err := wait.Poll(1*time.Second, timeout, func() (bool, error) { if pod, err := data.clientset.CoreV1().Pods(namespace).Get(context.TODO(), name, metav1.GetOptions{}); err != nil { if errors.IsNotFound(err) { @@ -619,8 +619,8 @@ func (data *TestData) podWaitFor(timeout time.Duration, name, namespace string, // podWaitForRunning polls the k8s apiserver until the specified Pod is in the "running" state (or // until the provided timeout expires). func (data *TestData) podWaitForRunning(timeout time.Duration, name, namespace string) error { - _, err := data.podWaitFor(timeout, name, namespace, func(pod *v1.Pod) (bool, error) { - return pod.Status.Phase == v1.PodRunning, nil + _, err := data.podWaitFor(timeout, name, namespace, func(pod *corev1.Pod) (bool, error) { + return pod.Status.Phase == corev1.PodRunning, nil }) return err } @@ -628,8 +628,8 @@ func (data *TestData) podWaitForRunning(timeout time.Duration, name, namespace s // podWaitForIP polls the K8s apiserver until the specified Pod is in the "running" state (or until // the provided timeout expires). The function then returns the IP address assigned to the Pod. func (data *TestData) podWaitForIP(timeout time.Duration, name, namespace string) (string, error) { - pod, err := data.podWaitFor(timeout, name, namespace, func(pod *v1.Pod) (bool, error) { - return pod.Status.Phase == v1.PodRunning, nil + pod, err := data.podWaitFor(timeout, name, namespace, func(pod *corev1.Pod) (bool, error) { + return pod.Status.Phase == corev1.PodRunning, nil }) if err != nil { return "", err @@ -699,7 +699,7 @@ func (data *TestData) deleteAntreaAgentOnNode(nodeName string, gracePeriodSecond return false, nil } for _, pod := range pods.Items { - if pod.Status.Phase != v1.PodRunning { + if pod.Status.Phase != corev1.PodRunning { return false, nil } } @@ -728,7 +728,7 @@ func (data *TestData) getAntreaPodOnNode(nodeName string) (podName string, err e } // getAntreaController retrieves the name of the Antrea Controller (antrea-controller-*) running in the k8s cluster. -func (data *TestData) getAntreaController() (*v1.Pod, error) { +func (data *TestData) getAntreaController() (*corev1.Pod, error) { listOptions := metav1.ListOptions{ LabelSelector: "app=antrea,component=antrea-controller", } @@ -744,7 +744,7 @@ func (data *TestData) getAntreaController() (*v1.Pod, error) { // restartAntreaControllerPod deletes the antrea-controller Pod to force it to be re-scheduled. It then waits // for the new Pod to become available, and returns it. -func (data *TestData) restartAntreaControllerPod(timeout time.Duration) (*v1.Pod, error) { +func (data *TestData) restartAntreaControllerPod(timeout time.Duration) (*corev1.Pod, error) { var gracePeriodSeconds int64 = 1 deleteOptions := metav1.DeleteOptions{ GracePeriodSeconds: &gracePeriodSeconds, @@ -756,7 +756,7 @@ func (data *TestData) restartAntreaControllerPod(timeout time.Duration) (*v1.Pod return nil, fmt.Errorf("error when deleting antrea-controller Pod: %v", err) } - var newPod *v1.Pod + var newPod *corev1.Pod // wait for new antrea-controller Pod if err := wait.Poll(1*time.Second, timeout, func() (bool, error) { pods, err := data.clientset.CoreV1().Pods("kube-system").List(context.TODO(), listOptions) @@ -771,7 +771,7 @@ func (data *TestData) restartAntreaControllerPod(timeout time.Duration) (*v1.Pod return false, nil } pod := pods.Items[0] - if pod.Status.Phase != v1.PodRunning || pod.DeletionTimestamp != nil { + if pod.Status.Phase != corev1.PodRunning || pod.DeletionTimestamp != nil { return false, nil } newPod = &pod @@ -814,12 +814,12 @@ func validatePodIP(podNetworkCIDR, podIP string) (bool, error) { // createService creates a service with port and targetPort. func (data *TestData) createService(serviceName string, port, targetPort int, selector map[string]string, affinity bool, - serviceType v1.ServiceType) (*v1.Service, error) { - affinityType := v1.ServiceAffinityNone + serviceType corev1.ServiceType) (*corev1.Service, error) { + affinityType := corev1.ServiceAffinityNone if affinity { - affinityType = v1.ServiceAffinityClientIP + affinityType = corev1.ServiceAffinityClientIP } - service := v1.Service{ + service := corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: serviceName, Namespace: testNamespace, @@ -828,9 +828,9 @@ func (data *TestData) createService(serviceName string, port, targetPort int, se "app": serviceName, }, }, - Spec: v1.ServiceSpec{ + Spec: corev1.ServiceSpec{ SessionAffinity: affinityType, - Ports: []v1.ServicePort{{ + Ports: []corev1.ServicePort{{ Port: int32(port), TargetPort: intstr.FromInt(targetPort), }}, @@ -842,16 +842,16 @@ func (data *TestData) createService(serviceName string, port, targetPort int, se } // createNginxClusterIPService create a nginx service with the given name. -func (data *TestData) createNginxClusterIPService(affinity bool) (*v1.Service, error) { - return data.createService("nginx", 80, 80, map[string]string{"app": "nginx"}, affinity, v1.ServiceTypeClusterIP) +func (data *TestData) createNginxClusterIPService(affinity bool) (*corev1.Service, error) { + return data.createService("nginx", 80, 80, map[string]string{"app": "nginx"}, affinity, corev1.ServiceTypeClusterIP) } -func (data *TestData) createNginxLoadBalancerService(affinity bool, ingressIPs []string) (*v1.Service, error) { - svc, err := data.createService("nginx-loadbalancer", 80, 80, map[string]string{"app": "nginx"}, affinity, v1.ServiceTypeLoadBalancer) +func (data *TestData) createNginxLoadBalancerService(affinity bool, ingressIPs []string) (*corev1.Service, error) { + svc, err := data.createService("nginx-loadbalancer", 80, 80, map[string]string{"app": "nginx"}, affinity, corev1.ServiceTypeLoadBalancer) if err != nil { return svc, err } - ingress := make([]v1.LoadBalancerIngress, len(ingressIPs)) + ingress := make([]corev1.LoadBalancerIngress, len(ingressIPs)) for idx, ingressIP := range ingressIPs { ingress[idx].IP = ingressIP } @@ -920,7 +920,7 @@ func (data *TestData) runCommandFromPod(podNamespace string, podName string, con Name(podName). SubResource("exec"). Param("container", containerName). - VersionedParams(&v1.PodExecOptions{ + VersionedParams(&corev1.PodExecOptions{ Command: cmd, Stdin: false, Stdout: true, @@ -1051,7 +1051,7 @@ func (data *TestData) GetEncapMode() (config.TrafficEncapModeType, error) { return config.TrafficEncapModeInvalid, fmt.Errorf("antrea-conf config map is not found") } -func (data *TestData) GetAntreaConfigMap(antreaNamespace string) (*v1.ConfigMap, error) { +func (data *TestData) GetAntreaConfigMap(antreaNamespace string) (*corev1.ConfigMap, error) { deployment, err := data.clientset.AppsV1().Deployments(antreaNamespace).Get(context.TODO(), antreaDeployment, metav1.GetOptions{}) if err != nil { return nil, fmt.Errorf("failed to retrieve Antrea Controller deployment: %v", err) diff --git a/test/e2e/performance_test.go b/test/e2e/performance_test.go index f9bfdae3a0b..622a1577e52 100644 --- a/test/e2e/performance_test.go +++ b/test/e2e/performance_test.go @@ -24,11 +24,10 @@ import ( "time" "golang.org/x/exp/rand" - "k8s.io/apimachinery/pkg/util/wait" - corev1 "k8s.io/api/core/v1" networkv1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/wait" ) const ( diff --git a/test/e2e/providers/kind.go b/test/e2e/providers/kind.go index 21ad8900691..8d9687f40a1 100644 --- a/test/e2e/providers/kind.go +++ b/test/e2e/providers/kind.go @@ -16,10 +16,11 @@ package providers import ( "fmt" - "github.com/vmware-tanzu/antrea/test/e2e/providers/exec" "os" "path" "strings" + + "github.com/vmware-tanzu/antrea/test/e2e/providers/exec" ) type KindProvider struct { diff --git a/test/e2e/proxy_test.go b/test/e2e/proxy_test.go index 515e8f6ddf5..aade8cf6cd8 100644 --- a/test/e2e/proxy_test.go +++ b/test/e2e/proxy_test.go @@ -23,7 +23,7 @@ import ( "time" "github.com/stretchr/testify/require" - "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -100,10 +100,10 @@ func TestProxyHairpin(t *testing.T) { skipIfProxyDisabled(t, data) nodeName := nodeName(1) - err = data.createPodOnNode("busybox", nodeName, "busybox", []string{"nc", "-lk", "-p", "80"}, nil, nil, []v1.ContainerPort{{ContainerPort: 80, Protocol: v1.ProtocolTCP}}) + err = data.createPodOnNode("busybox", nodeName, "busybox", []string{"nc", "-lk", "-p", "80"}, nil, nil, []corev1.ContainerPort{{ContainerPort: 80, Protocol: corev1.ProtocolTCP}}) require.NoError(t, err) require.NoError(t, data.podWaitForRunning(defaultTimeout, "busybox", testNamespace)) - svc, err := data.createService("busybox", 80, 80, map[string]string{"antrea-e2e": "busybox"}, false, v1.ServiceTypeClusterIP) + svc, err := data.createService("busybox", 80, 80, map[string]string{"antrea-e2e": "busybox"}, false, corev1.ServiceTypeClusterIP) require.NoError(t, err) stdout, stderr, err := data.runCommandFromPod(testNamespace, "busybox", busyboxContainerName, []string{"nc", svc.Spec.ClusterIP, "80", "-w", "1", "-e", "ls", "/"}) require.NoError(t, err, fmt.Sprintf("stdout: %s\n, stderr: %s", stdout, stderr)) diff --git a/test/e2e/reachability.go b/test/e2e/reachability.go index ee97e11d8cc..9940a76fc08 100644 --- a/test/e2e/reachability.go +++ b/test/e2e/reachability.go @@ -16,9 +16,10 @@ package e2e import ( "fmt" + "strings" + "github.com/pkg/errors" log "github.com/sirupsen/logrus" - "strings" ) type Pod string diff --git a/test/e2e/traceflow_test.go b/test/e2e/traceflow_test.go index 2e9aca17c59..c54151beb09 100644 --- a/test/e2e/traceflow_test.go +++ b/test/e2e/traceflow_test.go @@ -22,7 +22,6 @@ import ( "time" networkingv1 "k8s.io/api/networking/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" @@ -328,11 +327,11 @@ func TestTraceflow(t *testing.T) { tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() - if _, err := data.crdClient.OpsV1alpha1().Traceflows().Create(context.TODO(), tc.tf, v1.CreateOptions{}); err != nil { + if _, err := data.crdClient.OpsV1alpha1().Traceflows().Create(context.TODO(), tc.tf, metav1.CreateOptions{}); err != nil { t.Fatalf("Error when creating traceflow: %v", err) } defer func() { - if err := data.crdClient.OpsV1alpha1().Traceflows().Delete(context.TODO(), tc.tf.Name, v1.DeleteOptions{}); err != nil { + if err := data.crdClient.OpsV1alpha1().Traceflows().Delete(context.TODO(), tc.tf.Name, metav1.DeleteOptions{}); err != nil { t.Errorf("Error when deleting traceflow: %v", err) } }() @@ -381,7 +380,7 @@ func (data *TestData) waitForTraceflow(name string, phase v1alpha1.TraceflowPhas var tf *v1alpha1.Traceflow var err error if err = wait.PollImmediate(1*time.Second, 15*time.Second, func() (bool, error) { - tf, err = data.crdClient.OpsV1alpha1().Traceflows().Get(context.TODO(), name, v1.GetOptions{}) + tf, err = data.crdClient.OpsV1alpha1().Traceflows().Get(context.TODO(), name, metav1.GetOptions{}) if err != nil || tf.Status.Phase != phase { return false, nil } diff --git a/test/e2e/utils/cnpspecbuilder.go b/test/e2e/utils/cnpspecbuilder.go index 85045e660eb..8552a7798ea 100644 --- a/test/e2e/utils/cnpspecbuilder.go +++ b/test/e2e/utils/cnpspecbuilder.go @@ -16,7 +16,6 @@ package utils import ( v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" diff --git a/test/e2e/utils/networkpolicyspecbuilder.go b/test/e2e/utils/networkpolicyspecbuilder.go index debb99606de..40af266cf79 100644 --- a/test/e2e/utils/networkpolicyspecbuilder.go +++ b/test/e2e/utils/networkpolicyspecbuilder.go @@ -17,7 +17,6 @@ package utils import ( v1 "k8s.io/api/core/v1" networkingv1 "k8s.io/api/networking/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" )