Skip to content

Commit

Permalink
fix golint and unittest
Browse files Browse the repository at this point in the history
Signed-off-by: AiRanthem <[email protected]>
  • Loading branch information
AiRanthem committed Sep 4, 2024
1 parent 4a03b42 commit 48f50fd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/controller/uniteddeployment/uniteddeployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,23 @@ func (r *ReconcileUnitedDeployment) Reconcile(_ context.Context, request reconci
// "apps.kruise.io/subset-reallocate" = "true";
// 2. During this Reconcile, a previously schedulable subset is found to have
// just become unschedulable, which means UnschedulableTimestamp is nil
nextReplicas := &map[string]int32{}
reallocate := instance.Annotations[appsv1alpha1.AnnotationReallocate] == "true"
var nextReplicas *map[string]int32
var reallocate bool
if annotation, ok := instance.Annotations[appsv1alpha1.AnnotationReallocate]; ok {
reallocate = annotation == "true"
} else {
// if the webhook is running, this branch is never entered.
// this branch is reserved for unit tests without a webhook running.
reallocate = true
}
for name, subset := range *nameToSubset {
if status := subset.Status.UnschedulableStatus; status.Unschedulable && status.UnschedulableTimestamp == nil {
klog.InfoS("new unschedulable subset discovered, should reallocate", "name", name)
reallocate = true
}
}
if reallocate {
klog.Info("reallocate subset replicas for spec is changed")
klog.Info("reallocate subset replicas for spec is changed or new unschedulable subset found")
nextReplicas, err = NewReplicaAllocator(instance).Alloc(nameToSubset)
if err != nil {
klog.ErrorS(err, "UnitedDeployment specified subset replicas is ineffective", "unitedDeployment", klog.KObj(instance))
Expand Down

0 comments on commit 48f50fd

Please sign in to comment.