Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ require (
knative.dev/caching v0.0.0-20220118175933-0c1cc094a7f4
knative.dev/hack v0.0.0-20220118141833-9b2ed8471e30
knative.dev/networking v0.0.0-20220120043934-ec785540a732
knative.dev/pkg v0.0.0-20220118160532-77555ea48cd4
knative.dev/pkg v0.0.0-20220222214439-083dd97300e1
sigs.k8s.io/yaml v1.3.0
)
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2135,8 +2135,9 @@ knative.dev/hack v0.0.0-20220118141833-9b2ed8471e30 h1:UkNpCWCMM5C4AeQ8aTrPTuR/6
knative.dev/hack v0.0.0-20220118141833-9b2ed8471e30/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
knative.dev/networking v0.0.0-20220120043934-ec785540a732 h1:fUUb5NWfYm8TQkhv1uFYlEn91YNKp+E4BD7ax7WYHW0=
knative.dev/networking v0.0.0-20220120043934-ec785540a732/go.mod h1:6cKBV/h/vIQWCPOkds/RvzUmMR8Vz6Dks2NWb0+3xks=
knative.dev/pkg v0.0.0-20220118160532-77555ea48cd4 h1:b9aXVrcfM/ajjHE/lGvlJOHZNAR5FF2TOTLWG7eMhzQ=
knative.dev/pkg v0.0.0-20220118160532-77555ea48cd4/go.mod h1:etVT7Tm8pSDf4RKhGk4r7j/hj3dNBpvT7bO6a6wpahs=
knative.dev/pkg v0.0.0-20220222214439-083dd97300e1 h1:p6MI/Rs9AZC5+qRvqX48njRjmFBYi4Y80q23efgJ+38=
knative.dev/pkg v0.0.0-20220222214439-083dd97300e1/go.mod h1:etVT7Tm8pSDf4RKhGk4r7j/hj3dNBpvT7bO6a6wpahs=
mvdan.cc/gofumpt v0.1.1/go.mod h1:yXG1r1WqZVKWbVRtBWKWX9+CxGYfA51nSomhM0woR48=
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4=
Expand Down
38 changes: 15 additions & 23 deletions vendor/knative.dev/pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

"github.com/google/uuid"
"golang.org/x/sync/errgroup"

"go.uber.org/zap"
"go.uber.org/zap/zapcore"
Expand Down Expand Up @@ -440,6 +441,11 @@ func (c *Impl) EnqueueKeyAfter(key types.NamespacedName, delay time.Duration) {
}
}

// Run runs the controller with it's configured Concurrency
func (c *Impl) Run(ctx context.Context) error {
return c.RunContext(ctx, c.Concurrency)
}

// RunContext starts the controller's worker threads, the number of which is threadiness.
// If the context has been decorated for LeaderElection, then an elector is built and run.
// It then blocks until the context is cancelled, at which point it shuts down its
Expand Down Expand Up @@ -487,19 +493,6 @@ func (c *Impl) RunContext(ctx context.Context, threadiness int) error {
return nil
}

// Run runs the controller.
//
// Deprecated: Use RunContext instead.
func (c *Impl) Run(threadiness int, stopCh <-chan struct{}) error {
// Create a context that is cancelled when the stopCh is called.
ctx, cancel := context.WithCancel(context.Background())
go func() {
<-stopCh
cancel()
}()
return c.RunContext(ctx, threadiness)
}

// processNextWorkItem will read a single work item off the workqueue and
// attempt to process it, by calling Reconcile on our Reconciler.
func (c *Impl) processNextWorkItem() bool {
Expand Down Expand Up @@ -778,18 +771,17 @@ func WaitForCacheSyncQuick(stopCh <-chan struct{}, cacheSyncs ...cache.InformerS
}

// StartAll kicks off all of the passed controllers with DefaultThreadsPerController.
func StartAll(ctx context.Context, controllers ...*Impl) {
wg := sync.WaitGroup{}
func StartAll(ctx context.Context, controllers ...*Impl) error {
eg, egCtx := errgroup.WithContext(ctx)

// Start all of the controllers.
for _, ctrlr := range controllers {
wg.Add(1)
concurrency := ctrlr.Concurrency
go func(c *Impl) {
defer wg.Done()
c.RunContext(ctx, concurrency)
}(ctrlr)
for _, controller := range controllers {
c := controller
eg.Go(func() error {
return c.Run(egCtx)
})
}
wg.Wait()
return eg.Wait()
}

// This is attached to contexts passed to controller constructors to associate
Expand Down
12 changes: 6 additions & 6 deletions vendor/knative.dev/pkg/injection/sharedmain/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import (
"log"
"net/http"
"os"
"strings"
"time"

"github.com/spf13/pflag"

"go.uber.org/automaxprocs/maxprocs" // automatically set GOMAXPROCS based on cgroups
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -120,13 +119,12 @@ var (
// by name.
func MainNamed(ctx context.Context, component string, ctors ...injection.NamedControllerConstructor) {

disabledControllers := pflag.StringSlice("disable-controllers", []string{}, "Comma-separated list of disabled controllers.")
disabledControllers := flag.String("disable-controllers", "", "Comma-separated list of disabled controllers.")

// HACK: This parses flags, so the above should be set once this runs.
cfg := injection.ParseAndGetRESTConfigOrDie()

enabledCtors := enabledControllers(*disabledControllers, ctors)

enabledCtors := enabledControllers(strings.Split(*disabledControllers, ","), ctors)
MainWithConfig(ctx, component, cfg, toControllerConstructors(enabledCtors)...)
}

Expand Down Expand Up @@ -268,7 +266,9 @@ func MainWithConfig(ctx context.Context, component string, cfg *rest.Config, cto
wh.InformersHaveSynced()
}
logger.Info("Starting controllers...")
go controller.StartAll(ctx, controllers...)
eg.Go(func() error {
return controller.StartAll(ctx, controllers...)
})

// This will block until either a signal arrives or one of the grouped functions
// returns an error.
Expand Down
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ knative.dev/networking/pkg/client/injection/reconciler/networking/v1alpha1/serve
knative.dev/networking/pkg/client/listers/networking/v1alpha1
knative.dev/networking/pkg/ingress
knative.dev/networking/pkg/prober
# knative.dev/pkg v0.0.0-20220118160532-77555ea48cd4
# knative.dev/pkg v0.0.0-20220222214439-083dd97300e1
## explicit
knative.dev/pkg/apiextensions/storageversion
knative.dev/pkg/apiextensions/storageversion/cmd/migrate
Expand Down