-
Notifications
You must be signed in to change notification settings - Fork 916
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Poor12 <shentiecheng@huawei.com>
- Loading branch information
Poor12
committed
Apr 27, 2023
1 parent
0f84dd7
commit 6c33e76
Showing
5 changed files
with
246 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
pkg/scheduler/framework/plugins/clustereviction/cluster_eviction.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package clustereviction | ||
|
||
import ( | ||
"context" | ||
|
||
"k8s.io/klog/v2" | ||
|
||
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/helper" | ||
) | ||
|
||
const ( | ||
// Name is the name of the plugin used in the plugin registry and configurations. | ||
Name = "ClusterEviction" | ||
) | ||
|
||
// ClusterEviction is a plugin that checks if the target cluster is in the GracefulEvictionTasks which means it has been evicted. | ||
type ClusterEviction struct{} | ||
|
||
var _ framework.FilterPlugin = &ClusterEviction{} | ||
|
||
// New instantiates the APIEnablement plugin. | ||
func New() (framework.Plugin, error) { | ||
return &ClusterEviction{}, nil | ||
} | ||
|
||
// Name returns the plugin name. | ||
func (p *ClusterEviction) Name() string { | ||
return Name | ||
} | ||
|
||
// Filter checks if the target cluster is in the GracefulEvictionTasks which means it has been evicted. | ||
func (p *ClusterEviction) Filter(_ context.Context, bindingSpec *workv1alpha2.ResourceBindingSpec, _ *workv1alpha2.ResourceBindingStatus, cluster *clusterv1alpha1.Cluster) *framework.Result { | ||
if helper.CheckIfClusterEvicted(bindingSpec.GracefulEvictionTasks, cluster.Name) { | ||
klog.V(2).Infof("Cluster(%s) has been evicted before.", cluster.Name) | ||
return framework.NewResult(framework.Unschedulable, "cluster(s) has been evicted before") | ||
} | ||
|
||
return framework.NewResult(framework.Success) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters