From 9ddbaafa6e6ce1e1f7b07a096f560a3fafcbe463 Mon Sep 17 00:00:00 2001 From: Rohith Jayawardene Date: Sat, 31 Aug 2024 09:23:27 +0100 Subject: [PATCH] feat: removing the limitation by default and placing the decision on the administrator as to limits --- cmd/controller/main.go | 4 ++-- pkg/assets/job.yaml.tpl | 6 ++++++ pkg/controller/configuration/controller.go | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/controller/main.go b/cmd/controller/main.go index d0c37eb46..b29c5e6f9 100644 --- a/cmd/controller/main.go +++ b/cmd/controller/main.go @@ -76,9 +76,9 @@ func main() { flags.IntVar(&config.WebhookPort, "webhooks-port", 10081, "The port the webhook endpoint binds to") flags.StringSliceVar(&config.ExecutorSecrets, "executor-secret", []string{}, "Name of a secret in controller namespace which should be added to the job") flags.StringVar(&config.ExecutorMemoryRequest, "executor-memory-request", "32Mi", "The default memory request for the executor container") - flags.StringVar(&config.ExecutorMemoryLimit, "executor-memory-limit", "1Gi", "The default memory limit for the executor container") + flags.StringVar(&config.ExecutorMemoryLimit, "executor-memory-limit", "", "The default memory limit for the executor container (default is no limit)") flags.StringVar(&config.ExecutorCPURequest, "executor-cpu-request", "5m", "The default CPU request for the executor container") - flags.StringVar(&config.ExecutorCPULimit, "executor-cpu-limit", "1", "The default CPU limit for the executor container") + flags.StringVar(&config.ExecutorCPULimit, "executor-cpu-limit", "", "The default CPU limit for the executor container (default is no limit)") flags.StringVar(&config.BackendTemplate, "backend-template", "", "Name of secret in the controller namespace containing a template for the terraform state") flags.StringVar(&config.ExecutorImage, "executor-image", fmt.Sprintf("ghcr.io/appvia/terranetes-executor:%s", version.Version), "The image to use for the executor") flags.StringVar(&config.InfracostsImage, "infracost-image", "infracosts/infracost:latest", "The image to use for the infracosts") diff --git a/pkg/assets/job.yaml.tpl b/pkg/assets/job.yaml.tpl index b65604bd6..8ac8dfe7c 100644 --- a/pkg/assets/job.yaml.tpl +++ b/pkg/assets/job.yaml.tpl @@ -259,9 +259,15 @@ spec: optional: false {{- end }} resources: + {{- if or (ne .DefaultExecutorCPULimit "") (ne .DefaultExecutorMemoryLimit "") }} limits: + {{- if ne .DefaultExecutorCPULimit "" }} cpu: {{ .DefaultExecutorCPULimit }} + {{- end }} + {{- if ne .DefaultExecutorMemoryLimit "" }} memory: {{ .DefaultExecutorMemoryLimit }} + {{- end }} + {{- end }} requests: cpu: {{ .DefaultExecutorCPURequest }} memory: {{ .DefaultExecutorMemoryRequest }} diff --git a/pkg/controller/configuration/controller.go b/pkg/controller/configuration/controller.go index 6deca0e2b..da6fb97c5 100644 --- a/pkg/controller/configuration/controller.go +++ b/pkg/controller/configuration/controller.go @@ -177,6 +177,9 @@ func (c *Controller) Add(mgr manager.Manager) error { c.DefaultExecutorMemoryLimit, c.DefaultExecutorMemoryRequest, } { + if c == "" { + continue + } if _, err := resource.ParseQuantity(c); err != nil { return fmt.Errorf("invalid resource quantity: %q, error: %w", c, err) }