From d161feb8979a6f44b950270f71faee45df70ea84 Mon Sep 17 00:00:00 2001 From: Victor Agababov Date: Thu, 13 Feb 2020 20:26:40 -0800 Subject: [PATCH] ff pkg (#6850) --- Gopkg.lock | 4 ++-- vendor/knative.dev/pkg/Gopkg.lock | 4 ++-- .../pkg/metrics/metricstest/metricstest.go | 15 +++++++++++++ vendor/knative.dev/pkg/tracker/enqueue.go | 22 +++++++++++++++---- 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 26c58f5d5403..6bf86d992a33 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1801,7 +1801,7 @@ [[projects]] branch = "master" - digest = "1:e71caa2e846cf80d5c362a7189f6a9276f8d60b96dd95b52a11ac321270098f6" + digest = "1:08f61d9c869f9ede5e90279575ac65a6147c190ef3ccc1cff2d38f9cf515353c" name = "knative.dev/pkg" packages = [ "apis", @@ -1908,7 +1908,7 @@ "websocket", ] pruneopts = "T" - revision = "602d92f69b660a5a84cbe96a9be21723f6f52d3d" + revision = "91a86d6aecdeaf91afe351e132c7c86047007563" [[projects]] branch = "master" diff --git a/vendor/knative.dev/pkg/Gopkg.lock b/vendor/knative.dev/pkg/Gopkg.lock index a0f0e2a31b8a..eb55ee4fceb6 100644 --- a/vendor/knative.dev/pkg/Gopkg.lock +++ b/vendor/knative.dev/pkg/Gopkg.lock @@ -1323,14 +1323,14 @@ [[projects]] branch = "master" - digest = "1:d2545cd71ef3604f5d2d792e569c6e3a4df31e336d76e709b0b8bac759c0faf7" + digest = "1:691951c6805590983ccea7c6dbca360bcb58af5f4d60f75af9499903bb3039e9" name = "knative.dev/test-infra" packages = [ "scripts", "tools/dep-collector", ] pruneopts = "UT" - revision = "c7c50ccd8082344a5f8ea85a5ae8de59308d325c" + revision = "279d938f5e19db2550bea7f71f4cdb97e0d84128" [[projects]] digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c" diff --git a/vendor/knative.dev/pkg/metrics/metricstest/metricstest.go b/vendor/knative.dev/pkg/metrics/metricstest/metricstest.go index f67363c3055f..0e967c83bc6c 100644 --- a/vendor/knative.dev/pkg/metrics/metricstest/metricstest.go +++ b/vendor/knative.dev/pkg/metrics/metricstest/metricstest.go @@ -90,6 +90,21 @@ func CheckDistributionData(t test.T, name string, wantTags map[string]string, ex } } +// CheckDistributionRange checks the view with a name matching string name to verify that the DistributionData stats reported +// are tagged with the tags in wantTags and that expectedCount number of records were reported. +func CheckDistributionCount(t test.T, name string, wantTags map[string]string, expectedCount int64) { + t.Helper() + if row := checkExactlyOneRow(t, name); row != nil { + checkRowTags(t, row, name, wantTags) + + if s, ok := row.Data.(*view.DistributionData); !ok { + t.Error("want DistributionData", "metric", name, "got", reflect.TypeOf(row.Data)) + } else if s.Count != expectedCount { + t.Error("reporter count wrong", "metric", name, "got", s.Count, "want", expectedCount) + } + } +} + // CheckLastValueData checks the view with a name matching string name to verify that the LastValueData stats // reported are tagged with the tags in wantTags and that wantValue matches reported last value. func CheckLastValueData(t test.T, name string, wantTags map[string]string, wantValue float64) { diff --git a/vendor/knative.dev/pkg/tracker/enqueue.go b/vendor/knative.dev/pkg/tracker/enqueue.go index 4a40a129ea85..a8f02ea6abad 100644 --- a/vendor/knative.dev/pkg/tracker/enqueue.go +++ b/vendor/knative.dev/pkg/tracker/enqueue.go @@ -131,6 +131,13 @@ func (i *impl) TrackReference(ref Reference, obj interface{}) error { key := types.NamespacedName{Namespace: object.GetNamespace(), Name: object.GetName()} i.m.Lock() + // Call the callback without the lock held. + var keys []types.NamespacedName + defer func(cb func(types.NamespacedName)) { + for _, key := range keys { + cb(key) + } + }(i.cb) // read i.cb with the lock held defer i.m.Unlock() if i.exact == nil { i.exact = make(map[Reference]set) @@ -158,7 +165,7 @@ func (i *impl) TrackReference(ref Reference, obj interface{}) error { // The simplest way of eliminating such a window is to call the // callback to "catch up" immediately following new // registrations. - i.cb(key) + keys = append(keys, key) } // Overwrite the key with a new expiration. l[key] = time.Now().Add(i.leaseDuration) @@ -191,7 +198,7 @@ func (i *impl) TrackReference(ref Reference, obj interface{}) error { // The simplest way of eliminating such a window is to call the // callback to "catch up" immediately following new // registrations. - i.cb(key) + keys = append(keys, key) } // Overwrite the key with a new expiration. l[key] = matcher{ @@ -223,6 +230,13 @@ func (i *impl) OnChanged(obj interface{}) { } i.m.Lock() + // Call the callbacks without the lock held. + var keys []types.NamespacedName + defer func(cb func(types.NamespacedName)) { + for _, key := range keys { + cb(key) + } + }(i.cb) // read i.cb with the lock held defer i.m.Unlock() // Handle exact matches. @@ -234,7 +248,7 @@ func (i *impl) OnChanged(obj interface{}) { delete(s, key) continue } - i.cb(key) + keys = append(keys, key) } if len(s) == 0 { delete(i.exact, ref) @@ -253,7 +267,7 @@ func (i *impl) OnChanged(obj interface{}) { continue } if m.selector.Matches(ls) { - i.cb(key) + keys = append(keys, key) } } if len(s) == 0 {