Merge pull request #838 from XiShanYongYe-Chang/adapt-scheduled-condition

adapt the Scheduled condition for binding
This commit is contained in:
karmada-bot 2021-10-21 10:59:07 +08:00 committed by GitHub
commit d535f7047c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View File

@ -36,6 +36,7 @@ import (
"github.com/karmada-io/karmada/pkg/scheduler/framework/plugins/tainttoleration" "github.com/karmada-io/karmada/pkg/scheduler/framework/plugins/tainttoleration"
"github.com/karmada-io/karmada/pkg/scheduler/metrics" "github.com/karmada-io/karmada/pkg/scheduler/metrics"
"github.com/karmada-io/karmada/pkg/util" "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. // 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 return Unknown
} }
if len(resourceBinding.Spec.Clusters) == 0 { if !helper.IsBindingReady(&resourceBinding.Status) {
return FirstSchedule return FirstSchedule
} }
@ -842,7 +843,7 @@ func (s *Scheduler) getTypeFromClusterResourceBindings(name string) ScheduleType
return Unknown return Unknown
} }
if len(binding.Spec.Clusters) == 0 { if !helper.IsBindingReady(&binding.Status) {
return FirstSchedule return FirstSchedule
} }

View File

@ -20,8 +20,9 @@ import (
policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
workv1alpha2 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2" workv1alpha2 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2"
"github.com/karmada-io/karmada/pkg/util" "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/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 // 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) policyName := deploymentNamePrefix + rand.String(RandomStrLength)
deploymentNamespace := testNamespace deploymentNamespace := testNamespace
deploymentName := policyName deploymentName := policyName
deployment := helper.NewDeployment(deploymentNamespace, deploymentName) deployment := testhelper.NewDeployment(deploymentNamespace, deploymentName)
maxGroups := 1 maxGroups := 1
minGroups := 1 minGroups := 1
numOfFailedClusters := 1 numOfFailedClusters := 1
@ -41,7 +42,7 @@ var _ = ginkgo.Describe("failover testing", func() {
var targetClusterNames []string var targetClusterNames []string
// set MaxGroups=MinGroups=1, label is location=CHN. // 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, APIVersion: deployment.APIVersion,
Kind: deployment.Kind, Kind: deployment.Kind,
@ -250,7 +251,7 @@ func getTargetClusterNames(deployment *appsv1.Deployment) (targetClusterNames []
return false, err 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) klog.Infof("The ResourceBinding(%s/%s) hasn't been scheduled.", binding.Namespace, binding.Name)
return false, nil return false, nil
} }

View File

@ -75,7 +75,7 @@ var _ = ginkgo.Describe("propagation with fieldSelector testing", func() {
if index > 2 { if index > 2 {
break 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 { gomega.Eventually(func() error {
clusterObj := &clusterv1alpha1.Cluster{} clusterObj := &clusterv1alpha1.Cluster{}
err := controlPlaneClient.Get(context.TODO(), client.ObjectKey{Name: cluster}, clusterObj) err := controlPlaneClient.Get(context.TODO(), client.ObjectKey{Name: cluster}, clusterObj)