Skip to content

Commit c719555

Browse files
authored
Merge pull request #6279 from seanlaii/automated-cherry-pick-of-#6270-upstream-release-1.12
Automated cherry pick of #6270: fix the issue where discovery-timeout fails to work properly
2 parents eb679d9 + e768255 commit c719555

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

pkg/karmadactl/addons/utils/helpers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package utils
1919
import (
2020
"context"
2121
"fmt"
22+
"time"
2223

2324
appsv1 "k8s.io/api/apps/v1"
2425
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -35,7 +36,7 @@ var (
3536
// This blocks until the Deployment's observed generation and ready replicas match the desired state,
3637
// ensuring it is fully rolled out.
3738
WaitForDeploymentRollout = func(c clientset.Interface, dep *appsv1.Deployment, timeoutSeconds int) error {
38-
return cmdutil.WaitForDeploymentRollout(c, dep, timeoutSeconds)
39+
return cmdutil.WaitForDeploymentRollout(c, dep, time.Duration(timeoutSeconds)*time.Second)
3940
}
4041
)
4142

pkg/karmadactl/cmdinit/utils/deploy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package utils
1818

1919
import (
2020
"context"
21+
"time"
2122

2223
appsv1 "k8s.io/api/apps/v1"
2324
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -32,5 +33,5 @@ func CreateDeployAndWait(kubeClientSet kubernetes.Interface, deployment *appsv1.
3233
if _, err := kubeClientSet.AppsV1().Deployments(deployment.GetNamespace()).Create(context.TODO(), deployment, metav1.CreateOptions{}); err != nil {
3334
klog.Warning(err)
3435
}
35-
return util.WaitForDeploymentRollout(kubeClientSet, deployment, waitComponentReadyTimeout)
36+
return util.WaitForDeploymentRollout(kubeClientSet, deployment, time.Duration(waitComponentReadyTimeout)*time.Second)
3637
}

pkg/karmadactl/register/register.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ func (o *CommandRegisterOption) EnsureNecessaryResourcesExistInMemberCluster(boo
461461
return err
462462
}
463463

464-
if err = cmdutil.WaitForDeploymentRollout(o.memberClusterClient, KarmadaAgentDeployment, int(o.Timeout)); err != nil {
464+
if err = cmdutil.WaitForDeploymentRollout(o.memberClusterClient, KarmadaAgentDeployment, o.Timeout); err != nil {
465465
return err
466466
}
467467

pkg/karmadactl/util/check.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ func WaitForStatefulSetRollout(c kubernetes.Interface, sts *appsv1.StatefulSet,
5959
return nil
6060
}
6161

62-
// WaitForDeploymentRollout wait for Deployment reaches the ready state or timeout.
63-
func WaitForDeploymentRollout(c kubernetes.Interface, dep *appsv1.Deployment, timeoutSeconds int) error {
62+
// WaitForDeploymentRollout wait for Deployment reaches the ready state or timeout.
63+
func WaitForDeploymentRollout(c kubernetes.Interface, dep *appsv1.Deployment, timeout time.Duration) error {
6464
var lastErr error
65-
pollError := wait.PollUntilContextTimeout(context.TODO(), time.Second, time.Duration(timeoutSeconds)*time.Second, true, func(ctx context.Context) (bool, error) {
65+
pollError := wait.PollUntilContextTimeout(context.TODO(), time.Second, timeout, true, func(ctx context.Context) (bool, error) {
6666
d, err := c.AppsV1().Deployments(dep.GetNamespace()).Get(ctx, dep.GetName(), metav1.GetOptions{})
6767
if err != nil {
6868
lastErr = err

0 commit comments

Comments
 (0)