@@ -19,7 +19,6 @@ package apienablement
19
19
import (
20
20
"context"
21
21
22
- "k8s.io/apimachinery/pkg/api/meta"
23
22
"k8s.io/klog/v2"
24
23
25
24
clusterv1alpha1 "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1"
@@ -55,15 +54,21 @@ func (p *APIEnablement) Filter(
55
54
_ * workv1alpha2.ResourceBindingStatus ,
56
55
cluster * clusterv1alpha1.Cluster ,
57
56
) * framework.Result {
58
- if helper .IsAPIEnabled (cluster .Status .APIEnablements , bindingSpec .Resource .APIVersion , bindingSpec .Resource .Kind ) {
57
+ // If the cluster is already in the target list, always allow it to pass
58
+ // This ensures the scheduler never deletes scheduled resources by this plugin.
59
+ // In case of the required APIs(CRDs) are accidentally deleted from member cluster, Karmada
60
+ // controllers will try recreating these resources once the API becomes available again.
61
+ if bindingSpec .TargetContains (cluster .Name ) {
59
62
return framework .NewResult (framework .Success )
60
63
}
61
64
62
- // Let the cluster pass if it is already on the list of schedule result and the cluster's
63
- // API enablements is incomplete, to avoid the issue that cluster be accidentally removed
64
- // due to untrusted API enablements.
65
- if bindingSpec .TargetContains (cluster .Name ) &&
66
- ! meta .IsStatusConditionTrue (cluster .Status .Conditions , clusterv1alpha1 .ClusterConditionCompleteAPIEnablements ) {
65
+ // For new scheduling decisions, check if the API is enabled to ensure the application
66
+ // is deployed to a cluster that supports all required APIs.
67
+ // Note: Although controllers may not always get the complete API list,
68
+ // we enforce strict checks to maintain consistency. This may occasionally
69
+ // exclude clusters prematurely. Users requiring a specific number of target
70
+ // clusters should use SpreadConstraints(in PropagationPolicy) to meet their requirements.
71
+ if helper .IsAPIEnabled (cluster .Status .APIEnablements , bindingSpec .Resource .APIVersion , bindingSpec .Resource .Kind ) {
67
72
return framework .NewResult (framework .Success )
68
73
}
69
74
0 commit comments