From d8abacba40a63395cc064452b09a244555536fca Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Fri, 6 Mar 2020 16:29:23 -0500 Subject: [PATCH] client-go: update expansions callers --- pkg/controller/certificates/approver/sarapprove.go | 2 +- .../certificates/certificate_controller_test.go | 3 ++- .../deletion/namespaced_resources_deleter.go | 2 +- .../plugins/defaultbinder/default_binder.go | 2 +- .../kubectl/pkg/cmd/certificates/certificates.go | 3 ++- staging/src/k8s.io/kubectl/pkg/drain/drain.go | 2 +- test/e2e/apps/disruption.go | 12 ++++++------ test/e2e/auth/certificates.go | 2 +- test/e2e/storage/pd.go | 2 +- test/integration/auth/node_test.go | 4 ++-- .../certificates/admission_approval_test.go | 2 +- test/integration/evictions/evictions_test.go | 6 +++--- test/integration/scheduler/extender_test.go | 2 +- test/integration/scheduler/framework_test.go | 4 ++-- 14 files changed, 25 insertions(+), 23 deletions(-) diff --git a/pkg/controller/certificates/approver/sarapprove.go b/pkg/controller/certificates/approver/sarapprove.go index 1273ee0ddc2..7ab7aff1112 100644 --- a/pkg/controller/certificates/approver/sarapprove.go +++ b/pkg/controller/certificates/approver/sarapprove.go @@ -100,7 +100,7 @@ func (a *sarApprover) handle(csr *capi.CertificateSigningRequest) error { } if approved { appendApprovalCondition(csr, r.successMessage) - _, err = a.client.CertificatesV1beta1().CertificateSigningRequests().UpdateApproval(csr) + _, err = a.client.CertificatesV1beta1().CertificateSigningRequests().UpdateApproval(context.Background(), csr, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("error updating approval for csr: %v", err) } diff --git a/pkg/controller/certificates/certificate_controller_test.go b/pkg/controller/certificates/certificate_controller_test.go index 566e8d05351..7d3129d7193 100644 --- a/pkg/controller/certificates/certificate_controller_test.go +++ b/pkg/controller/certificates/certificate_controller_test.go @@ -17,6 +17,7 @@ limitations under the License. package certificates import ( + "context" "testing" "time" @@ -47,7 +48,7 @@ func TestCertificateController(t *testing.T) { Reason: "test reason", Message: "test message", }) - _, err := client.CertificatesV1beta1().CertificateSigningRequests().UpdateApproval(csr) + _, err := client.CertificatesV1beta1().CertificateSigningRequests().UpdateApproval(context.TODO(), csr, metav1.UpdateOptions{}) if err != nil { return err } diff --git a/pkg/controller/namespace/deletion/namespaced_resources_deleter.go b/pkg/controller/namespace/deletion/namespaced_resources_deleter.go index 5d173ce3165..28ac0b3660e 100644 --- a/pkg/controller/namespace/deletion/namespaced_resources_deleter.go +++ b/pkg/controller/namespace/deletion/namespaced_resources_deleter.go @@ -292,7 +292,7 @@ func (d *namespacedResourcesDeleter) finalizeNamespace(namespace *v1.Namespace) for _, value := range finalizerSet.List() { namespaceFinalize.Spec.Finalizers = append(namespaceFinalize.Spec.Finalizers, v1.FinalizerName(value)) } - namespace, err := d.nsClient.Finalize(&namespaceFinalize) + namespace, err := d.nsClient.Finalize(context.Background(), &namespaceFinalize, metav1.UpdateOptions{}) if err != nil { // it was removed already, so life is good if errors.IsNotFound(err) { diff --git a/pkg/scheduler/framework/plugins/defaultbinder/default_binder.go b/pkg/scheduler/framework/plugins/defaultbinder/default_binder.go index 7ce88d296f5..73525b17052 100644 --- a/pkg/scheduler/framework/plugins/defaultbinder/default_binder.go +++ b/pkg/scheduler/framework/plugins/defaultbinder/default_binder.go @@ -53,7 +53,7 @@ func (b DefaultBinder) Bind(ctx context.Context, state *framework.CycleState, p ObjectMeta: metav1.ObjectMeta{Namespace: p.Namespace, Name: p.Name, UID: p.UID}, Target: v1.ObjectReference{Kind: "Node", Name: nodeName}, } - err := b.handle.ClientSet().CoreV1().Pods(binding.Namespace).Bind(binding) + err := b.handle.ClientSet().CoreV1().Pods(binding.Namespace).Bind(context.TODO(), binding, metav1.CreateOptions{}) if err != nil { return framework.NewStatus(framework.Error, err.Error()) } diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/certificates/certificates.go b/staging/src/k8s.io/kubectl/pkg/cmd/certificates/certificates.go index 9bd539b5f19..9c652051dc3 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/certificates/certificates.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/certificates/certificates.go @@ -17,6 +17,7 @@ limitations under the License. package certificates import ( + "context" "fmt" "io" @@ -234,7 +235,7 @@ func (o *CertificateOptions) modifyCertificateCondition(builder *resource.Builde csr := info.Object.(*certificatesv1beta1.CertificateSigningRequest) csr, hasCondition := modify(csr) if !hasCondition || force { - _, err = clientSet.CertificateSigningRequests().UpdateApproval(csr) + _, err = clientSet.CertificateSigningRequests().UpdateApproval(context.TODO(), csr, metav1.UpdateOptions{}) if errors.IsConflict(err) && i < 10 { if err := info.Get(); err != nil { return err diff --git a/staging/src/k8s.io/kubectl/pkg/drain/drain.go b/staging/src/k8s.io/kubectl/pkg/drain/drain.go index 225c0fcedac..9c203668f78 100644 --- a/staging/src/k8s.io/kubectl/pkg/drain/drain.go +++ b/staging/src/k8s.io/kubectl/pkg/drain/drain.go @@ -165,7 +165,7 @@ func (d *Helper) EvictPod(pod corev1.Pod, policyGroupVersion string) error { } // Remember to change change the URL manipulation func when Eviction's version change - return d.Client.PolicyV1beta1().Evictions(eviction.Namespace).Evict(eviction) + return d.Client.PolicyV1beta1().Evictions(eviction.Namespace).Evict(context.TODO(), eviction) } // GetPodsForDeletion receives resource info for a node, and returns those pods as PodDeleteList, diff --git a/test/e2e/apps/disruption.go b/test/e2e/apps/disruption.go index c448869f9a6..22a8856fbb1 100644 --- a/test/e2e/apps/disruption.go +++ b/test/e2e/apps/disruption.go @@ -246,7 +246,7 @@ var _ = SIGDescribe("DisruptionController", func() { } if c.shouldDeny { - err = cs.CoreV1().Pods(ns).Evict(e) + err = cs.CoreV1().Pods(ns).Evict(context.TODO(), e) gomega.Expect(err).Should(gomega.MatchError("Cannot evict pod as it would violate the pod's disruption budget.")) } else { // Only wait for running pods in the "allow" case @@ -257,7 +257,7 @@ var _ = SIGDescribe("DisruptionController", func() { // Since disruptionAllowed starts out false, if an eviction is ever allowed, // that means the controller is working. err = wait.PollImmediate(framework.Poll, timeout, func() (bool, error) { - err = cs.CoreV1().Pods(ns).Evict(e) + err = cs.CoreV1().Pods(ns).Evict(context.TODO(), e) if err != nil { return false, nil } @@ -284,7 +284,7 @@ var _ = SIGDescribe("DisruptionController", func() { Namespace: ns, }, } - err = cs.CoreV1().Pods(ns).Evict(e) + err = cs.CoreV1().Pods(ns).Evict(context.TODO(), e) gomega.Expect(err).Should(gomega.MatchError("Cannot evict pod as it would violate the pod's disruption budget.")) ginkgo.By("Updating the pdb to allow a pod to be evicted") @@ -297,7 +297,7 @@ var _ = SIGDescribe("DisruptionController", func() { ginkgo.By("Trying to evict the same pod we tried earlier which should now be evictable") waitForPodsOrDie(cs, ns, 3) waitForPdbToObserveHealthyPods(cs, ns, 3) - err = cs.CoreV1().Pods(ns).Evict(e) + err = cs.CoreV1().Pods(ns).Evict(context.TODO(), e) framework.ExpectNoError(err) // the eviction is now allowed ginkgo.By("Patching the pdb to disallow a pod to be evicted") @@ -319,7 +319,7 @@ var _ = SIGDescribe("DisruptionController", func() { Namespace: ns, }, } - err = cs.CoreV1().Pods(ns).Evict(e) + err = cs.CoreV1().Pods(ns).Evict(context.TODO(), e) gomega.Expect(err).Should(gomega.MatchError("Cannot evict pod as it would violate the pod's disruption budget.")) ginkgo.By("Deleting the pdb to allow a pod to be evicted") @@ -327,7 +327,7 @@ var _ = SIGDescribe("DisruptionController", func() { ginkgo.By("Trying to evict the same pod we tried earlier which should now be evictable") waitForPodsOrDie(cs, ns, 3) - err = cs.CoreV1().Pods(ns).Evict(e) + err = cs.CoreV1().Pods(ns).Evict(context.TODO(), e) framework.ExpectNoError(err) // the eviction is now allowed }) diff --git a/test/e2e/auth/certificates.go b/test/e2e/auth/certificates.go index a426e929abd..78b493c0479 100644 --- a/test/e2e/auth/certificates.go +++ b/test/e2e/auth/certificates.go @@ -82,7 +82,7 @@ var _ = SIGDescribe("Certificates API", func() { Message: "Set from an e2e test", }, } - csr, err = csrs.UpdateApproval(csr) + csr, err = csrs.UpdateApproval(context.TODO(), csr, metav1.UpdateOptions{}) if err != nil { csr, _ = csrs.Get(context.TODO(), csrName, metav1.GetOptions{}) framework.Logf("err updating approval: %v", err) diff --git a/test/e2e/storage/pd.go b/test/e2e/storage/pd.go index b6638fd5808..732b31d2a75 100644 --- a/test/e2e/storage/pd.go +++ b/test/e2e/storage/pd.go @@ -430,7 +430,7 @@ var _ = utils.SIGDescribe("Pod Disks", func() { } ginkgo.By("evicting host0Pod") err = wait.PollImmediate(framework.Poll, podEvictTimeout, func() (bool, error) { - if err := cs.CoreV1().Pods(ns).Evict(evictTarget); err != nil { + if err := cs.CoreV1().Pods(ns).Evict(context.TODO(), evictTarget); err != nil { framework.Logf("Failed to evict host0Pod, ignoring error: %v", err) return false, nil } diff --git a/test/integration/auth/node_test.go b/test/integration/auth/node_test.go index 834dbd676dc..d978c065a40 100644 --- a/test/integration/auth/node_test.go +++ b/test/integration/auth/node_test.go @@ -295,7 +295,7 @@ func TestNodeAuthorizer(t *testing.T) { createNode2NormalPodEviction := func(client clientset.Interface) func() error { return func() error { zero := int64(0) - return client.PolicyV1beta1().Evictions("ns").Evict(&policy.Eviction{ + return client.PolicyV1beta1().Evictions("ns").Evict(context.TODO(), &policy.Eviction{ TypeMeta: metav1.TypeMeta{ APIVersion: "policy/v1beta1", Kind: "Eviction", @@ -311,7 +311,7 @@ func TestNodeAuthorizer(t *testing.T) { createNode2MirrorPodEviction := func(client clientset.Interface) func() error { return func() error { zero := int64(0) - return client.PolicyV1beta1().Evictions("ns").Evict(&policy.Eviction{ + return client.PolicyV1beta1().Evictions("ns").Evict(context.TODO(), &policy.Eviction{ TypeMeta: metav1.TypeMeta{ APIVersion: "policy/v1beta1", Kind: "Eviction", diff --git a/test/integration/certificates/admission_approval_test.go b/test/integration/certificates/admission_approval_test.go index eb30adf9412..57d566833d8 100644 --- a/test/integration/certificates/admission_approval_test.go +++ b/test/integration/certificates/admission_approval_test.go @@ -77,7 +77,7 @@ func TestCSRSignerNameApprovalPlugin(t *testing.T) { Reason: "AutoApproved", Message: "Approved during integration test", }) - _, err := testuserClient.CertificatesV1beta1().CertificateSigningRequests().UpdateApproval(csr) + _, err := testuserClient.CertificatesV1beta1().CertificateSigningRequests().UpdateApproval(context.TODO(), csr, metav1.UpdateOptions{}) if err != nil && test.error != err.Error() { t.Errorf("expected error %q but got: %v", test.error, err) } diff --git a/test/integration/evictions/evictions_test.go b/test/integration/evictions/evictions_test.go index d3e631fe40f..841fbaacbb2 100644 --- a/test/integration/evictions/evictions_test.go +++ b/test/integration/evictions/evictions_test.go @@ -27,7 +27,7 @@ import ( "testing" "time" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "k8s.io/api/policy/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -113,7 +113,7 @@ func TestConcurrentEvictionRequests(t *testing.T) { eviction := newEviction(ns.Name, podName, deleteOption) err := wait.PollImmediate(5*time.Second, 60*time.Second, func() (bool, error) { - e := clientSet.PolicyV1beta1().Evictions(ns.Name).Evict(eviction) + e := clientSet.PolicyV1beta1().Evictions(ns.Name).Evict(context.TODO(), eviction) switch { case apierrors.IsTooManyRequests(e): return false, nil @@ -221,7 +221,7 @@ func TestTerminalPodEviction(t *testing.T) { oldPdb := pdbList.Items[0] eviction := newEviction(ns.Name, pod.Name, deleteOption) err = wait.PollImmediate(5*time.Second, 60*time.Second, func() (bool, error) { - e := clientSet.PolicyV1beta1().Evictions(ns.Name).Evict(eviction) + e := clientSet.PolicyV1beta1().Evictions(ns.Name).Evict(context.TODO(), eviction) switch { case apierrors.IsTooManyRequests(e): return false, nil diff --git a/test/integration/scheduler/extender_test.go b/test/integration/scheduler/extender_test.go index 255d29c67e8..b3de3e06262 100644 --- a/test/integration/scheduler/extender_test.go +++ b/test/integration/scheduler/extender_test.go @@ -232,7 +232,7 @@ func (e *Extender) Bind(binding *extenderv1.ExtenderBindingArgs) error { }, } - return e.Client.CoreV1().Pods(b.Namespace).Bind(b) + return e.Client.CoreV1().Pods(b.Namespace).Bind(context.TODO(), b, metav1.CreateOptions{}) } func machine1_2_3Predicate(pod *v1.Pod, node *v1.Node) (bool, error) { diff --git a/test/integration/scheduler/framework_test.go b/test/integration/scheduler/framework_test.go index 928c8ce8511..517001c312c 100644 --- a/test/integration/scheduler/framework_test.go +++ b/test/integration/scheduler/framework_test.go @@ -301,13 +301,13 @@ func (bp *BindPlugin) Bind(ctx context.Context, state *framework.CycleState, p * bp.pluginInvokeEventChan <- pluginInvokeEvent{pluginName: bp.Name(), val: bp.numBindCalled} } if bp.bindStatus.IsSuccess() { - if err := bp.client.CoreV1().Pods(p.Namespace).Bind(&v1.Binding{ + if err := bp.client.CoreV1().Pods(p.Namespace).Bind(context.TODO(), &v1.Binding{ ObjectMeta: metav1.ObjectMeta{Namespace: p.Namespace, Name: p.Name, UID: p.UID, Annotations: map[string]string{bindPluginAnnotation: bp.Name()}}, Target: v1.ObjectReference{ Kind: "Node", Name: nodeName, }, - }); err != nil { + }, metav1.CreateOptions{}); err != nil { return framework.NewStatus(framework.Error, fmt.Sprintf("bind failed: %v", err)) } }