avoid the same cluster appearing in both spec.clusters and spec.gracefulEvictionTasks
Signed-off-by: Poor12 <shentiecheng@huawei.com>
This commit is contained in:
parent
2ef01942f1
commit
da44a5d9f9
|
@ -48,6 +48,13 @@ func assessEvictionTasks(bindingSpec workv1alpha2.ResourceBindingSpec,
|
|||
}
|
||||
|
||||
func assessSingleTask(task workv1alpha2.GracefulEvictionTask, opt assessmentOption) *workv1alpha2.GracefulEvictionTask {
|
||||
// avoid the same cluster appearing in both spec.clusters and spec.gracefulEvictionTasks
|
||||
for _, targetCluster := range opt.scheduleResult {
|
||||
if task.FromCluster == targetCluster.Name {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
if task.SuppressDeletion != nil {
|
||||
if *task.SuppressDeletion {
|
||||
return &task
|
||||
|
|
|
@ -210,6 +210,25 @@ func Test_assessSingleTask(t *testing.T) {
|
|||
},
|
||||
want: nil,
|
||||
},
|
||||
{
|
||||
name: "cluster appears both in targetClusters and gracefulEvictionTasks",
|
||||
args: args{
|
||||
task: workv1alpha2.GracefulEvictionTask{
|
||||
FromCluster: "member1",
|
||||
CreationTimestamp: metav1.Time{Time: timeNow.Add(time.Minute * -1)},
|
||||
},
|
||||
opt: assessmentOption{
|
||||
timeout: timeout,
|
||||
scheduleResult: []workv1alpha2.TargetCluster{
|
||||
{Name: "member1"},
|
||||
},
|
||||
observedStatus: []workv1alpha2.AggregatedStatusItem{
|
||||
{ClusterName: "member1", Health: workv1alpha2.ResourceHealthy},
|
||||
},
|
||||
},
|
||||
},
|
||||
want: nil,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue