mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
some manual fixes
This commit is contained in:
parent
9443a38144
commit
2637772298
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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")
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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))
|
||||
|
@ -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()
|
||||
|
@ -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",
|
||||
],
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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(
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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": [
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user