diff --git a/cmd/main.go b/cmd/main.go index c952542e..8199a0fa 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -7,6 +7,7 @@ import ( "time" "github.com/spf13/cobra" + pvcautoresizer "github.com/topolvm/pvc-autoresizer" _ "k8s.io/client-go/plugin/pkg/client/auth" "sigs.k8s.io/controller-runtime/pkg/log/zap" //+kubebuilder:scaffold:imports @@ -25,6 +26,10 @@ var config struct { development bool zapOpts zap.Options pvcMutatingWebhookEnabled bool + defaultThreshold string + defaultInodesThreshold string + defaultIncrease string + defaultLimit string } // rootCmd represents the base command when called without any subcommands @@ -61,6 +66,14 @@ func init() { fs.BoolVar(&config.development, "development", false, "Use development logger config") fs.BoolVar(&config.pvcMutatingWebhookEnabled, "pvc-mutating-webhook-enabled", true, "Enable the pvc mutating webhook endpoint") + fs.StringVar(&config.defaultThreshold, "default-threshold", pvcautoresizer.DefaultThreshold, + "Default value of ResizeThresholdAnnotation") + fs.StringVar(&config.defaultInodesThreshold, "default-inodes-threshold", pvcautoresizer.DefaultInodesThreshold, + "Default value of ResizeInodesThresholdAnnotation") + fs.StringVar(&config.defaultIncrease, "default-increase", pvcautoresizer.DefaultIncrease, + "Default value of ResizeIncreaseAnnotation") + fs.StringVar(&config.defaultLimit, "default-limit", pvcautoresizer.DefaultLimit, + "Default value of StorageLimitAnnotation") goflags := flag.NewFlagSet("zap", flag.ExitOnError) config.zapOpts.BindFlags(goflags) diff --git a/cmd/run.go b/cmd/run.go index 17f3bfa2..b033ce90 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -4,6 +4,7 @@ import ( "net" "time" + pvcautoresizer "github.com/topolvm/pvc-autoresizer" "github.com/topolvm/pvc-autoresizer/internal/hooks" "github.com/topolvm/pvc-autoresizer/internal/runners" corev1 "k8s.io/api/core/v1" @@ -148,6 +149,19 @@ func subMain() error { } } + if config.defaultThreshold != "" { + pvcautoresizer.DefaultThreshold = config.defaultThreshold + } + if config.defaultInodesThreshold != "" { + pvcautoresizer.DefaultInodesThreshold = config.defaultInodesThreshold + } + if config.defaultIncrease != "" { + pvcautoresizer.DefaultIncrease = config.defaultIncrease + } + if config.defaultLimit != "" { + pvcautoresizer.DefaultLimit = config.defaultLimit + } + //+kubebuilder:scaffold:builder setupLog.Info("starting manager") diff --git a/constants.go b/constants.go index 1cbcef3d..87702e15 100644 --- a/constants.go +++ b/constants.go @@ -21,11 +21,16 @@ const PreviousCapacityBytesAnnotation = "resize.topolvm.io/pre_capacity_bytes" // InitialResizeGroupByAnnotation is the key of the initial-resize group by. const InitialResizeGroupByAnnotation = "resize.topolvm.io/initial-resize-group-by" -// DefaultThreshold is the default value of ResizeThresholdAnnotation. -const DefaultThreshold = "10%" +var ( + // DefaultThreshold is the default value of ResizeThresholdAnnotation. + DefaultThreshold = "10%" -// DefaultInodesThreshold is the default value of ResizeInodesThresholdAnnotation. -const DefaultInodesThreshold = "10%" + // DefaultInodesThreshold is the default value of ResizeInodesThresholdAnnotation. + DefaultInodesThreshold = "10%" -// DefaultIncrease is the default value of ResizeIncreaseAnnotation. -const DefaultIncrease = "10%" + // DefaultIncrease is the default value of ResizeIncreaseAnnotation. + DefaultIncrease = "10%" + + // DefaultLimit is the default value of StorageLimitAnnotation. + DefaultLimit = "100Gi" +) diff --git a/internal/runners/pvc_autoresizer.go b/internal/runners/pvc_autoresizer.go index 4334272d..878fd5d1 100644 --- a/internal/runners/pvc_autoresizer.go +++ b/internal/runners/pvc_autoresizer.go @@ -334,5 +334,5 @@ func PvcStorageLimit(pvc *corev1.PersistentVolumeClaim) (resource.Quantity, erro return resource.ParseQuantity(annotation) } - return *resource.NewQuantity(0, resource.BinarySI), nil + return resource.ParseQuantity(pvcautoresizer.DefaultLimit) } diff --git a/test/e2e/suite_test.go b/test/e2e/suite_test.go index 4d4f80de..0ae06fb5 100644 --- a/test/e2e/suite_test.go +++ b/test/e2e/suite_test.go @@ -71,7 +71,7 @@ func TestMtest(t *testing.T) { RegisterFailHandler(Fail) SetDefaultEventuallyPollingInterval(time.Second) - SetDefaultEventuallyTimeout(5 * time.Minute) + SetDefaultEventuallyTimeout(10 * time.Minute) RunSpecs(t, "Test on sanity") }