From 8e1e16e95081d7431852c6a46ea372ff79a50b5e Mon Sep 17 00:00:00 2001 From: changzhen Date: Tue, 19 Oct 2021 21:02:55 +0800 Subject: [PATCH] adapt the Scheduled condition for binding Signed-off-by: changzhen --- pkg/scheduler/scheduler.go | 5 +++-- test/e2e/failover_test.go | 9 +++++---- test/e2e/fieldselector_test.go | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/scheduler/scheduler.go b/pkg/scheduler/scheduler.go index a119a76fb657..2bbdd60c571f 100644 --- a/pkg/scheduler/scheduler.go +++ b/pkg/scheduler/scheduler.go @@ -36,6 +36,7 @@ import ( "github.com/karmada-io/karmada/pkg/scheduler/framework/plugins/tainttoleration" "github.com/karmada-io/karmada/pkg/scheduler/metrics" "github.com/karmada-io/karmada/pkg/util" + "github.com/karmada-io/karmada/pkg/util/helper" ) // ScheduleType defines the schedule type of a binding object should be performed. @@ -811,7 +812,7 @@ func (s *Scheduler) getTypeFromResourceBindings(ns, name string) ScheduleType { return Unknown } - if len(resourceBinding.Spec.Clusters) == 0 { + if !helper.IsBindingReady(&resourceBinding.Status) { return FirstSchedule } @@ -842,7 +843,7 @@ func (s *Scheduler) getTypeFromClusterResourceBindings(name string) ScheduleType return Unknown } - if len(binding.Spec.Clusters) == 0 { + if !helper.IsBindingReady(&binding.Status) { return FirstSchedule } diff --git a/test/e2e/failover_test.go b/test/e2e/failover_test.go index 4bf847763a96..6a9f1a384a00 100644 --- a/test/e2e/failover_test.go +++ b/test/e2e/failover_test.go @@ -20,8 +20,9 @@ import ( policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" workv1alpha2 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2" "github.com/karmada-io/karmada/pkg/util" + "github.com/karmada-io/karmada/pkg/util/helper" "github.com/karmada-io/karmada/pkg/util/names" - "github.com/karmada-io/karmada/test/helper" + testhelper "github.com/karmada-io/karmada/test/helper" ) // failover testing is used to test the rescheduling situation when some initially scheduled clusters fail @@ -32,7 +33,7 @@ var _ = ginkgo.Describe("failover testing", func() { policyName := deploymentNamePrefix + rand.String(RandomStrLength) deploymentNamespace := testNamespace deploymentName := policyName - deployment := helper.NewDeployment(deploymentNamespace, deploymentName) + deployment := testhelper.NewDeployment(deploymentNamespace, deploymentName) maxGroups := 1 minGroups := 1 numOfFailedClusters := 1 @@ -41,7 +42,7 @@ var _ = ginkgo.Describe("failover testing", func() { var targetClusterNames []string // set MaxGroups=MinGroups=1, label is location=CHN. - policy := helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{ + policy := testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{ { APIVersion: deployment.APIVersion, Kind: deployment.Kind, @@ -250,7 +251,7 @@ func getTargetClusterNames(deployment *appsv1.Deployment) (targetClusterNames [] return false, err } - if len(binding.Spec.Clusters) == 0 { + if !helper.IsBindingReady(&binding.Status) { klog.Infof("The ResourceBinding(%s/%s) hasn't been scheduled.", binding.Namespace, binding.Name) return false, nil } diff --git a/test/e2e/fieldselector_test.go b/test/e2e/fieldselector_test.go index 0c36fa2405bd..2281f59abccf 100644 --- a/test/e2e/fieldselector_test.go +++ b/test/e2e/fieldselector_test.go @@ -75,7 +75,7 @@ var _ = ginkgo.Describe("propagation with fieldSelector testing", func() { if index > 2 { break } - fmt.Printf("setting provider and region for cluster %v", cluster) + fmt.Printf("setting provider and region for cluster %v\n", cluster) gomega.Eventually(func() error { clusterObj := &clusterv1alpha1.Cluster{} err := controlPlaneClient.Get(context.TODO(), client.ObjectKey{Name: cluster}, clusterObj)