Migrate deprecated wait.poll
Signed-off-by: Mohammed Affan <mohammed.affan.727@gmail.com>
This commit is contained in:
parent
d4c27937c7
commit
6a07cca040
|
@ -181,7 +181,7 @@ func (c *CertRotationController) syncCertRotation(secret *corev1.Secret) error {
|
||||||
|
|
||||||
var newCertData []byte
|
var newCertData []byte
|
||||||
klog.V(1).Infof("Waiting for the client certificate to be issued")
|
klog.V(1).Infof("Waiting for the client certificate to be issued")
|
||||||
err = wait.Poll(1*time.Second, 5*time.Minute, func() (done bool, err error) {
|
err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 5*time.Minute, false, func(ctx context.Context) (done bool, err error) {
|
||||||
csr, err := c.KubeClient.CertificatesV1().CertificateSigningRequests().Get(context.TODO(), csr, metav1.GetOptions{})
|
csr, err := c.KubeClient.CertificatesV1().CertificateSigningRequests().Get(context.TODO(), csr, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, fmt.Errorf("failed to get the cluster csr %s. err: %v", clusterName, err)
|
return false, fmt.Errorf("failed to get the cluster csr %s. err: %v", clusterName, err)
|
||||||
|
|
|
@ -545,7 +545,7 @@ func (o *CommandRegisterOption) constructKarmadaAgentConfig(bootstrapClient *kub
|
||||||
}
|
}
|
||||||
|
|
||||||
klog.V(1).Infof("Waiting for the client certificate to be issued")
|
klog.V(1).Infof("Waiting for the client certificate to be issued")
|
||||||
err = wait.Poll(1*time.Second, o.Timeout, func() (done bool, err error) {
|
err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, o.Timeout, false, func(ctx context.Context) (done bool, err error) {
|
||||||
csrOK, err := bootstrapClient.CertificatesV1().CertificateSigningRequests().Get(context.TODO(), csrName, metav1.GetOptions{})
|
csrOK, err := bootstrapClient.CertificatesV1().CertificateSigningRequests().Get(context.TODO(), csrName, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, fmt.Errorf("failed to get the cluster csr %s. err: %v", o.ClusterName, err)
|
return false, fmt.Errorf("failed to get the cluster csr %s. err: %v", o.ClusterName, err)
|
||||||
|
|
|
@ -239,7 +239,7 @@ func (j *CommandUnjoinOption) deleteClusterObject(controlPlaneKarmadaClient *kar
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure the given cluster object has been deleted
|
// make sure the given cluster object has been deleted
|
||||||
err = wait.Poll(1*time.Second, j.Wait, func() (done bool, err error) {
|
err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, j.Wait, false, func(ctx context.Context) (done bool, err error) {
|
||||||
_, err = controlPlaneKarmadaClient.ClusterV1alpha1().Clusters().Get(context.TODO(), j.ClusterName, metav1.GetOptions{})
|
_, err = controlPlaneKarmadaClient.ClusterV1alpha1().Clusters().Get(context.TODO(), j.ClusterName, metav1.GetOptions{})
|
||||||
if apierrors.IsNotFound(err) {
|
if apierrors.IsNotFound(err) {
|
||||||
return true, nil
|
return true, nil
|
||||||
|
|
|
@ -91,7 +91,7 @@ func EnsureServiceAccountExist(client kubeclient.Interface, serviceAccountObj *c
|
||||||
// WaitForServiceAccountSecretCreation wait the ServiceAccount's secret has been created.
|
// WaitForServiceAccountSecretCreation wait the ServiceAccount's secret has been created.
|
||||||
func WaitForServiceAccountSecretCreation(client kubeclient.Interface, asObj *corev1.ServiceAccount) (*corev1.Secret, error) {
|
func WaitForServiceAccountSecretCreation(client kubeclient.Interface, asObj *corev1.ServiceAccount) (*corev1.Secret, error) {
|
||||||
var clusterSecret *corev1.Secret
|
var clusterSecret *corev1.Secret
|
||||||
err := wait.Poll(1*time.Second, 30*time.Second, func() (done bool, err error) {
|
err := wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 30*time.Second, false, func(ctx context.Context) (done bool, err error) {
|
||||||
serviceAccount, err := client.CoreV1().ServiceAccounts(asObj.Namespace).Get(context.TODO(), asObj.Name, metav1.GetOptions{})
|
serviceAccount, err := client.CoreV1().ServiceAccounts(asObj.Namespace).Get(context.TODO(), asObj.Name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if apierrors.IsNotFound(err) {
|
if apierrors.IsNotFound(err) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ package e2e
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/onsi/ginkgo/v2"
|
"github.com/onsi/ginkgo/v2"
|
||||||
"github.com/onsi/gomega"
|
"github.com/onsi/gomega"
|
||||||
|
@ -136,6 +137,7 @@ var _ = ginkgo.Describe("[cluster unjoined] reschedule testing", func() {
|
||||||
opts := unjoin.CommandUnjoinOption{
|
opts := unjoin.CommandUnjoinOption{
|
||||||
ClusterNamespace: "karmada-cluster",
|
ClusterNamespace: "karmada-cluster",
|
||||||
ClusterName: newClusterName,
|
ClusterName: newClusterName,
|
||||||
|
Wait: 60 * time.Second,
|
||||||
}
|
}
|
||||||
err := opts.Run(f)
|
err := opts.Run(f)
|
||||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
||||||
|
@ -194,6 +196,7 @@ var _ = ginkgo.Describe("[cluster joined] reschedule testing", func() {
|
||||||
opts := unjoin.CommandUnjoinOption{
|
opts := unjoin.CommandUnjoinOption{
|
||||||
ClusterNamespace: "karmada-cluster",
|
ClusterNamespace: "karmada-cluster",
|
||||||
ClusterName: newClusterName,
|
ClusterName: newClusterName,
|
||||||
|
Wait: 60 * time.Second,
|
||||||
}
|
}
|
||||||
err := opts.Run(f)
|
err := opts.Run(f)
|
||||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
||||||
|
|
Loading…
Reference in New Issue