Skip to content

Commit

Permalink
skip the filter if the cluster is already in the list of scheduling r…
Browse files Browse the repository at this point in the history
…esults and its API enablements are incomplete

Signed-off-by: huangyanfeng <[email protected]>
  • Loading branch information
yanfeng1992 committed Sep 14, 2024
1 parent e76ce63 commit ecc4dc7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
clusterv1alpha1 "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1"
workv1alpha2 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2"
"github.com/karmada-io/karmada/pkg/scheduler/framework"
"github.com/karmada-io/karmada/pkg/util"
"github.com/karmada-io/karmada/pkg/util/helper"
)

Expand Down Expand Up @@ -55,6 +56,10 @@ func (p *APIEnablement) Filter(
cluster *clusterv1alpha1.Cluster,
) *framework.Result {
if !helper.IsAPIEnabled(cluster.Status.APIEnablements, bindingSpec.Resource.APIVersion, bindingSpec.Resource.Kind) {
// skip the filter if the cluster is already in the list of scheduling results and its API enablements are incomplete
if bindingSpec.TargetContains(cluster.Name) && !util.IsClusterCompleteAPIEnablements(&cluster.Status) {
return framework.NewResult(framework.Success)
}
klog.V(2).Infof("Cluster(%s) not fit as missing API(%s, kind=%s)", cluster.Name, bindingSpec.Resource.APIVersion, bindingSpec.Resource.Kind)
return framework.NewResult(framework.Unschedulable, "cluster(s) did not have the API resource")
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/util/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,8 @@ func ClusterAccessCredentialChanged(newSpec, oldSpec clusterv1alpha1.ClusterSpec
}
return true
}

// IsClusterCompleteAPIEnablements tells whether the cluster's API enablements (.status.apiEnablements) is complete.
func IsClusterCompleteAPIEnablements(clusterStatus *clusterv1alpha1.ClusterStatus) bool {
return meta.IsStatusConditionTrue(clusterStatus.Conditions, clusterv1alpha1.ClusterConditionCompleteAPIEnablements)
}

0 comments on commit ecc4dc7

Please sign in to comment.