Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds --max-workers flag to the exec-entrypoint helm command #2607

Merged
merged 4 commits into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/helm/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type WatchOptions struct {
ReconcilePeriod time.Duration
WatchDependentResources bool
OverrideValues map[string]string
MaxWorkers int
}

// Add creates a new helm operator controller and adds it to the manager
Expand All @@ -69,7 +70,10 @@ func Add(mgr manager.Manager, options WatchOptions) error {
mgr.GetScheme().AddKnownTypeWithName(options.GVK, &unstructured.Unstructured{})
metav1.AddToGroupVersion(mgr.GetScheme(), options.GVK.GroupVersion())

c, err := controller.New(controllerName, mgr, controller.Options{Reconciler: r})
c, err := controller.New(controllerName, mgr, controller.Options{
Reconciler: r,
MaxConcurrentReconciles: options.MaxWorkers,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is the same used in Ansible. So it shows great 👍

})
if err != nil {
return err
}
Expand Down
10 changes: 10 additions & 0 deletions pkg/helm/flags/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package flags

import (
"strings"

"github.com/operator-framework/operator-sdk/internal/flags/watch"
"github.com/operator-framework/operator-sdk/pkg/log/zap"
"github.com/spf13/pflag"
Expand All @@ -23,6 +25,7 @@ import (
// HelmOperatorFlags - Options to be used by a helm operator
type HelmOperatorFlags struct {
watch.WatchFlags
MaxWorkers int
}

// AddTo - Add the helm operator flags to the the flagset
Expand All @@ -31,5 +34,12 @@ func AddTo(flagSet *pflag.FlagSet, helpTextPrefix ...string) *HelmOperatorFlags
hof := &HelmOperatorFlags{}
hof.WatchFlags.AddTo(flagSet, helpTextPrefix...)
flagSet.AddFlagSet(zap.FlagSet())
flagSet.IntVar(&hof.MaxWorkers,
"max-workers",
1,
strings.Join(append(helpTextPrefix,
"Maximum number of workers to use."),
" "),
)
return hof
}
1 change: 1 addition & 0 deletions pkg/helm/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func Run(flags *hoflags.HelmOperatorFlags) error {
ReconcilePeriod: flags.ReconcilePeriod,
WatchDependentResources: w.WatchDependentResources,
OverrideValues: w.OverrideValues,
MaxWorkers: flags.MaxWorkers,
})
if err != nil {
log.Error(err, "Failed to add manager factory to controller.")
Expand Down