Skip to content

Commit e4a4a47

Browse files
authored
Merge pull request #3906 from Affan-7/cleanup-wait.poll
Migrate deprecated wait.Poll function
2 parents 4c634e7 + 197d335 commit e4a4a47

File tree

5 files changed

+7
-4
lines changed

5 files changed

+7
-4
lines changed

pkg/controllers/certificate/cert_rotation_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func (c *CertRotationController) syncCertRotation(secret *corev1.Secret) error {
181181

182182
var newCertData []byte
183183
klog.V(1).Infof("Waiting for the client certificate to be issued")
184-
err = wait.Poll(1*time.Second, 5*time.Minute, func() (done bool, err error) {
184+
err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 5*time.Minute, false, func(context.Context) (done bool, err error) {
185185
csr, err := c.KubeClient.CertificatesV1().CertificateSigningRequests().Get(context.TODO(), csr, metav1.GetOptions{})
186186
if err != nil {
187187
return false, fmt.Errorf("failed to get the cluster csr %s. err: %v", clusterName, err)

pkg/karmadactl/register/register.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ func (o *CommandRegisterOption) constructKarmadaAgentConfig(bootstrapClient *kub
545545
}
546546

547547
klog.V(1).Infof("Waiting for the client certificate to be issued")
548-
err = wait.Poll(1*time.Second, o.Timeout, func() (done bool, err error) {
548+
err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, o.Timeout, false, func(context.Context) (done bool, err error) {
549549
csrOK, err := bootstrapClient.CertificatesV1().CertificateSigningRequests().Get(context.TODO(), csrName, metav1.GetOptions{})
550550
if err != nil {
551551
return false, fmt.Errorf("failed to get the cluster csr %s. err: %v", o.ClusterName, err)

pkg/karmadactl/unjoin/unjoin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func (j *CommandUnjoinOption) deleteClusterObject(controlPlaneKarmadaClient *kar
239239
}
240240

241241
// make sure the given cluster object has been deleted
242-
err = wait.Poll(1*time.Second, j.Wait, func() (done bool, err error) {
242+
err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, j.Wait, false, func(context.Context) (done bool, err error) {
243243
_, err = controlPlaneKarmadaClient.ClusterV1alpha1().Clusters().Get(context.TODO(), j.ClusterName, metav1.GetOptions{})
244244
if apierrors.IsNotFound(err) {
245245
return true, nil

pkg/util/serviceaccount.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func EnsureServiceAccountExist(client kubeclient.Interface, serviceAccountObj *c
9191
// WaitForServiceAccountSecretCreation wait the ServiceAccount's secret has been created.
9292
func WaitForServiceAccountSecretCreation(client kubeclient.Interface, asObj *corev1.ServiceAccount) (*corev1.Secret, error) {
9393
var clusterSecret *corev1.Secret
94-
err := wait.Poll(1*time.Second, 30*time.Second, func() (done bool, err error) {
94+
err := wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 30*time.Second, false, func(context.Context) (done bool, err error) {
9595
serviceAccount, err := client.CoreV1().ServiceAccounts(asObj.Namespace).Get(context.TODO(), asObj.Name, metav1.GetOptions{})
9696
if err != nil {
9797
if apierrors.IsNotFound(err) {

test/e2e/rescheduling_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package e2e
1919
import (
2020
"fmt"
2121
"os"
22+
"time"
2223

2324
"github.com/onsi/ginkgo/v2"
2425
"github.com/onsi/gomega"
@@ -136,6 +137,7 @@ var _ = ginkgo.Describe("[cluster unjoined] reschedule testing", func() {
136137
opts := unjoin.CommandUnjoinOption{
137138
ClusterNamespace: "karmada-cluster",
138139
ClusterName: newClusterName,
140+
Wait: 60 * time.Second,
139141
}
140142
err := opts.Run(f)
141143
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
@@ -194,6 +196,7 @@ var _ = ginkgo.Describe("[cluster joined] reschedule testing", func() {
194196
opts := unjoin.CommandUnjoinOption{
195197
ClusterNamespace: "karmada-cluster",
196198
ClusterName: newClusterName,
199+
Wait: 60 * time.Second,
197200
}
198201
err := opts.Run(f)
199202
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())

0 commit comments

Comments
 (0)