From 26377722982a8489d2a974db88e7478e54e4eaf0 Mon Sep 17 00:00:00 2001 From: Mike Danese Date: Tue, 17 Dec 2019 00:01:53 -0800 Subject: [PATCH] some manual fixes --- .../cloud/node_lifecycle_controller_test.go | 5 ++-- pkg/controller/controller_utils_test.go | 7 +++-- .../nodeipam/ipam/range_allocator_test.go | 5 ++-- .../node_lifecycle_controller_test.go | 24 ++++++++-------- pkg/controller/replication/conversion.go | 28 +++++++++---------- pkg/controller/testutil/test_utils.go | 27 +++++++++--------- .../certificate/bootstrap/bootstrap_test.go | 7 +++-- pkg/kubelet/pluginmanager/pluginwatcher/BUILD | 1 - .../pluginwatcher/example_handler.go | 2 +- .../pluginwatcher/example_plugin.go | 2 +- pkg/util/node/node.go | 2 +- .../typed/core/v1/event_expansion.go | 2 +- .../typed/core/v1/fake/fake_node_expansion.go | 6 ++-- .../typed/core/v1/node_expansion.go | 6 ++-- .../certificate/certificate_manager_test.go | 7 +++-- .../cloud-provider/node/helpers/conditions.go | 3 +- test/e2e_node/BUILD | 1 - test/e2e_node/util.go | 2 -- 18 files changed, 71 insertions(+), 66 deletions(-) diff --git a/pkg/controller/cloud/node_lifecycle_controller_test.go b/pkg/controller/cloud/node_lifecycle_controller_test.go index 67685f36be9..974daea95bc 100644 --- a/pkg/controller/cloud/node_lifecycle_controller_test.go +++ b/pkg/controller/cloud/node_lifecycle_controller_test.go @@ -17,12 +17,13 @@ limitations under the License. package cloud import ( + "context" "errors" "reflect" "testing" "time" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/informers" @@ -448,7 +449,7 @@ func Test_NodesShutdown(t *testing.T) { } func syncNodeStore(nodeinformer coreinformers.NodeInformer, f *testutil.FakeNodeHandler) error { - nodes, err := f.List(metav1.ListOptions{}) + nodes, err := f.List(context.TODO(), metav1.ListOptions{}) if err != nil { return err } diff --git a/pkg/controller/controller_utils_test.go b/pkg/controller/controller_utils_test.go index 4ede69f007c..5ab7908a662 100644 --- a/pkg/controller/controller_utils_test.go +++ b/pkg/controller/controller_utils_test.go @@ -17,6 +17,7 @@ limitations under the License. package controller import ( + "context" "encoding/json" "fmt" "math" @@ -733,11 +734,11 @@ func TestRemoveTaintOffNode(t *testing.T) { }, } for _, test := range tests { - node, _ := test.nodeHandler.Get(test.nodeName, metav1.GetOptions{}) + node, _ := test.nodeHandler.Get(context.TODO(), test.nodeName, metav1.GetOptions{}) err := RemoveTaintOffNode(test.nodeHandler, test.nodeName, node, test.taintsToRemove...) assert.NoError(t, err, "%s: RemoveTaintOffNode() error = %v", test.name, err) - node, _ = test.nodeHandler.Get(test.nodeName, metav1.GetOptions{}) + node, _ = test.nodeHandler.Get(context.TODO(), test.nodeName, metav1.GetOptions{}) assert.EqualValues(t, test.expectedTaints, node.Spec.Taints, "%s: failed to remove taint off node: expected %+v, got %+v", test.name, test.expectedTaints, node.Spec.Taints) @@ -912,7 +913,7 @@ func TestAddOrUpdateTaintOnNode(t *testing.T) { err := AddOrUpdateTaintOnNode(test.nodeHandler, test.nodeName, test.taintsToAdd...) assert.NoError(t, err, "%s: AddOrUpdateTaintOnNode() error = %v", test.name, err) - node, _ := test.nodeHandler.Get(test.nodeName, metav1.GetOptions{}) + node, _ := test.nodeHandler.Get(context.TODO(), test.nodeName, metav1.GetOptions{}) assert.EqualValues(t, test.expectedTaints, node.Spec.Taints, "%s: failed to add taint to node: expected %+v, got %+v", test.name, test.expectedTaints, node.Spec.Taints) diff --git a/pkg/controller/nodeipam/ipam/range_allocator_test.go b/pkg/controller/nodeipam/ipam/range_allocator_test.go index c017fb0bb41..92cf51af2d4 100644 --- a/pkg/controller/nodeipam/ipam/range_allocator_test.go +++ b/pkg/controller/nodeipam/ipam/range_allocator_test.go @@ -17,11 +17,12 @@ limitations under the License. package ipam import ( + "context" "net" "testing" "time" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/informers" @@ -306,7 +307,7 @@ func TestOccupyPreExistingCIDR(t *testing.T) { t.Run(tc.description, func(t *testing.T) { // Initialize the range allocator. fakeNodeInformer := getFakeNodeInformer(tc.fakeNodeHandler) - nodeList, _ := tc.fakeNodeHandler.List(metav1.ListOptions{}) + nodeList, _ := tc.fakeNodeHandler.List(context.TODO(), metav1.ListOptions{}) _, err := NewCIDRRangeAllocator(tc.fakeNodeHandler, fakeNodeInformer, tc.allocatorParams, nodeList) if err == nil && tc.ctrlCreateFail { t.Fatalf("creating range allocator was expected to fail, but it did not") diff --git a/pkg/controller/nodelifecycle/node_lifecycle_controller_test.go b/pkg/controller/nodelifecycle/node_lifecycle_controller_test.go index 13e733a70f3..32eeced551e 100644 --- a/pkg/controller/nodelifecycle/node_lifecycle_controller_test.go +++ b/pkg/controller/nodelifecycle/node_lifecycle_controller_test.go @@ -135,7 +135,7 @@ func (nc *nodeLifecycleController) syncLeaseStore(lease *coordv1.Lease) error { } func (nc *nodeLifecycleController) syncNodeStore(fakeNodeHandler *testutil.FakeNodeHandler) error { - nodes, err := fakeNodeHandler.List(metav1.ListOptions{}) + nodes, err := fakeNodeHandler.List(context.TODO(), metav1.ListOptions{}) if err != nil { return err } @@ -2740,7 +2740,7 @@ func TestApplyNoExecuteTaints(t *testing.T) { t.Errorf("unexpected error: %v", err) } nodeController.doNoExecuteTaintingPass() - node0, err := fakeNodeHandler.Get("node0", metav1.GetOptions{}) + node0, err := fakeNodeHandler.Get(context.TODO(), "node0", metav1.GetOptions{}) if err != nil { t.Errorf("Can't get current node0...") return @@ -2748,7 +2748,7 @@ func TestApplyNoExecuteTaints(t *testing.T) { if !taintutils.TaintExists(node0.Spec.Taints, UnreachableTaintTemplate) { t.Errorf("Can't find taint %v in %v", originalTaint, node0.Spec.Taints) } - node2, err := fakeNodeHandler.Get("node2", metav1.GetOptions{}) + node2, err := fakeNodeHandler.Get(context.TODO(), "node2", metav1.GetOptions{}) if err != nil { t.Errorf("Can't get current node2...") return @@ -2759,7 +2759,7 @@ func TestApplyNoExecuteTaints(t *testing.T) { // Make node3 healthy again. node2.Status = healthyNodeNewStatus - _, err = fakeNodeHandler.UpdateStatus(node2) + _, err = fakeNodeHandler.UpdateStatus(context.TODO(), node2) if err != nil { t.Errorf(err.Error()) return @@ -2772,7 +2772,7 @@ func TestApplyNoExecuteTaints(t *testing.T) { } nodeController.doNoExecuteTaintingPass() - node2, err = fakeNodeHandler.Get("node2", metav1.GetOptions{}) + node2, err = fakeNodeHandler.Get(context.TODO(), "node2", metav1.GetOptions{}) if err != nil { t.Errorf("Can't get current node2...") return @@ -2886,12 +2886,12 @@ func TestSwapUnreachableNotReadyTaints(t *testing.T) { } nodeController.doNoExecuteTaintingPass() - node0, err := fakeNodeHandler.Get("node0", metav1.GetOptions{}) + node0, err := fakeNodeHandler.Get(context.TODO(), "node0", metav1.GetOptions{}) if err != nil { t.Errorf("Can't get current node0...") return } - node1, err := fakeNodeHandler.Get("node1", metav1.GetOptions{}) + node1, err := fakeNodeHandler.Get(context.TODO(), "node1", metav1.GetOptions{}) if err != nil { t.Errorf("Can't get current node1...") return @@ -2905,12 +2905,12 @@ func TestSwapUnreachableNotReadyTaints(t *testing.T) { node0.Status = newNodeStatus node1.Status = healthyNodeNewStatus - _, err = fakeNodeHandler.UpdateStatus(node0) + _, err = fakeNodeHandler.UpdateStatus(context.TODO(), node0) if err != nil { t.Errorf(err.Error()) return } - _, err = fakeNodeHandler.UpdateStatus(node1) + _, err = fakeNodeHandler.UpdateStatus(context.TODO(), node1) if err != nil { t.Errorf(err.Error()) return @@ -2924,7 +2924,7 @@ func TestSwapUnreachableNotReadyTaints(t *testing.T) { } nodeController.doNoExecuteTaintingPass() - node0, err = fakeNodeHandler.Get("node0", metav1.GetOptions{}) + node0, err = fakeNodeHandler.Get(context.TODO(), "node0", metav1.GetOptions{}) if err != nil { t.Errorf("Can't get current node0...") return @@ -3120,7 +3120,7 @@ func TestTaintsNodeByCondition(t *testing.T) { } for _, test := range tests { - fakeNodeHandler.Update(test.Node) + fakeNodeHandler.Update(context.TODO(), test.Node) if err := nodeController.syncNodeStore(fakeNodeHandler); err != nil { t.Errorf("unexpected error: %v", err) } @@ -3331,7 +3331,7 @@ func TestReconcileNodeLabels(t *testing.T) { } for _, test := range tests { - fakeNodeHandler.Update(test.Node) + fakeNodeHandler.Update(context.TODO(), test.Node) if err := nodeController.syncNodeStore(fakeNodeHandler); err != nil { t.Fatalf("unexpected error: %v", err) } diff --git a/pkg/controller/replication/conversion.go b/pkg/controller/replication/conversion.go index 38d9972eaef..b33fbb8e03c 100644 --- a/pkg/controller/replication/conversion.go +++ b/pkg/controller/replication/conversion.go @@ -203,19 +203,19 @@ type conversionClient struct { v1client.ReplicationControllerInterface } -func (c conversionClient) Create(rs *apps.ReplicaSet) (*apps.ReplicaSet, error) { - return convertCall(c.ReplicationControllerInterface.Create, rs) +func (c conversionClient) Create(ctx context.Context, rs *apps.ReplicaSet) (*apps.ReplicaSet, error) { + return convertCall(ctx, c.ReplicationControllerInterface.Create, rs) } -func (c conversionClient) Update(rs *apps.ReplicaSet) (*apps.ReplicaSet, error) { - return convertCall(c.ReplicationControllerInterface.Update, rs) +func (c conversionClient) Update(ctx context.Context, rs *apps.ReplicaSet) (*apps.ReplicaSet, error) { + return convertCall(ctx, c.ReplicationControllerInterface.Update, rs) } -func (c conversionClient) UpdateStatus(rs *apps.ReplicaSet) (*apps.ReplicaSet, error) { - return convertCall(c.ReplicationControllerInterface.UpdateStatus, rs) +func (c conversionClient) UpdateStatus(ctx context.Context, rs *apps.ReplicaSet) (*apps.ReplicaSet, error) { + return convertCall(ctx, c.ReplicationControllerInterface.UpdateStatus, rs) } -func (c conversionClient) Get(name string, options metav1.GetOptions) (*apps.ReplicaSet, error) { +func (c conversionClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*apps.ReplicaSet, error) { rc, err := c.ReplicationControllerInterface.Get(context.TODO(), name, options) if err != nil { return nil, err @@ -223,7 +223,7 @@ func (c conversionClient) Get(name string, options metav1.GetOptions) (*apps.Rep return convertRCtoRS(rc, nil) } -func (c conversionClient) List(opts metav1.ListOptions) (*apps.ReplicaSetList, error) { +func (c conversionClient) List(ctx context.Context, opts metav1.ListOptions) (*apps.ReplicaSetList, error) { rcList, err := c.ReplicationControllerInterface.List(context.TODO(), opts) if err != nil { return nil, err @@ -231,22 +231,22 @@ func (c conversionClient) List(opts metav1.ListOptions) (*apps.ReplicaSetList, e return convertList(rcList) } -func (c conversionClient) Watch(opts metav1.ListOptions) (watch.Interface, error) { +func (c conversionClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { // This is not used by RSC because we wrap the shared informer instead. return nil, errors.New("Watch() is not implemented for conversionClient") } -func (c conversionClient) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *apps.ReplicaSet, err error) { +func (c conversionClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, subresources ...string) (result *apps.ReplicaSet, err error) { // This is not used by RSC. return nil, errors.New("Patch() is not implemented for conversionClient") } -func (c conversionClient) GetScale(name string, options metav1.GetOptions) (result *autoscalingv1.Scale, err error) { +func (c conversionClient) GetScale(ctx context.Context, name string, options metav1.GetOptions) (result *autoscalingv1.Scale, err error) { // This is not used by RSC. return nil, errors.New("GetScale() is not implemented for conversionClient") } -func (c conversionClient) UpdateScale(name string, scale *autoscalingv1.Scale) (result *autoscalingv1.Scale, err error) { +func (c conversionClient) UpdateScale(ctx context.Context, name string, scale *autoscalingv1.Scale) (result *autoscalingv1.Scale, err error) { // This is not used by RSC. return nil, errors.New("UpdateScale() is not implemented for conversionClient") } @@ -275,12 +275,12 @@ func convertList(rcList *v1.ReplicationControllerList) (*apps.ReplicaSetList, er return rsList, nil } -func convertCall(fn func(*v1.ReplicationController) (*v1.ReplicationController, error), rs *apps.ReplicaSet) (*apps.ReplicaSet, error) { +func convertCall(ctx context.Context, fn func(context.Context, *v1.ReplicationController) (*v1.ReplicationController, error), rs *apps.ReplicaSet) (*apps.ReplicaSet, error) { rc, err := convertRStoRC(rs) if err != nil { return nil, err } - result, err := fn(rc) + result, err := fn(ctx, rc) if err != nil { return nil, err } diff --git a/pkg/controller/testutil/test_utils.go b/pkg/controller/testutil/test_utils.go index 807139524ff..7eb12d8b83a 100644 --- a/pkg/controller/testutil/test_utils.go +++ b/pkg/controller/testutil/test_utils.go @@ -17,6 +17,7 @@ limitations under the License. package testutil import ( + "context" "encoding/json" "errors" "fmt" @@ -37,7 +38,7 @@ import ( "k8s.io/apimachinery/pkg/util/clock" ref "k8s.io/client-go/tools/reference" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "k8s.io/client-go/kubernetes/fake" v1core "k8s.io/client-go/kubernetes/typed/core/v1" "k8s.io/client-go/tools/cache" @@ -110,7 +111,7 @@ func (m *FakeLegacyHandler) Nodes() v1core.NodeInterface { } // Create adds a new Node to the fake store. -func (m *FakeNodeHandler) Create(node *v1.Node) (*v1.Node, error) { +func (m *FakeNodeHandler) Create(_ context.Context, node *v1.Node) (*v1.Node, error) { m.lock.Lock() defer func() { m.RequestCount++ @@ -130,7 +131,7 @@ func (m *FakeNodeHandler) Create(node *v1.Node) (*v1.Node, error) { } // Get returns a Node from the fake store. -func (m *FakeNodeHandler) Get(name string, opts metav1.GetOptions) (*v1.Node, error) { +func (m *FakeNodeHandler) Get(_ context.Context, name string, opts metav1.GetOptions) (*v1.Node, error) { m.lock.Lock() defer func() { m.RequestCount++ @@ -152,7 +153,7 @@ func (m *FakeNodeHandler) Get(name string, opts metav1.GetOptions) (*v1.Node, er } // List returns a list of Nodes from the fake store. -func (m *FakeNodeHandler) List(opts metav1.ListOptions) (*v1.NodeList, error) { +func (m *FakeNodeHandler) List(_ context.Context, opts metav1.ListOptions) (*v1.NodeList, error) { m.lock.Lock() defer func() { m.RequestCount++ @@ -182,7 +183,7 @@ func (m *FakeNodeHandler) List(opts metav1.ListOptions) (*v1.NodeList, error) { } // Delete deletes a Node from the fake store. -func (m *FakeNodeHandler) Delete(id string, opt *metav1.DeleteOptions) error { +func (m *FakeNodeHandler) Delete(_ context.Context, id string, opt *metav1.DeleteOptions) error { m.lock.Lock() defer func() { m.RequestCount++ @@ -196,12 +197,12 @@ func (m *FakeNodeHandler) Delete(id string, opt *metav1.DeleteOptions) error { } // DeleteCollection deletes a collection of Nodes from the fake store. -func (m *FakeNodeHandler) DeleteCollection(opt *metav1.DeleteOptions, listOpts metav1.ListOptions) error { +func (m *FakeNodeHandler) DeleteCollection(_ context.Context, opt *metav1.DeleteOptions, listOpts metav1.ListOptions) error { return nil } // Update updates a Node in the fake store. -func (m *FakeNodeHandler) Update(node *v1.Node) (*v1.Node, error) { +func (m *FakeNodeHandler) Update(_ context.Context, node *v1.Node) (*v1.Node, error) { m.lock.Lock() defer func() { m.RequestCount++ @@ -220,7 +221,7 @@ func (m *FakeNodeHandler) Update(node *v1.Node) (*v1.Node, error) { } // UpdateStatus updates a status of a Node in the fake store. -func (m *FakeNodeHandler) UpdateStatus(node *v1.Node) (*v1.Node, error) { +func (m *FakeNodeHandler) UpdateStatus(_ context.Context, node *v1.Node) (*v1.Node, error) { m.lock.Lock() defer func() { m.RequestCount++ @@ -263,18 +264,18 @@ func (m *FakeNodeHandler) UpdateStatus(node *v1.Node) (*v1.Node, error) { } // PatchStatus patches a status of a Node in the fake store. -func (m *FakeNodeHandler) PatchStatus(nodeName string, data []byte) (*v1.Node, error) { +func (m *FakeNodeHandler) PatchStatus(ctx context.Context, nodeName string, data []byte) (*v1.Node, error) { m.RequestCount++ - return m.Patch(nodeName, types.StrategicMergePatchType, data, "status") + return m.Patch(ctx, nodeName, types.StrategicMergePatchType, data, "status") } // Watch watches Nodes in a fake store. -func (m *FakeNodeHandler) Watch(opts metav1.ListOptions) (watch.Interface, error) { +func (m *FakeNodeHandler) Watch(_ context.Context, opts metav1.ListOptions) (watch.Interface, error) { return watch.NewFake(), nil } // Patch patches a Node in the fake store. -func (m *FakeNodeHandler) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*v1.Node, error) { +func (m *FakeNodeHandler) Patch(_ context.Context, name string, pt types.PatchType, data []byte, subresources ...string) (*v1.Node, error) { m.lock.Lock() defer func() { m.RequestCount++ @@ -476,7 +477,7 @@ func contains(node *v1.Node, nodes []*v1.Node) bool { // GetZones returns list of zones for all Nodes stored in FakeNodeHandler func GetZones(nodeHandler *FakeNodeHandler) []string { - nodes, _ := nodeHandler.List(metav1.ListOptions{}) + nodes, _ := nodeHandler.List(context.TODO(), metav1.ListOptions{}) zones := sets.NewString() for _, node := range nodes.Items { zones.Insert(utilnode.GetZoneKey(&node)) diff --git a/pkg/kubelet/certificate/bootstrap/bootstrap_test.go b/pkg/kubelet/certificate/bootstrap/bootstrap_test.go index a3d47194c7c..40bbfd16b6c 100644 --- a/pkg/kubelet/certificate/bootstrap/bootstrap_test.go +++ b/pkg/kubelet/certificate/bootstrap/bootstrap_test.go @@ -17,6 +17,7 @@ limitations under the License. package bootstrap import ( + "context" "fmt" "io/ioutil" "os" @@ -147,7 +148,7 @@ type fakeClient struct { failureType failureType } -func (c *fakeClient) Create(*certificates.CertificateSigningRequest) (*certificates.CertificateSigningRequest, error) { +func (c *fakeClient) Create(context.Context, *certificates.CertificateSigningRequest) (*certificates.CertificateSigningRequest, error) { if c.failureType == createError { return nil, fmt.Errorf("fakeClient failed creating request") } @@ -160,11 +161,11 @@ func (c *fakeClient) Create(*certificates.CertificateSigningRequest) (*certifica return &csr, nil } -func (c *fakeClient) List(opts metav1.ListOptions) (*certificates.CertificateSigningRequestList, error) { +func (c *fakeClient) List(_ context.Context, opts metav1.ListOptions) (*certificates.CertificateSigningRequestList, error) { return &certificates.CertificateSigningRequestList{}, nil } -func (c *fakeClient) Watch(opts metav1.ListOptions) (watch.Interface, error) { +func (c *fakeClient) Watch(_ context.Context, opts metav1.ListOptions) (watch.Interface, error) { c.watch = watch.NewFakeWithChanSize(1, false) c.watch.Add(c.generateCSR()) c.watch.Stop() diff --git a/pkg/kubelet/pluginmanager/pluginwatcher/BUILD b/pkg/kubelet/pluginmanager/pluginwatcher/BUILD index 06f911a5bc7..b8cbf8ccdd7 100644 --- a/pkg/kubelet/pluginmanager/pluginwatcher/BUILD +++ b/pkg/kubelet/pluginmanager/pluginwatcher/BUILD @@ -17,7 +17,6 @@ go_library( "//pkg/util/filesystem:go_default_library", "//staging/src/k8s.io/kubelet/pkg/apis/pluginregistration/v1:go_default_library", "//vendor/github.com/fsnotify/fsnotify:go_default_library", - "//vendor/golang.org/x/net/context:go_default_library", "//vendor/google.golang.org/grpc:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], diff --git a/pkg/kubelet/pluginmanager/pluginwatcher/example_handler.go b/pkg/kubelet/pluginmanager/pluginwatcher/example_handler.go index 16dc6396922..70dcb21bd42 100644 --- a/pkg/kubelet/pluginmanager/pluginwatcher/example_handler.go +++ b/pkg/kubelet/pluginmanager/pluginwatcher/example_handler.go @@ -17,6 +17,7 @@ limitations under the License. package pluginwatcher import ( + "context" "errors" "fmt" "net" @@ -24,7 +25,6 @@ import ( "sync" "time" - "golang.org/x/net/context" "google.golang.org/grpc" "k8s.io/klog" diff --git a/pkg/kubelet/pluginmanager/pluginwatcher/example_plugin.go b/pkg/kubelet/pluginmanager/pluginwatcher/example_plugin.go index ca2e4342272..ac4cd855c02 100644 --- a/pkg/kubelet/pluginmanager/pluginwatcher/example_plugin.go +++ b/pkg/kubelet/pluginmanager/pluginwatcher/example_plugin.go @@ -17,6 +17,7 @@ limitations under the License. package pluginwatcher import ( + "context" "errors" "fmt" "net" @@ -24,7 +25,6 @@ import ( "sync" "time" - "golang.org/x/net/context" "google.golang.org/grpc" "k8s.io/klog" diff --git a/pkg/util/node/node.go b/pkg/util/node/node.go index ac16760f9b1..1d6b0a6e657 100644 --- a/pkg/util/node/node.go +++ b/pkg/util/node/node.go @@ -202,7 +202,7 @@ func SetNodeCondition(c clientset.Interface, node types.NodeName, condition v1.N if err != nil { return nil } - _, err = c.CoreV1().Nodes().PatchStatus(string(node), patch) + _, err = c.CoreV1().Nodes().PatchStatus(context.TODO(), string(node), patch) return err } diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/event_expansion.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/event_expansion.go index 7377ef5d70d..211cf0603c0 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/event_expansion.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/event_expansion.go @@ -119,7 +119,7 @@ func (e *events) Search(scheme *runtime.Scheme, objOrRef runtime.Object) (*v1.Ev refUID = &stringRefUID } fieldSelector := e.GetFieldSelector(&ref.Name, &ref.Namespace, refKind, refUID) - return e.List(metav1.ListOptions{FieldSelector: fieldSelector.String()}) + return e.List(context.TODO(), metav1.ListOptions{FieldSelector: fieldSelector.String()}) } // Returns the appropriate field selector based on the API version being used to communicate with the server. diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/fake/fake_node_expansion.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/fake/fake_node_expansion.go index a39022c83f4..eccf9fec63c 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/fake/fake_node_expansion.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/fake/fake_node_expansion.go @@ -17,13 +17,15 @@ limitations under the License. package fake import ( - "k8s.io/api/core/v1" + "context" + + v1 "k8s.io/api/core/v1" types "k8s.io/apimachinery/pkg/types" core "k8s.io/client-go/testing" ) // TODO: Should take a PatchType as an argument probably. -func (c *FakeNodes) PatchStatus(nodeName string, data []byte) (*v1.Node, error) { +func (c *FakeNodes) PatchStatus(_ context.Context, nodeName string, data []byte) (*v1.Node, error) { // TODO: Should be configurable to support additional patch strategies. pt := types.StrategicMergePatchType obj, err := c.Fake.Invokes( diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/node_expansion.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/node_expansion.go index 1df46ed56f6..bdf7bfed8d4 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/node_expansion.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/node_expansion.go @@ -27,19 +27,19 @@ import ( type NodeExpansion interface { // PatchStatus modifies the status of an existing node. It returns the copy // of the node that the server returns, or an error. - PatchStatus(nodeName string, data []byte) (*v1.Node, error) + PatchStatus(ctx context.Context, nodeName string, data []byte) (*v1.Node, error) } // PatchStatus modifies the status of an existing node. It returns the copy of // the node that the server returns, or an error. -func (c *nodes) PatchStatus(nodeName string, data []byte) (*v1.Node, error) { +func (c *nodes) PatchStatus(ctx context.Context, nodeName string, data []byte) (*v1.Node, error) { result := &v1.Node{} err := c.client.Patch(types.StrategicMergePatchType). Resource("nodes"). Name(nodeName). SubResource("status"). Body(data). - Do(context.TODO()). + Do(ctx). Into(result) return result, err } diff --git a/staging/src/k8s.io/client-go/util/certificate/certificate_manager_test.go b/staging/src/k8s.io/client-go/util/certificate/certificate_manager_test.go index 96650adcdc5..b68b7b601a8 100644 --- a/staging/src/k8s.io/client-go/util/certificate/certificate_manager_test.go +++ b/staging/src/k8s.io/client-go/util/certificate/certificate_manager_test.go @@ -18,6 +18,7 @@ package certificate import ( "bytes" + "context" "crypto/tls" "crypto/x509" "crypto/x509/pkix" @@ -996,7 +997,7 @@ type fakeClient struct { err error } -func (c fakeClient) List(opts v1.ListOptions) (*certificates.CertificateSigningRequestList, error) { +func (c fakeClient) List(_ context.Context, opts v1.ListOptions) (*certificates.CertificateSigningRequestList, error) { if c.failureType == watchError { if c.err != nil { return nil, c.err @@ -1011,7 +1012,7 @@ func (c fakeClient) List(opts v1.ListOptions) (*certificates.CertificateSigningR return &csrReply, nil } -func (c fakeClient) Create(*certificates.CertificateSigningRequest) (*certificates.CertificateSigningRequest, error) { +func (c fakeClient) Create(context.Context, *certificates.CertificateSigningRequest) (*certificates.CertificateSigningRequest, error) { if c.failureType == createError { if c.err != nil { return nil, c.err @@ -1023,7 +1024,7 @@ func (c fakeClient) Create(*certificates.CertificateSigningRequest) (*certificat return &csrReply, nil } -func (c fakeClient) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c fakeClient) Watch(_ context.Context, opts v1.ListOptions) (watch.Interface, error) { if c.failureType == watchError { if c.err != nil { return nil, c.err diff --git a/staging/src/k8s.io/cloud-provider/node/helpers/conditions.go b/staging/src/k8s.io/cloud-provider/node/helpers/conditions.go index d96e751520f..93500075201 100644 --- a/staging/src/k8s.io/cloud-provider/node/helpers/conditions.go +++ b/staging/src/k8s.io/cloud-provider/node/helpers/conditions.go @@ -17,6 +17,7 @@ limitations under the License. package helpers import ( + "context" "encoding/json" "time" @@ -51,6 +52,6 @@ func SetNodeCondition(c clientset.Interface, node types.NodeName, condition v1.N if err != nil { return err } - _, err = c.CoreV1().Nodes().PatchStatus(string(node), patch) + _, err = c.CoreV1().Nodes().PatchStatus(context.TODO(), string(node), patch) return err } diff --git a/test/e2e_node/BUILD b/test/e2e_node/BUILD index a3eaf21d393..29d740a2a97 100644 --- a/test/e2e_node/BUILD +++ b/test/e2e_node/BUILD @@ -54,7 +54,6 @@ go_library( "//vendor/github.com/coreos/go-systemd/util:go_default_library", "//vendor/github.com/onsi/ginkgo:go_default_library", "//vendor/github.com/onsi/gomega:go_default_library", - "//vendor/golang.org/x/net/context:go_default_library", "//vendor/k8s.io/klog:go_default_library", ] + select({ "@io_bazel_rules_go//go/platform:android": [ diff --git a/test/e2e_node/util.go b/test/e2e_node/util.go index d7f844d264a..73721bb7bad 100644 --- a/test/e2e_node/util.go +++ b/test/e2e_node/util.go @@ -28,8 +28,6 @@ import ( "strings" "time" - "golang.org/x/net/context" - v1 "k8s.io/api/core/v1" apiequality "k8s.io/apimachinery/pkg/api/equality" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"