Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #67 from ulucinar/fix-check
Browse files Browse the repository at this point in the history
Pass maximum concurrent reconciles options to generated controllers
  • Loading branch information
ulucinar authored Sep 17, 2021
2 parents 03b092f + d6dbdc7 commit 9b4eaff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pkg/pipeline/templates/controller.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

// Setup adds a controller that reconciles {{ .CRD.Kind }} managed resources.
func Setup(mgr ctrl.Manager, l logging.Logger, rl workqueue.RateLimiter) error {
func Setup(mgr ctrl.Manager, l logging.Logger, rl workqueue.RateLimiter, concurrency int) error {
name := managed.ControllerName({{ .TypePackageAlias }}{{ .CRD.Kind }}GroupVersionKind.String())
r := managed.NewReconciler(mgr,
xpresource.ManagedKind({{ .TypePackageAlias }}{{ .CRD.Kind }}GroupVersionKind),
Expand All @@ -30,7 +30,7 @@ func Setup(mgr ctrl.Manager, l logging.Logger, rl workqueue.RateLimiter) error {

return ctrl.NewControllerManagedBy(mgr).
Named(name).
WithOptions(controller.Options{RateLimiter: rl}).
WithOptions(controller.Options{RateLimiter: rl, MaxConcurrentReconciles: concurrency}).
For(&{{ .TypePackageAlias }}{{ .CRD.Kind }}{}).
Complete(r)
}
6 changes: 3 additions & 3 deletions pkg/pipeline/templates/setup.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ import (

// Setup creates all controllers with the supplied logger and adds them to
// the supplied manager.
func Setup(mgr ctrl.Manager, l logging.Logger, wl workqueue.RateLimiter) error {
for _, setup := range []func(ctrl.Manager, logging.Logger, workqueue.RateLimiter) error{
func Setup(mgr ctrl.Manager, l logging.Logger, wl workqueue.RateLimiter, concurrency int) error {
for _, setup := range []func(ctrl.Manager, logging.Logger, workqueue.RateLimiter, int) error{
{{- range $alias := .Aliases }}
{{ $alias }}Setup,
{{- end }}
} {
if err := setup(mgr, l, wl); err != nil {
if err := setup(mgr, l, wl, concurrency); err != nil {
return err
}
}
Expand Down
10 changes: 8 additions & 2 deletions pkg/tfcli/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,14 @@ func (c *Client) checkOperation() error {
}
// check if operation timed out if timeout is configured
if c.timeout != nil && xpState.Ts.Before(time.Now()) {
// then async operation has timed out
return c.removeStateStore()
storeExists, err := c.pathExists(filepath.Join(c.wsPath, fileStore), false)
if err != nil {
return err
}
// then async operation has timed out before generating a store file
if !storeExists {
return c.removeStateStore()
}
}
return tferrors.NewOperationInProgressError(xpState.Operation)
}
Expand Down

0 comments on commit 9b4eaff

Please sign in to comment.