Skip to content

Commit

Permalink
fix binpacking log to show proper node quantity and pods (#825)
Browse files Browse the repository at this point in the history
* fix binpacking log to show proper node quantity and pods

* crash on hash error since it shouldn't ever happen

* replace panic with fatal log

* add error to fatal log
  • Loading branch information
bwagner5 authored Nov 23, 2021
1 parent 6ab36af commit 568e82e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions pkg/controllers/provisioning/binpacking/packer.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,19 @@ func (p *Packer) Pack(ctx context.Context, schedule *scheduling.Schedule, instan
continue
}
key, err := hashstructure.Hash(packing, hashstructure.FormatV2, &hashstructure.HashOptions{SlicesAsSets: true})
if err == nil {
if mainPack, ok := packs[key]; ok {
mainPack.NodeQuantity++
mainPack.Pods = append(mainPack.Pods, packing.Pods...)
continue
} else {
packs[key] = packing
}
if err != nil {
logging.FromContext(ctx).Fatalf("Unable to hash packings while binpacking: %s", err.Error())
}
if mainPack, ok := packs[key]; ok {
mainPack.NodeQuantity++
mainPack.Pods = append(mainPack.Pods, packing.Pods...)
continue
}
packs[key] = packing
packings = append(packings, packing)
logging.FromContext(ctx).Infof("Computed packing of %d nodes for %d pod(s) with instance type option(s) %s", packing.NodeQuantity, flattenedLen(packing.Pods...), instanceTypeNames(packing.InstanceTypeOptions))
}
for _, pack := range packings {
logging.FromContext(ctx).Infof("Computed packing of %d node(s) for %d pod(s) with instance type option(s) %s", pack.NodeQuantity, flattenedLen(pack.Pods...), instanceTypeNames(pack.InstanceTypeOptions))
}
return packings
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/provisioning/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,6 @@ func (s *Scheduler) Register(_ context.Context, m manager.Manager) error {
NewControllerManagedBy(m).
Named("scheduling").
For(&v1.Pod{}).
WithOptions(controller.Options{MaxConcurrentReconciles: 10000}).
WithOptions(controller.Options{MaxConcurrentReconciles: 10_000}).
Complete(s)
}

0 comments on commit 568e82e

Please sign in to comment.