From 3139924368abe588ded0ac6c35d5b5a8368da9b9 Mon Sep 17 00:00:00 2001 From: wangweizZZ Date: Fri, 23 Feb 2024 11:17:02 +0800 Subject: [PATCH] adjust vg selection strategy Signed-off-by: wangweizZZ --- pkg/mgmt/volume/start.go | 2 +- pkg/mgmt/volume/volume.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/mgmt/volume/start.go b/pkg/mgmt/volume/start.go index c4fdef72..e57a149f 100644 --- a/pkg/mgmt/volume/start.go +++ b/pkg/mgmt/volume/start.go @@ -74,7 +74,7 @@ func Start(controllerMtx *sync.RWMutex, stopCh <-chan struct{}) error { go VolInformerFactory.Start(stopCh) klog.Info("Starting Lvm volume controller") // Threadiness defines the number of workers to be launched in Run function - return controller.Run(2, stopCh) + return controller.Run(1, stopCh) } // GetClusterConfig return the config for k8s. diff --git a/pkg/mgmt/volume/volume.go b/pkg/mgmt/volume/volume.go index 877b79fd..ed23594f 100644 --- a/pkg/mgmt/volume/volume.go +++ b/pkg/mgmt/volume/volume.go @@ -259,9 +259,9 @@ func (c *VolController) getVgPriorityList(vol *apis.LVMVolume) ([]apis.VolumeGro filteredVgs = append(filteredVgs, vg) } - // prioritize the volume group having less free space available. + // prioritize the volume group having most free space available. sort.SliceStable(filteredVgs, func(i, j int) bool { - return filteredVgs[i].Free.Cmp(filteredVgs[j].Free) < 0 + return filteredVgs[i].Free.Cmp(filteredVgs[j].Free) > 0 }) return filteredVgs, nil }