From f3393fcef3de1025840011c91c3aad7f15b59441 Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 19 Nov 2021 16:46:31 -0600 Subject: [PATCH 1/4] fix binpacking log to show proper node quantity and pods --- pkg/controllers/provisioning/binpacking/packer.go | 14 +++++++++----- pkg/controllers/provisioning/scheduler.go | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/controllers/provisioning/binpacking/packer.go b/pkg/controllers/provisioning/binpacking/packer.go index 578ff5c0909f..77e91684d9ed 100644 --- a/pkg/controllers/provisioning/binpacking/packer.go +++ b/pkg/controllers/provisioning/binpacking/packer.go @@ -93,17 +93,21 @@ 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 err != nil { + logging.FromContext(ctx).Errorf("Hashing packings to determine node batches") + packings = append(packings, packing) + } else { if mainPack, ok := packs[key]; ok { mainPack.NodeQuantity++ mainPack.Pods = append(mainPack.Pods, packing.Pods...) continue - } else { - packs[key] = packing } + packs[key] = packing + packings = append(packings, 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 } diff --git a/pkg/controllers/provisioning/scheduler.go b/pkg/controllers/provisioning/scheduler.go index 5319bfdf07c5..dbdadbddbf1e 100644 --- a/pkg/controllers/provisioning/scheduler.go +++ b/pkg/controllers/provisioning/scheduler.go @@ -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) } From cdf081824d1bb336ed17b55ec7f9bdd01805f83a Mon Sep 17 00:00:00 2001 From: Brandon Date: Sun, 21 Nov 2021 15:22:35 -0600 Subject: [PATCH 2/4] crash on hash error since it shouldn't ever happen --- .../provisioning/binpacking/packer.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/pkg/controllers/provisioning/binpacking/packer.go b/pkg/controllers/provisioning/binpacking/packer.go index 77e91684d9ed..f205e55e1885 100644 --- a/pkg/controllers/provisioning/binpacking/packer.go +++ b/pkg/controllers/provisioning/binpacking/packer.go @@ -94,17 +94,15 @@ func (p *Packer) Pack(ctx context.Context, schedule *scheduling.Schedule, instan } key, err := hashstructure.Hash(packing, hashstructure.FormatV2, &hashstructure.HashOptions{SlicesAsSets: true}) if err != nil { - logging.FromContext(ctx).Errorf("Hashing packings to determine node batches") - packings = append(packings, packing) - } else { - if mainPack, ok := packs[key]; ok { - mainPack.NodeQuantity++ - mainPack.Pods = append(mainPack.Pods, packing.Pods...) - continue - } - packs[key] = packing - packings = append(packings, packing) + panic("Unable to hash packings while binpacking") } + if mainPack, ok := packs[key]; ok { + mainPack.NodeQuantity++ + mainPack.Pods = append(mainPack.Pods, packing.Pods...) + continue + } + packs[key] = packing + packings = append(packings, packing) } 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)) From 3b862554d053c547d7dad1eb042a27b85342247e Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 22 Nov 2021 09:34:11 -0600 Subject: [PATCH 3/4] replace panic with fatal log --- pkg/controllers/provisioning/binpacking/packer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/controllers/provisioning/binpacking/packer.go b/pkg/controllers/provisioning/binpacking/packer.go index f205e55e1885..29e7cf31ba68 100644 --- a/pkg/controllers/provisioning/binpacking/packer.go +++ b/pkg/controllers/provisioning/binpacking/packer.go @@ -94,7 +94,7 @@ func (p *Packer) Pack(ctx context.Context, schedule *scheduling.Schedule, instan } key, err := hashstructure.Hash(packing, hashstructure.FormatV2, &hashstructure.HashOptions{SlicesAsSets: true}) if err != nil { - panic("Unable to hash packings while binpacking") + logging.FromContext(ctx).Fatal("Unable to hash packings while binpacking") } if mainPack, ok := packs[key]; ok { mainPack.NodeQuantity++ From 7fb908114fc6a7635aad9fe426953d5125c535cd Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 22 Nov 2021 12:43:42 -0600 Subject: [PATCH 4/4] add error to fatal log --- pkg/controllers/provisioning/binpacking/packer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/controllers/provisioning/binpacking/packer.go b/pkg/controllers/provisioning/binpacking/packer.go index 29e7cf31ba68..43ea230bee97 100644 --- a/pkg/controllers/provisioning/binpacking/packer.go +++ b/pkg/controllers/provisioning/binpacking/packer.go @@ -94,7 +94,7 @@ func (p *Packer) Pack(ctx context.Context, schedule *scheduling.Schedule, instan } key, err := hashstructure.Hash(packing, hashstructure.FormatV2, &hashstructure.HashOptions{SlicesAsSets: true}) if err != nil { - logging.FromContext(ctx).Fatal("Unable to hash packings while binpacking") + logging.FromContext(ctx).Fatalf("Unable to hash packings while binpacking: %s", err.Error()) } if mainPack, ok := packs[key]; ok { mainPack.NodeQuantity++