From bff5c0c31825b13034eec01e0b5e9506e846f93f Mon Sep 17 00:00:00 2001 From: knative-automation Date: Tue, 2 Mar 2021 07:43:32 -0800 Subject: [PATCH] upgrade to latest dependencies (#203) bumping knative.dev/eventing 4e5bdf9...f220668: > f220668 add more coverage (# 4999) > fba3dbf Use common script in GH Actions (# 4997) > 2db6877 Add missing singular resource names to source/sinkbinding crds (# 4992) > 184fa2f mtping adapter now cleans up internal cache when it stops leading (# 4908) > 6fb67cd update deps + codegen (# 4990) > 00b44e9 Format markdown (# 4980) > 235dba5 refactor for better testability, add ut (# 4979) > 44b0a0e Add roadmap for 2021 for Eventing, Eventing Sources and Event Delivery WGs (# 4863) > 5451f19 add more ut coverage (# 4978) > 207aa26 Add unit tests for parallel_validation_test (# 4845) > 86f455c swap lberk/vaikas shifts (# 4900) bumping knative.dev/pkg 584933f...9039dc1: > 9039dc1 moved release docs to github.com/knative/release (# 2040) > 07b5ddf add demoteFunc controller option (# 2033) > 8a8de5f Move IsKProbe to drainer, since it's the only place it's used (# 2038) > 5367a43 Fix potential deadlock when k8s client is used (# 2031) > b5bf07b adding retry event count metric for source (# 2016) > 17a36e7 Format markdown (# 2037) > 29be1c1 Add the release badge for all of the repos (# 2035) > e90ac15 Remove the system.Clock and it's mock in a different location (# 2034) > 8a9bf76 Add symmetric filter helped based on OwnerRefable. (# 2032) > 29092fe Format markdown (# 2030) > d733bb4 Add nightly badged to release tables (# 2029) > 7b5bcc3 Use the constant for UserAgent (# 2028) > 86a8236 Format markdown (# 2025) > 6c2f94a Unregister views to avoid slow oom issue during meter cleanup (# 2005) > 7689cce Update common github actions (# 2024) > f4650d8 Add releasability badges for each repo (# 2023) Signed-off-by: Knative Automation --- go.mod | 4 +- go.sum | 11 +- .../v1alpha1/vspheresource/controller.go | 3 + .../v1alpha1/vspheresource/reconciler.go | 3 + .../generators/reconciler_controller.go | 3 + .../generators/reconciler_reconciler.go | 3 + .../knative.dev/pkg/controller/controller.go | 7 ++ vendor/knative.dev/pkg/controller/options.go | 3 + vendor/knative.dev/pkg/metrics/exporter.go | 68 ++++++----- .../knative.dev/pkg/metrics/metrics_worker.go | 111 ++++++++++++++++++ .../knative.dev/pkg/metrics/resource_view.go | 8 +- .../knative.dev/pkg/network/handlers/drain.go | 23 +++- vendor/knative.dev/pkg/network/network.go | 23 +--- .../pkg/source/source_stats_reporter.go | 23 ++++ vendor/knative.dev/pkg/system/clock.go | 32 ----- vendor/modules.txt | 4 +- 16 files changed, 231 insertions(+), 98 deletions(-) create mode 100644 vendor/knative.dev/pkg/metrics/metrics_worker.go delete mode 100644 vendor/knative.dev/pkg/system/clock.go diff --git a/go.mod b/go.mod index d3161eff4..a23f23efa 100644 --- a/go.mod +++ b/go.mod @@ -27,9 +27,9 @@ require ( k8s.io/client-go v0.19.7 k8s.io/code-generator v0.19.7 k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6 - knative.dev/eventing v0.20.1-0.20210219125302-4e5bdf97930a + knative.dev/eventing v0.21.1-0.20210302004649-f22066824960 knative.dev/hack v0.0.0-20210203173706-8368e1f6eacf - knative.dev/pkg v0.0.0-20210216013737-584933f8280b + knative.dev/pkg v0.0.0-20210226182947-9039dc189ced ) replace ( diff --git a/go.sum b/go.sum index 56c0950c6..78b3c3a74 100644 --- a/go.sum +++ b/go.sum @@ -1217,14 +1217,15 @@ k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6 h1:+WnxoVtG8TMiudHBSEtrVL k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6/go.mod h1:UuqjUnNftUyPE5H64/qeyjQoUZhGpeFDVdxjTeEVN2o= k8s.io/utils v0.0.0-20200729134348-d5654de09c73 h1:uJmqzgNWG7XyClnU/mLPBWwfKKF1K8Hf8whTseBgJcg= k8s.io/utils v0.0.0-20200729134348-d5654de09c73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -knative.dev/eventing v0.20.1-0.20210219125302-4e5bdf97930a h1:3cqlUxlZ6M+EZA80OTroRXz7XNNImc4Qix01jqOA1Bo= -knative.dev/eventing v0.20.1-0.20210219125302-4e5bdf97930a/go.mod h1:JjbVEOTJJHqo9CTxbTfrMn018hG8fOr3UfBoCJ7KWaA= +knative.dev/eventing v0.21.1-0.20210302004649-f22066824960 h1:E5lX5F6PNv2GwBcrJyrq+uHls2SnKLX4TLH1BeLq6j4= +knative.dev/eventing v0.21.1-0.20210302004649-f22066824960/go.mod h1:KtN2FEhPzxyqXKxpJufdq0lzL3Iu+5qjFqBal8Lg2tQ= knative.dev/hack v0.0.0-20210203173706-8368e1f6eacf h1:u4cY4jr2LYvhoz/1HBWEPsMiLkm0HMdDTfmmw1RE8zE= knative.dev/hack v0.0.0-20210203173706-8368e1f6eacf/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= knative.dev/pkg v0.0.0-20210215165523-84c98f3c3e7a/go.mod h1:TJSdebQOWX5N2bszohOYVi0H1QtXbtlYLuMghAFBMhY= -knative.dev/pkg v0.0.0-20210216013737-584933f8280b h1:2v+GBBenjPXhtk3KX/YqxCQVBU6o/AaRkkqE58lgFRQ= -knative.dev/pkg v0.0.0-20210216013737-584933f8280b/go.mod h1:TJSdebQOWX5N2bszohOYVi0H1QtXbtlYLuMghAFBMhY= -knative.dev/reconciler-test v0.0.0-20210216030508-77f50054d024/go.mod h1:RP/K5xJylB72Go6eAsXYEsQHp4zCCNMNjmsqhvq7wko= +knative.dev/pkg v0.0.0-20210225221047-07b5ddfaea60/go.mod h1:TJSdebQOWX5N2bszohOYVi0H1QtXbtlYLuMghAFBMhY= +knative.dev/pkg v0.0.0-20210226182947-9039dc189ced h1:OCtTbXsJhiR35qCDxFj9Xc8sU3i87ePbc7YlHCt0al4= +knative.dev/pkg v0.0.0-20210226182947-9039dc189ced/go.mod h1:TJSdebQOWX5N2bszohOYVi0H1QtXbtlYLuMghAFBMhY= +knative.dev/reconciler-test v0.0.0-20210223181346-209f32c8cdc4/go.mod h1:RP/K5xJylB72Go6eAsXYEsQHp4zCCNMNjmsqhvq7wko= pgregory.net/rapid v0.3.3/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= diff --git a/pkg/client/injection/reconciler/sources/v1alpha1/vspheresource/controller.go b/pkg/client/injection/reconciler/sources/v1alpha1/vspheresource/controller.go index 553e60b7e..0082a0196 100644 --- a/pkg/client/injection/reconciler/sources/v1alpha1/vspheresource/controller.go +++ b/pkg/client/injection/reconciler/sources/v1alpha1/vspheresource/controller.go @@ -102,6 +102,9 @@ func NewImpl(ctx context.Context, r Interface, optionsFns ...controller.OptionsF if opts.SkipStatusUpdates { rec.skipStatusUpdates = true } + if opts.DemoteFunc != nil { + rec.DemoteFunc = opts.DemoteFunc + } } rec.Recorder = createRecorder(ctx, agentName) diff --git a/pkg/client/injection/reconciler/sources/v1alpha1/vspheresource/reconciler.go b/pkg/client/injection/reconciler/sources/v1alpha1/vspheresource/reconciler.go index 7e5f13175..3d8b056af 100644 --- a/pkg/client/injection/reconciler/sources/v1alpha1/vspheresource/reconciler.go +++ b/pkg/client/injection/reconciler/sources/v1alpha1/vspheresource/reconciler.go @@ -158,6 +158,9 @@ func NewReconciler(ctx context.Context, logger *zap.SugaredLogger, client versio if opts.SkipStatusUpdates { rec.skipStatusUpdates = true } + if opts.DemoteFunc != nil { + rec.DemoteFunc = opts.DemoteFunc + } } return rec diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go index 06d436648..78ff96730 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go @@ -271,6 +271,9 @@ func NewImpl(ctx {{.contextContext|raw}}, r Interface{{if .hasClass}}, classValu rec.skipStatusUpdates = true } {{- end}} + if opts.DemoteFunc != nil { + rec.DemoteFunc = opts.DemoteFunc + } } rec.Recorder = createRecorder(ctx, agentName) diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go index 10149fadd..cc6757da8 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go @@ -363,6 +363,9 @@ func NewReconciler(ctx {{.contextContext|raw}}, logger *{{.zapSugaredLogger|raw} rec.skipStatusUpdates = true } {{- end}} + if opts.DemoteFunc != nil { + rec.DemoteFunc = opts.DemoteFunc + } } return rec diff --git a/vendor/knative.dev/pkg/controller/controller.go b/vendor/knative.dev/pkg/controller/controller.go index 27fe75e40..2a28497fa 100644 --- a/vendor/knative.dev/pkg/controller/controller.go +++ b/vendor/knative.dev/pkg/controller/controller.go @@ -152,6 +152,13 @@ func FilterControllerGK(gk schema.GroupKind) func(obj interface{}) bool { } } +// FilterController makes it simple to create FilterFunc's for use with +// cache.FilteringResourceEventHandler that filter based on the +// controlling resource. +func FilterController(r kmeta.OwnerRefable) func(obj interface{}) bool { + return FilterControllerGK(r.GetGroupVersionKind().GroupKind()) +} + // FilterWithName makes it simple to create FilterFunc's for use with // cache.FilteringResourceEventHandler that filter based on a name. func FilterWithName(name string) func(obj interface{}) bool { diff --git a/vendor/knative.dev/pkg/controller/options.go b/vendor/knative.dev/pkg/controller/options.go index b40b5a359..8d61835e6 100644 --- a/vendor/knative.dev/pkg/controller/options.go +++ b/vendor/knative.dev/pkg/controller/options.go @@ -35,6 +35,9 @@ type Options struct { // SkipStatusUpdates configures this reconciler to either do automated status // updates (default) or skip them if this is set to true. SkipStatusUpdates bool + + // DemoteFunc configures the demote function this reconciler uses + DemoteFunc func(b reconciler.Bucket) } // OptionsFn is a callback method signature that accepts an Impl and returns diff --git a/vendor/knative.dev/pkg/metrics/exporter.go b/vendor/knative.dev/pkg/metrics/exporter.go index b98a18de1..3fc4966fd 100644 --- a/vendor/knative.dev/pkg/metrics/exporter.go +++ b/vendor/knative.dev/pkg/metrics/exporter.go @@ -21,7 +21,6 @@ import ( "errors" "fmt" "strings" - "sync" "go.opencensus.io/resource" "go.opencensus.io/stats/view" @@ -32,9 +31,14 @@ import ( var ( curMetricsExporter view.Exporter curMetricsConfig *metricsConfig - metricsMux sync.RWMutex + mWorker *metricsWorker ) +func init() { + mWorker = newMetricsWorker() + go mWorker.start() +} + // SecretFetcher is a function (extracted from SecretNamespaceLister) for fetching // a specific Secret. This avoids requiring global or namespace list in controllers. type SecretFetcher func(string) (*corev1.Secret, error) @@ -154,28 +158,14 @@ func UpdateExporter(ctx context.Context, ops ExporterOptions, logger *zap.Sugare // Updating the metrics config and the metrics exporters needs to be atomic to // avoid using an outdated metrics config with new exporters. - metricsMux.Lock() - defer metricsMux.Unlock() - - if isNewExporterRequired(newConfig) { - logger.Info("Flushing the existing exporter before setting up the new exporter.") - flushGivenExporter(curMetricsExporter) - e, f, err := newMetricsExporter(newConfig, logger) - if err != nil { - logger.Errorw("Failed to update a new metrics exporter based on metric config", zap.Error(err), "config", newConfig) - return err - } - existingConfig := curMetricsConfig - curMetricsExporter = e - if err := setFactory(f); err != nil { - logger.Errorw("Failed to update metrics factory when loading metric config", zap.Error(err), "config", newConfig) - return err - } - logger.Infof("Successfully updated the metrics exporter; old config: %v; new config %v", existingConfig, newConfig) + updateCmd := &updateMetricsConfigWithExporter{ + ctx: ctx, + newConfig: newConfig, + done: make(chan error), } - - setCurMetricsConfigUnlocked(newConfig) - return nil + mWorker.c <- updateCmd + err = <-updateCmd.done + return err } // isNewExporterRequired compares the non-nil newConfig against curMetricsConfig. When backend changes, @@ -228,27 +218,35 @@ func newMetricsExporter(config *metricsConfig, logger *zap.SugaredLogger) (view. } func getCurMetricsExporter() view.Exporter { - metricsMux.RLock() - defer metricsMux.RUnlock() - return curMetricsExporter + readCmd := &readExporter{done: make(chan *view.Exporter)} + mWorker.c <- readCmd + e := <-readCmd.done + return *e } func setCurMetricsExporter(e view.Exporter) { - metricsMux.Lock() - defer metricsMux.Unlock() - curMetricsExporter = e + setCmd := &setExporter{ + newExporter: &e, + done: make(chan struct{}), + } + mWorker.c <- setCmd + <-setCmd.done } func getCurMetricsConfig() *metricsConfig { - metricsMux.RLock() - defer metricsMux.RUnlock() - return curMetricsConfig + readCmd := &readMetricsConfig{done: make(chan *metricsConfig)} + mWorker.c <- readCmd + cfg := <-readCmd.done + return cfg } func setCurMetricsConfig(c *metricsConfig) { - metricsMux.Lock() - defer metricsMux.Unlock() - setCurMetricsConfigUnlocked(c) + setCmd := &setMetricsConfig{ + newConfig: c, + done: make(chan struct{}), + } + mWorker.c <- setCmd + <-setCmd.done } func setCurMetricsConfigUnlocked(c *metricsConfig) { diff --git a/vendor/knative.dev/pkg/metrics/metrics_worker.go b/vendor/knative.dev/pkg/metrics/metrics_worker.go new file mode 100644 index 000000000..0b7753acb --- /dev/null +++ b/vendor/knative.dev/pkg/metrics/metrics_worker.go @@ -0,0 +1,111 @@ +/* +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 metrics + +import ( + "context" + + "go.opencensus.io/stats/view" + "go.uber.org/zap" + "knative.dev/pkg/logging" +) + +type metricsWorker struct { + c chan command +} + +func newMetricsWorker() *metricsWorker { + return &metricsWorker{c: make(chan command)} +} + +type command interface { + handleCommand(w *metricsWorker) +} + +type readExporter struct { + done chan *view.Exporter +} + +type setExporter struct { + newExporter *view.Exporter + done chan struct{} +} + +type readMetricsConfig struct { + done chan *metricsConfig +} + +type updateMetricsConfigWithExporter struct { + ctx context.Context + newConfig *metricsConfig + done chan error +} + +type setMetricsConfig struct { + newConfig *metricsConfig + done chan struct{} +} + +func (cmd *readMetricsConfig) handleCommand(w *metricsWorker) { + cmd.done <- curMetricsConfig +} + +func (cmd *setMetricsConfig) handleCommand(w *metricsWorker) { + setCurMetricsConfigUnlocked(cmd.newConfig) + cmd.done <- struct{}{} +} + +func (cmd *updateMetricsConfigWithExporter) handleCommand(w *metricsWorker) { + ctx := cmd.ctx + logger := logging.FromContext(ctx) + if isNewExporterRequired(cmd.newConfig) { + logger.Info("Flushing the existing exporter before setting up the new exporter.") + flushGivenExporter(curMetricsExporter) + e, f, err := newMetricsExporter(cmd.newConfig, logger) + if err != nil { + logger.Errorw("Failed to update a new metrics exporter based on metric config", zap.Error(err), "config", cmd.newConfig) + cmd.done <- err + return + } + existingConfig := curMetricsConfig + curMetricsExporter = e + if err := setFactory(f); err != nil { + logger.Errorw("Failed to update metrics factory when loading metric config", zap.Error(err), "config", cmd.newConfig) + cmd.done <- err + return + } + logger.Infof("Successfully updated the metrics exporter; old config: %v; new config %v", existingConfig, cmd.newConfig) + } + setCurMetricsConfigUnlocked(cmd.newConfig) + cmd.done <- nil +} + +func (w *metricsWorker) start() { + for { + cmd := <-w.c + cmd.handleCommand(w) + } +} + +func (cmd *setExporter) handleCommand(w *metricsWorker) { + curMetricsExporter = *cmd.newExporter + cmd.done <- struct{}{} +} + +func (cmd *readExporter) handleCommand(w *metricsWorker) { + cmd.done <- &curMetricsExporter +} diff --git a/vendor/knative.dev/pkg/metrics/resource_view.go b/vendor/knative.dev/pkg/metrics/resource_view.go index 7135af70a..236fd588b 100644 --- a/vendor/knative.dev/pkg/metrics/resource_view.go +++ b/vendor/knative.dev/pkg/metrics/resource_view.go @@ -82,10 +82,16 @@ func cleanup() { expiryCutoff := allMeters.clock.Now().Add(-1 * maxMeterExporterAge) allMeters.lock.Lock() defer allMeters.lock.Unlock() + resourceViews.lock.Lock() + defer resourceViews.lock.Unlock() for key, meter := range allMeters.meters { if key != "" && meter.t.Before(expiryCutoff) { flushGivenExporter(meter.e) + // Make a copy of views to avoid data races + viewsCopy := copyViews(resourceViews.views) + meter.m.Unregister(viewsCopy...) delete(allMeters.meters, key) + meter.m.Stop() } } } @@ -139,7 +145,7 @@ func RegisterResourceView(views ...*view.View) error { return nil } -// UnregisterResourceView is similar to view.Unregiste(), except that it will +// UnregisterResourceView is similar to view.Unregister(), except that it will // unregister the view across all Resources tracked byt he system, rather than // simply the default view. func UnregisterResourceView(views ...*view.View) { diff --git a/vendor/knative.dev/pkg/network/handlers/drain.go b/vendor/knative.dev/pkg/network/handlers/drain.go index 0ed37ba6d..b8dc6ff1b 100644 --- a/vendor/knative.dev/pkg/network/handlers/drain.go +++ b/vendor/knative.dev/pkg/network/handlers/drain.go @@ -17,6 +17,7 @@ limitations under the License. package handlers import ( + "fmt" "net/http" "sync" "time" @@ -90,11 +91,11 @@ func (d *Drainer) ServeHTTP(w http.ResponseWriter, r *http.Request) { } return } - if network.IsKProbe(r) { + if isKProbe(r) { if d.draining() { http.Error(w, "shutting down", http.StatusServiceUnavailable) } else { - network.ServeKProbe(w, r) + serveKProbe(w, r) } return } @@ -146,3 +147,21 @@ func (d *Drainer) draining() bool { defer d.RUnlock() return d.timer != nil } + +// isKProbe returns true if the request is a knatvie probe. +func isKProbe(r *http.Request) bool { + return r.Header.Get(network.ProbeHeaderName) == network.ProbeHeaderValue +} + +// serveKProbe serve KProbe requests. +func serveKProbe(w http.ResponseWriter, r *http.Request) { + hh := r.Header.Get(network.HashHeaderName) + if hh == "" { + http.Error(w, + fmt.Sprintf("a probe request must contain a non-empty %q header", network.HashHeaderName), + http.StatusBadRequest) + return + } + w.Header().Set(network.HashHeaderName, hh) + w.WriteHeader(http.StatusOK) +} diff --git a/vendor/knative.dev/pkg/network/network.go b/vendor/knative.dev/pkg/network/network.go index b2ac63ce7..cf5feaa8f 100644 --- a/vendor/knative.dev/pkg/network/network.go +++ b/vendor/knative.dev/pkg/network/network.go @@ -17,7 +17,6 @@ limitations under the License. package network import ( - "fmt" "net/http" "strings" "time" @@ -52,33 +51,19 @@ const ( // uses to find out which version of the networking config is deployed. HashHeaderName = "K-Network-Hash" + // KubeProbeUAPrefix is the prefix for the User-Agent header. // Since K8s 1.8, prober requests have // User-Agent = "kube-probe/{major-version}.{minor-version}". KubeProbeUAPrefix = "kube-probe/" + // KubeletProbeHeaderName is the header name to augment the probes, because // Istio with mTLS rewrites probes, but their probes pass a different - // user-agent. So we augment the probes with this header. + // user-agent. KubeletProbeHeaderName = "K-Kubelet-Probe" ) // IsKubeletProbe returns true if the request is a Kubernetes probe. func IsKubeletProbe(r *http.Request) bool { - return strings.HasPrefix(r.Header.Get("User-Agent"), KubeProbeUAPrefix) || + return strings.HasPrefix(r.Header.Get(UserAgentKey), KubeProbeUAPrefix) || r.Header.Get(KubeletProbeHeaderName) != "" } - -// IsKProbe returns true if the request is a knatvie probe. -func IsKProbe(r *http.Request) bool { - return r.Header.Get(ProbeHeaderName) == ProbeHeaderValue -} - -// ServeKProbe serve KProbe requests. -func ServeKProbe(w http.ResponseWriter, r *http.Request) { - hh := r.Header.Get(HashHeaderName) - if hh == "" { - http.Error(w, fmt.Sprintf("a probe request must contain a non-empty %q header", HashHeaderName), http.StatusBadRequest) - return - } - w.Header().Set(HashHeaderName, hh) - w.WriteHeader(http.StatusOK) -} diff --git a/vendor/knative.dev/pkg/source/source_stats_reporter.go b/vendor/knative.dev/pkg/source/source_stats_reporter.go index b6d1ca93b..f343d9d75 100644 --- a/vendor/knative.dev/pkg/source/source_stats_reporter.go +++ b/vendor/knative.dev/pkg/source/source_stats_reporter.go @@ -35,6 +35,12 @@ var ( stats.UnitDimensionless, ) + // retryEventCountM is a counter which records the number of events sent by the source in retries. + retryEventCountM = stats.Int64( + "retry_event_count", + "Number of retry events sent", + stats.UnitDimensionless, + ) // Create the tag keys that will be used to add tags to our measurements. // Tag keys must conform to the restrictions described in // go.opencensus.io/tag/validate.go. Currently those restrictions are: @@ -51,6 +57,7 @@ var ( responseTimeout = tag.MustNewKey(metricskey.LabelResponseTimeout) ) +// ReportArgs defines the arguments for reporting metrics. type ReportArgs struct { Namespace string EventType string @@ -69,6 +76,7 @@ func init() { type StatsReporter interface { // ReportEventCount captures the event count. It records one per call. ReportEventCount(args *ReportArgs, responseCode int) error + ReportRetryEventCount(args *ReportArgs, responseCode int) error } var _ StatsReporter = (*reporter)(nil) @@ -98,6 +106,15 @@ func (r *reporter) ReportEventCount(args *ReportArgs, responseCode int) error { return nil } +func (r *reporter) ReportRetryEventCount(args *ReportArgs, responseCode int) error { + ctx, err := r.generateTag(args, responseCode) + if err != nil { + return err + } + metrics.Record(ctx, retryEventCountM.M(1)) + return nil +} + func (r *reporter) generateTag(args *ReportArgs, responseCode int) (context.Context, error) { return tag.New( r.ctx, @@ -132,6 +149,12 @@ func register() { Aggregation: view.Count(), TagKeys: tagKeys, }, + &view.View{ + Description: retryEventCountM.Description(), + Measure: retryEventCountM, + Aggregation: view.Count(), + TagKeys: tagKeys, + }, ); err != nil { panic(err) } diff --git a/vendor/knative.dev/pkg/system/clock.go b/vendor/knative.dev/pkg/system/clock.go deleted file mode 100644 index 7d99d9b5c..000000000 --- a/vendor/knative.dev/pkg/system/clock.go +++ /dev/null @@ -1,32 +0,0 @@ -/* -Copyright 2019 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 system - -import ( - "time" -) - -// Mockable interface for time based testing -type Clock interface { - Now() time.Time -} - -type RealClock struct{} - -func (RealClock) Now() time.Time { - return time.Now() -} diff --git a/vendor/modules.txt b/vendor/modules.txt index d17e6158b..74da50261 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1035,7 +1035,7 @@ k8s.io/utils/buffer k8s.io/utils/integer k8s.io/utils/pointer k8s.io/utils/trace -# knative.dev/eventing v0.20.1-0.20210219125302-4e5bdf97930a +# knative.dev/eventing v0.21.1-0.20210302004649-f22066824960 ## explicit knative.dev/eventing/pkg/adapter/v2 knative.dev/eventing/pkg/adapter/v2/util/crstatusevent @@ -1081,7 +1081,7 @@ knative.dev/eventing/pkg/kncloudevents # knative.dev/hack v0.0.0-20210203173706-8368e1f6eacf ## explicit knative.dev/hack -# knative.dev/pkg v0.0.0-20210216013737-584933f8280b +# knative.dev/pkg v0.0.0-20210226182947-9039dc189ced ## explicit knative.dev/pkg/apis knative.dev/pkg/apis/duck