Skip to content

Commit

Permalink
Merge pull request #5216 from yanfeng1992/fix-apienables
Browse files Browse the repository at this point in the history
skip the filter if the cluster is already in the list of scheduling result even if the API is missed
  • Loading branch information
karmada-bot committed Sep 18, 2024
2 parents 96622c6 + 4c416ce commit ec0521a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkg/scheduler/framework/plugins/apienablement/api_enablement.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package apienablement
import (
"context"

"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/klog/v2"

clusterv1alpha1 "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1"
Expand Down Expand Up @@ -54,10 +55,19 @@ func (p *APIEnablement) Filter(
_ *workv1alpha2.ResourceBindingStatus,
cluster *clusterv1alpha1.Cluster,
) *framework.Result {
if !helper.IsAPIEnabled(cluster.Status.APIEnablements, bindingSpec.Resource.APIVersion, bindingSpec.Resource.Kind) {
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")
if helper.IsAPIEnabled(cluster.Status.APIEnablements, bindingSpec.Resource.APIVersion, bindingSpec.Resource.Kind) {
return framework.NewResult(framework.Success)
}

return framework.NewResult(framework.Success)
// Let the cluster pass if it is already on the list of schedule result and the cluster's
// API enablements is incomplete, to avoid the issue that cluster be accidentally removed
// due to untrusted API enablements.
if bindingSpec.TargetContains(cluster.Name) &&
!meta.IsStatusConditionTrue(cluster.Status.Conditions, clusterv1alpha1.ClusterConditionCompleteAPIEnablements) {
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")
}

0 comments on commit ec0521a

Please sign in to comment.