diff --git a/go.mod b/go.mod index 031c970e5f8..3eb02af57e4 100644 --- a/go.mod +++ b/go.mod @@ -43,8 +43,8 @@ require ( k8s.io/utils v0.0.0-20201110183641-67b214c5f920 knative.dev/hack v0.0.0-20210622141627-e28525d8d260 knative.dev/hack/schema v0.0.0-20210622141627-e28525d8d260 - knative.dev/pkg v0.0.0-20210622173328-dd0db4b05c80 - knative.dev/reconciler-test v0.0.0-20210623134345-88c84739abd9 + knative.dev/pkg v0.0.0-20210701025203-30f9568e894e + knative.dev/reconciler-test v0.0.0-20210630182710-2a6d91dfee1e sigs.k8s.io/yaml v1.2.0 ) diff --git a/go.sum b/go.sum index 2f7214ea9d5..5a03bbcce2d 100644 --- a/go.sum +++ b/go.sum @@ -1090,10 +1090,11 @@ knative.dev/hack v0.0.0-20210622141627-e28525d8d260 h1:f2eMtOubAOc/Q7JlvFPDKXiPl knative.dev/hack v0.0.0-20210622141627-e28525d8d260/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= knative.dev/hack/schema v0.0.0-20210622141627-e28525d8d260 h1:YkMkZ7qdafyRHNIuKttYzEmM1ilKTGyEtPWeVLcLcDE= knative.dev/hack/schema v0.0.0-20210622141627-e28525d8d260/go.mod h1:ffjwmdcrH5vN3mPhO8RrF2KfNnbHeCE2C60A+2cv3U0= -knative.dev/pkg v0.0.0-20210622173328-dd0db4b05c80 h1:GHJ3lglE0/YHfBMMJqluqUNLOmsNXh7s7DBnfrkpRMM= knative.dev/pkg v0.0.0-20210622173328-dd0db4b05c80/go.mod h1:kGegTnbZ+ljFjAE3E1+8wgaH2LMv8qYi+72o3F3cbdc= -knative.dev/reconciler-test v0.0.0-20210623134345-88c84739abd9 h1:j+ZLX0o1vBxEpTc7J6QT6sSBblQHpZhJP4vxbFe+C5Y= -knative.dev/reconciler-test v0.0.0-20210623134345-88c84739abd9/go.mod h1:4wqv2WyWUC5yhTesRUVwgjv/fHTHny1RYBfdB6tVDok= +knative.dev/pkg v0.0.0-20210701025203-30f9568e894e h1:2TofgD72tjBuWN3a4Rg3uzrMu1OWOlh2KY2m0fsjwqQ= +knative.dev/pkg v0.0.0-20210701025203-30f9568e894e/go.mod h1:kGegTnbZ+ljFjAE3E1+8wgaH2LMv8qYi+72o3F3cbdc= +knative.dev/reconciler-test v0.0.0-20210630182710-2a6d91dfee1e h1:OlvD5NiM8rl3j56NIQfmwSazBffwofQE+XDAt88+BV4= +knative.dev/reconciler-test v0.0.0-20210630182710-2a6d91dfee1e/go.mod h1:4wqv2WyWUC5yhTesRUVwgjv/fHTHny1RYBfdB6tVDok= pgregory.net/rapid v0.3.3 h1:jCjBsY4ln4Atz78QoBWxUEvAHaFyNDQg9+WU62aCn1U= pgregory.net/rapid v0.3.3/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/vendor/knative.dev/pkg/controller/controller.go b/vendor/knative.dev/pkg/controller/controller.go index 9593eef28da..593d00a47db 100644 --- a/vendor/knative.dev/pkg/controller/controller.go +++ b/vendor/knative.dev/pkg/controller/controller.go @@ -57,6 +57,7 @@ var ( // when processing the controller's workqueue. Controller binaries // may adjust this process-wide default. For finer control, invoke // Run on the controller directly. + // TODO rename the const to Concurrency and deprecated this DefaultThreadsPerController = 2 ) @@ -203,6 +204,9 @@ type Impl struct { // which are not required to complete at the highest priority. workQueue *twoLaneQueue + // Concurrency - The number of workers to use when processing the controller's workqueue. + Concurrency int + // Sugared logger is easier to use but is not as performant as the // raw logger. In performance critical paths, call logger.Desugar() // and use the returned raw logger instead. In addition to the @@ -221,6 +225,7 @@ type ControllerOptions struct { //nolint // for backcompat. Logger *zap.SugaredLogger Reporter StatsReporter RateLimiter workqueue.RateLimiter + Concurrency int } // NewImpl instantiates an instance of our controller that will feed work to the @@ -244,12 +249,16 @@ func NewImplFull(r Reconciler, options ControllerOptions) *Impl { if options.Reporter == nil { options.Reporter = MustNewStatsReporter(options.WorkQueueName, options.Logger) } + if options.Concurrency == 0 { + options.Concurrency = DefaultThreadsPerController + } return &Impl{ Name: options.WorkQueueName, Reconciler: r, workQueue: newTwoLaneWorkQueue(options.WorkQueueName, options.RateLimiter), logger: options.Logger, statsReporter: options.Reporter, + Concurrency: options.Concurrency, } } @@ -723,9 +732,10 @@ func StartAll(ctx context.Context, controllers ...*Impl) { // 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, DefaultThreadsPerController) + c.RunContext(ctx, concurrency) }(ctrlr) } wg.Wait() diff --git a/vendor/knative.dev/pkg/controller/options.go b/vendor/knative.dev/pkg/controller/options.go index 8d61835e691..dbacd747996 100644 --- a/vendor/knative.dev/pkg/controller/options.go +++ b/vendor/knative.dev/pkg/controller/options.go @@ -38,6 +38,9 @@ type Options struct { // DemoteFunc configures the demote function this reconciler uses DemoteFunc func(b reconciler.Bucket) + + // Concurrency - The number of workers to use when processing the controller's workqueue. + Concurrency int } // OptionsFn is a callback method signature that accepts an Impl and returns diff --git a/vendor/knative.dev/pkg/injection/sharedmain/main.go b/vendor/knative.dev/pkg/injection/sharedmain/main.go index de49ae1a8c5..8cc6fb19552 100644 --- a/vendor/knative.dev/pkg/injection/sharedmain/main.go +++ b/vendor/knative.dev/pkg/injection/sharedmain/main.go @@ -167,6 +167,10 @@ func MainWithConfig(ctx context.Context, component string, cfg *rest.Config, cto logger, atomicLevel := SetupLoggerOrDie(ctx, component) defer flush(logger) ctx = logging.WithLogger(ctx, logger) + + // Override client-go's warning handler to give us nicely printed warnings. + rest.SetDefaultWarningHandler(&logging.WarningHandler{Logger: logger}) + profilingHandler := profiling.NewHandler(logger, false) profilingServer := profiling.NewServer(profilingHandler) diff --git a/vendor/knative.dev/pkg/logging/warning_handler.go b/vendor/knative.dev/pkg/logging/warning_handler.go new file mode 100644 index 00000000000..7ea7aeeff6a --- /dev/null +++ b/vendor/knative.dev/pkg/logging/warning_handler.go @@ -0,0 +1,33 @@ +/* +Copyright 2021 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package logging + +import "go.uber.org/zap" + +// WarningHandler is a warning handler to forward client-go's warning logs into a zap logger. +type WarningHandler struct { + Logger *zap.SugaredLogger +} + +func (h *WarningHandler) HandleWarningHeader(code int, agent string, message string) { + // This condition is copied from K8s' default WarningLogger. + if code != 299 || len(message) == 0 { + return + } + + h.Logger.Warn("API Warning: " + message) +} diff --git a/vendor/knative.dev/pkg/ptr/value.go b/vendor/knative.dev/pkg/ptr/value.go new file mode 100644 index 00000000000..148bf2105ca --- /dev/null +++ b/vendor/knative.dev/pkg/ptr/value.go @@ -0,0 +1,91 @@ +/* +Copyright 2021 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package ptr + +import "time" + +// Int32Value is a helper for turning pointers to integers into values for use +// in API types that want int32. +func Int32Value(i *int32) int32 { + if i == nil { + return 0 + } + return *i +} + +// Int64Value is a helper for turning pointers to integers into values for use +// in API types that want int64. +func Int64Value(i *int64) int64 { + if i == nil { + return 0 + } + return *i +} + +// Float32Value is a helper for turning pointers to floats into values for use +// in API types that want float32. +func Float32Value(f *float32) float32 { + if f == nil { + return 0 + } + return *f +} + +// Float64Value is a helper for turning pointers to floats into values for use +// in API types that want float64. +func Float64Value(f *float64) float64 { + if f == nil { + return 0 + } + return *f +} + +// BoolValue is a helper for turning pointers to bools into values for use in +// API types that want bool. +func BoolValue(b *bool) bool { + if b == nil { + return false + } + return *b +} + +// StringValue is a helper for turning pointers to strings into values for use +// in API types that want string. +func StringValue(s *string) string { + if s == nil { + return "" + } + return *s +} + +// DurationValue is a helper for turning *time.Duration into values for use in +// API types that want time.Duration. +func DurationValue(t *time.Duration) time.Duration { + if t == nil { + return 0 + } + return *t +} + +// TimeValue is a helper for turning *time.Time into values for use in API +// types that want API types that want time.Time. +func TimeValue(t *time.Time) time.Time { + if t == nil { + return time.Time{} + } + return *t +} diff --git a/vendor/knative.dev/pkg/test/spoof/spoof.go b/vendor/knative.dev/pkg/test/spoof/spoof.go index 48ffcffa850..0513f7e0f1e 100644 --- a/vendor/knative.dev/pkg/test/spoof/spoof.go +++ b/vendor/knative.dev/pkg/test/spoof/spoof.go @@ -208,7 +208,7 @@ func DefaultErrorRetryChecker(err error) (bool, error) { if isTCPTimeout(err) { return true, fmt.Errorf("retrying for TCP timeout: %w", err) } - // Retrying on DNS error, since we may be using xip.io or nip.io in tests. + // Retrying on DNS error, since we may be using sslip.io or nip.io in tests. if isDNSError(err) { return true, fmt.Errorf("retrying for DNS error: %w", err) } diff --git a/vendor/modules.txt b/vendor/modules.txt index ed4b5f5fb79..4ec9f2a435d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1011,7 +1011,7 @@ knative.dev/hack/schema/commands knative.dev/hack/schema/docs knative.dev/hack/schema/registry knative.dev/hack/schema/schema -# knative.dev/pkg v0.0.0-20210622173328-dd0db4b05c80 +# knative.dev/pkg v0.0.0-20210701025203-30f9568e894e ## explicit knative.dev/pkg/apiextensions/storageversion knative.dev/pkg/apiextensions/storageversion/cmd/migrate @@ -1139,7 +1139,7 @@ knative.dev/pkg/webhook/resourcesemantics knative.dev/pkg/webhook/resourcesemantics/conversion knative.dev/pkg/webhook/resourcesemantics/defaulting knative.dev/pkg/webhook/resourcesemantics/validation -# knative.dev/reconciler-test v0.0.0-20210623134345-88c84739abd9 +# knative.dev/reconciler-test v0.0.0-20210630182710-2a6d91dfee1e ## explicit knative.dev/reconciler-test/cmd/eventshub knative.dev/reconciler-test/pkg/environment