Skip to content

Commit

Permalink
feat: removing the limitation by default and placing the decision on …
Browse files Browse the repository at this point in the history
…the administrator as to limits
  • Loading branch information
gambol99 committed Aug 31, 2024
1 parent 999cb20 commit 9ddbaaf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 6 additions & 0 deletions pkg/assets/job.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/configuration/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 9ddbaaf

Please sign in to comment.