diff --git a/go.mod b/go.mod index 30f0e6c748..e03acbb45c 100644 --- a/go.mod +++ b/go.mod @@ -20,11 +20,11 @@ require ( github.com/spf13/cobra v1.1.3 github.com/spf13/pflag v1.0.5 github.com/tektoncd/hub/api v0.0.0-20210517094448-c032b766a83c - github.com/tektoncd/pipeline v0.23.0 + github.com/tektoncd/pipeline v0.24.1 github.com/tektoncd/plumbing v0.0.0-20210514044347-f8a9689d5bd5 github.com/tektoncd/triggers v0.13.0 github.com/tidwall/gjson v1.6.0 // indirect - go.opencensus.io v0.22.5 + go.opencensus.io v0.23.0 go.uber.org/multierr v1.5.0 golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 @@ -35,7 +35,7 @@ require ( k8s.io/apimachinery v0.19.7 k8s.io/cli-runtime v0.19.7 k8s.io/client-go v0.19.7 - knative.dev/pkg v0.0.0-20210208131226-4b2ae073fa06 + knative.dev/pkg v0.0.0-20210331065221-952fdd90dbb0 sigs.k8s.io/yaml v1.2.0 ) diff --git a/go.sum b/go.sum index 564b3934d6..c71867bcfb 100644 --- a/go.sum +++ b/go.sum @@ -43,6 +43,8 @@ contrib.go.opencensus.io/exporter/prometheus v0.2.1-0.20200609204449-6bcf6f8577f contrib.go.opencensus.io/exporter/prometheus v0.2.1-0.20200609204449-6bcf6f8577f0/go.mod h1:MjHoxkI7Ny27toPeFkRbXbzVjzIGkwOAptrAy8Mxtm8= contrib.go.opencensus.io/exporter/stackdriver v0.13.4 h1:ksUxwH3OD5sxkjzEqGxNTl+Xjsmu3BnC/300MhSVTSc= contrib.go.opencensus.io/exporter/stackdriver v0.13.4/go.mod h1:aXENhDJ1Y4lIg4EUaVTwzvYETVNZk10Pu26tevFKLUc= +contrib.go.opencensus.io/exporter/stackdriver v0.13.5 h1:TNaexHK16gPUoc7uzELKOU7JULqccn1NDuqUxmxSqfo= +contrib.go.opencensus.io/exporter/stackdriver v0.13.5/go.mod h1:aXENhDJ1Y4lIg4EUaVTwzvYETVNZk10Pu26tevFKLUc= contrib.go.opencensus.io/exporter/zipkin v0.1.2/go.mod h1:mP5xM3rrgOjpn79MM8fZbj3gsxcuytSqtH0dxSWW1RE= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= git.apache.org/thrift.git v0.12.0/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= @@ -483,6 +485,7 @@ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -879,6 +882,8 @@ github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeD github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.8.0 h1:zvJNkoCFAnYFNC24FV8nW4JdRJ3GIFcLbg65lL/JDcw= github.com/prometheus/client_golang v1.8.0/go.mod h1:O9VU6huf47PktckDQfMTX0Y8tY0/7TSWwj+ITvv0TnM= +github.com/prometheus/client_golang v1.9.0 h1:Rrch9mh17XcxvEu9D9DEpb4isxjGBtcevQjKvxPRQIU= +github.com/prometheus/client_golang v1.9.0/go.mod h1:FqZLKOZnGdFAhOK4nqGHa7D66IdsO+O441Eve7ptJDU= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -896,6 +901,8 @@ github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB8 github.com/prometheus/common v0.14.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.15.0 h1:4fgOnadei3EZvgRwxJ7RMpG1k1pOZth5Pc13tyspaKM= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= +github.com/prometheus/common v0.19.0 h1:Itb4+NjG9wRdkAWgVucbM/adyIXxEhbw0866e0uZE6A= +github.com/prometheus/common v0.19.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= @@ -991,9 +998,10 @@ github.com/tektoncd/hub/api v0.0.0-20210517094448-c032b766a83c h1:arOr460Dk43cYa github.com/tektoncd/hub/api v0.0.0-20210517094448-c032b766a83c/go.mod h1:uvOHItUnmqjvipDX0oI6MMDZkcQl9O/UPWGDR4Qw940= github.com/tektoncd/pipeline v0.20.1-0.20210203144343-1b7a37f0d21d/go.mod h1:GwdfGGt/5VhZL8JvJu8kFz8friKufcJ/TJkJmK6uc0U= github.com/tektoncd/pipeline v0.20.1-0.20210204110343-8c5a751b53ea/go.mod h1:GwdfGGt/5VhZL8JvJu8kFz8friKufcJ/TJkJmK6uc0U= -github.com/tektoncd/pipeline v0.23.0 h1:nOyk1KqXTZBlqRx20YrITUh7F/uDI2bXMfHedIxIzEY= -github.com/tektoncd/pipeline v0.23.0/go.mod h1:QcD1kMaXVIHA/V7RCi4NQUCR6z3plBVjmglRbpS71FQ= +github.com/tektoncd/pipeline v0.24.1 h1:c+Odgmf8dkUVRdQ5NVbOliwFB8608kM9i+18t5QDO+g= +github.com/tektoncd/pipeline v0.24.1/go.mod h1:ChFD/vfu14VOtCVlLWdtlvOwXfBfVotULoNV6yz+CKY= github.com/tektoncd/plumbing v0.0.0-20201021153918-6b7e894737b5/go.mod h1:WTWwsg91xgm+jPOKoyKVK/yRYxnVDlUYeDlypB1lDdQ= +github.com/tektoncd/plumbing v0.0.0-20210420200944-17170d5e7bc9/go.mod h1:WTWwsg91xgm+jPOKoyKVK/yRYxnVDlUYeDlypB1lDdQ= github.com/tektoncd/plumbing v0.0.0-20210514044347-f8a9689d5bd5 h1:tY3t38AFNwlSWALhulEHryANpQ53Hfjp9jM5zl8ImSQ= github.com/tektoncd/plumbing v0.0.0-20210514044347-f8a9689d5bd5/go.mod h1:WTWwsg91xgm+jPOKoyKVK/yRYxnVDlUYeDlypB1lDdQ= github.com/tektoncd/triggers v0.13.0 h1:e/4G0HwVqOHnqIMLAc3eKnMX7BNlgs3PDBEqVfL3suw= @@ -1056,6 +1064,8 @@ go.opencensus.io v0.22.4-0.20200608061201-1901b56b9515/go.mod h1:yxeiOL68Rb0Xd1d go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5 h1:dntmOdLpSpHlVqbW5Eay97DelsZHe+55D+xC6i0dDS0= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -1063,6 +1073,7 @@ go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/automaxprocs v1.3.0/go.mod h1:9CWT6lKIep8U41DDaPiH6eFscnTyjfTANNQNx6LrIcA= +go.uber.org/automaxprocs v1.4.0/go.mod h1:/mTEdr7LvHhs0v7mjdxDreTz1OG5zdZGqgOnhWiR/+Q= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A= @@ -1293,6 +1304,7 @@ golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1400,6 +1412,7 @@ golang.org/x/tools v0.0.0-20200916195026-c9a70fc28ce3/go.mod h1:z6u4i615ZeAfBE4X golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= @@ -1491,6 +1504,7 @@ google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201211151036-40ec1c210f7a/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210325224202-eed09b1b5210/go.mod h1:f2Bd7+2PlaVKmvKQ52aspJZXIDaRQBVdOOBfJ5i8OEs= google.golang.org/genproto v0.0.0-20210330181207-2295ebbda0c6 h1:F+kz69Q2lpqBTskKa73+uBMwi7PBQRQEUBqHt0oc1K8= google.golang.org/genproto v0.0.0-20210330181207-2295ebbda0c6/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= @@ -1648,12 +1662,12 @@ k8s.io/utils v0.0.0-20200729134348-d5654de09c73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/ k8s.io/utils v0.0.0-20210111153108-fddb29f9d009 h1:0T5IaWHO3sJTEmCP6mUlBvMukxPKUQWqiI/YuiBNMiQ= k8s.io/utils v0.0.0-20210111153108-fddb29f9d009/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= knative.dev/hack v0.0.0-20210120165453-8d623a0af457/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= -knative.dev/hack v0.0.0-20210203173706-8368e1f6eacf/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= +knative.dev/hack v0.0.0-20210325223819-b6ab329907d3/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= knative.dev/pkg v0.0.0-20210127163530-0d31134d5f4e/go.mod h1:X4NPrCo8NK3hbDVan9Vm7mf5io3ZoINakAdrpSXVB08= knative.dev/pkg v0.0.0-20210130001831-ca02ef752ac6/go.mod h1:X4NPrCo8NK3hbDVan9Vm7mf5io3ZoINakAdrpSXVB08= knative.dev/pkg v0.0.0-20210203171706-6045ed499615/go.mod h1:X4NPrCo8NK3hbDVan9Vm7mf5io3ZoINakAdrpSXVB08= -knative.dev/pkg v0.0.0-20210208131226-4b2ae073fa06 h1:u2mHDtIEB2WkXXgCj5yg2VuNP/W0XNRliaOJqJGrLeM= -knative.dev/pkg v0.0.0-20210208131226-4b2ae073fa06/go.mod h1:72bhCSsMqNteAB/T7gZN6w/bnMz+GwGE92+RUmhjzF8= +knative.dev/pkg v0.0.0-20210331065221-952fdd90dbb0 h1:z05hcB4br0qz7JdwIoUSTXLTF+7ThuJ+R6NFfXd1Y4Q= +knative.dev/pkg v0.0.0-20210331065221-952fdd90dbb0/go.mod h1:PD5g8hUCXq6iR3tILjmZeJBvQfXGnHMPKryq54qHJhg= maze.io/x/duration v0.0.0-20160924141736-faac084b6075/go.mod h1:1kfR2ph3CIvtfIQ8D8JhmAgePmnAUnR+AWYWUBo+l08= 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/contrib.go.opencensus.io/exporter/stackdriver/resource.go b/vendor/contrib.go.opencensus.io/exporter/stackdriver/resource.go index e32c4dab75..50331d2948 100644 --- a/vendor/contrib.go.opencensus.io/exporter/stackdriver/resource.go +++ b/vendor/contrib.go.opencensus.io/exporter/stackdriver/resource.go @@ -41,6 +41,11 @@ const ( knativeConfigurationName = "configuration_name" knativeNamespaceName = "namespace_name" + knativeBrokerType = "knative_broker" + knativeBrokerName = "broker_name" + knativeTriggerType = "knative_trigger" + knativeTriggerName = "trigger_name" + appEngineInstanceType = "gae_instance" appEngineService = "appengine.service.id" @@ -133,6 +138,23 @@ var knativeRevisionResourceMap = map[string]string{ knativeNamespaceName: knativeNamespaceName, } +var knativeBrokerResourceMap = map[string]string{ + "project_id": stackdriverProjectID, + "location": resourcekeys.CloudKeyZone, + "cluster_name": resourcekeys.K8SKeyClusterName, + knativeNamespaceName: knativeNamespaceName, + knativeBrokerName: knativeBrokerName, +} + +var knativeTriggerResourceMap = map[string]string{ + "project_id": stackdriverProjectID, + "location": resourcekeys.CloudKeyZone, + "cluster_name": resourcekeys.K8SKeyClusterName, + knativeNamespaceName: knativeNamespaceName, + knativeBrokerName: knativeBrokerName, + knativeTriggerName: knativeTriggerName, +} + // getAutodetectedLabels returns all the labels from the Monitored Resource detected // from the environment by calling monitoredresource.Autodetect. If a "zone" label is detected, // a "location" label is added with the same value to account for differences between @@ -213,6 +235,12 @@ func DefaultMapResource(res *resource.Resource) *monitoredrespb.MonitoredResourc case res.Type == knativeResType: result.Type = res.Type match = knativeRevisionResourceMap + case res.Type == knativeBrokerType: + result.Type = knativeBrokerType + match = knativeBrokerResourceMap + case res.Type == knativeTriggerType: + result.Type = knativeTriggerType + match = knativeTriggerResourceMap } var missing bool diff --git a/vendor/contrib.go.opencensus.io/exporter/stackdriver/stackdriver.go b/vendor/contrib.go.opencensus.io/exporter/stackdriver/stackdriver.go index 1e253f9dda..1f838ba33f 100644 --- a/vendor/contrib.go.opencensus.io/exporter/stackdriver/stackdriver.go +++ b/vendor/contrib.go.opencensus.io/exporter/stackdriver/stackdriver.go @@ -67,6 +67,7 @@ import ( "go.opencensus.io/trace" "golang.org/x/oauth2/google" "google.golang.org/api/option" + metricpb "google.golang.org/genproto/googleapis/api/metric" monitoredrespb "google.golang.org/genproto/googleapis/api/monitoredres" commonpb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1" @@ -469,6 +470,15 @@ func (e *Exporter) Flush() { e.traceExporter.Flush() } +// ViewToMetricDescriptor converts an OpenCensus view to a MetricDescriptor. +// +// This is useful for cases when you want to use your Go code as source of +// truth of metric descriptors. You can extract or define views in a central +// place, then call this method to generate MetricDescriptors. +func (e *Exporter) ViewToMetricDescriptor(ctx context.Context, v *view.View) (*metricpb.MetricDescriptor, error) { + return e.statsExporter.viewToMetricDescriptor(ctx, v) +} + func (o Options) handleError(err error) { if o.OnError != nil { o.OnError(err) diff --git a/vendor/github.com/prometheus/client_golang/prometheus/process_collector.go b/vendor/github.com/prometheus/client_golang/prometheus/process_collector.go index 9b80979421..c46702d60b 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/process_collector.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/process_collector.go @@ -15,7 +15,11 @@ package prometheus import ( "errors" + "fmt" + "io/ioutil" "os" + "strconv" + "strings" ) type processCollector struct { @@ -149,3 +153,20 @@ func (c *processCollector) reportError(ch chan<- Metric, desc *Desc, err error) } ch <- NewInvalidMetric(desc, err) } + +// NewPidFileFn returns a function that retrieves a pid from the specified file. +// It is meant to be used for the PidFn field in ProcessCollectorOpts. +func NewPidFileFn(pidFilePath string) func() (int, error) { + return func() (int, error) { + content, err := ioutil.ReadFile(pidFilePath) + if err != nil { + return 0, fmt.Errorf("can't read pid file %q: %+v", pidFilePath, err) + } + pid, err := strconv.Atoi(strings.TrimSpace(string(content))) + if err != nil { + return 0, fmt.Errorf("can't parse pid file %q: %+v", pidFilePath, err) + } + + return pid, nil + } +} diff --git a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go index 5e1c4546ce..d86d0cf4b0 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go @@ -99,7 +99,7 @@ func HandlerFor(reg prometheus.Gatherer, opts HandlerOpts) http.Handler { inFlightSem = make(chan struct{}, opts.MaxRequestsInFlight) } if opts.Registry != nil { - // Initialize all possibilites that can occur below. + // Initialize all possibilities that can occur below. errCnt.WithLabelValues("gathering") errCnt.WithLabelValues("encoding") if err := opts.Registry.Register(errCnt); err != nil { @@ -303,8 +303,12 @@ type Logger interface { // HandlerOpts specifies options how to serve metrics via an http.Handler. The // zero value of HandlerOpts is a reasonable default. type HandlerOpts struct { - // ErrorLog specifies an optional logger for errors collecting and - // serving metrics. If nil, errors are not logged at all. + // ErrorLog specifies an optional Logger for errors collecting and + // serving metrics. If nil, errors are not logged at all. Note that the + // type of a reported error is often prometheus.MultiError, which + // formats into a multi-line error string. If you want to avoid the + // latter, create a Logger implementation that detects a + // prometheus.MultiError and formats the contained errors into one line. ErrorLog Logger // ErrorHandling defines how errors are handled. Note that errors are // logged regardless of the configured ErrorHandling provided ErrorLog diff --git a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go index 9db2438053..ab037db861 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go @@ -43,14 +43,14 @@ func InstrumentHandlerInFlight(g prometheus.Gauge, next http.Handler) http.Handl // InstrumentHandlerDuration is a middleware that wraps the provided // http.Handler to observe the request duration with the provided ObserverVec. -// The ObserverVec must have zero, one, or two non-const non-curried labels. For -// those, the only allowed label names are "code" and "method". The function -// panics otherwise. The Observe method of the Observer in the ObserverVec is -// called with the request duration in seconds. Partitioning happens by HTTP -// status code and/or HTTP method if the respective instance label names are -// present in the ObserverVec. For unpartitioned observations, use an -// ObserverVec with zero labels. Note that partitioning of Histograms is -// expensive and should be used judiciously. +// The ObserverVec must have valid metric and label names and must have zero, +// one, or two non-const non-curried labels. For those, the only allowed label +// names are "code" and "method". The function panics otherwise. The Observe +// method of the Observer in the ObserverVec is called with the request duration +// in seconds. Partitioning happens by HTTP status code and/or HTTP method if +// the respective instance label names are present in the ObserverVec. For +// unpartitioned observations, use an ObserverVec with zero labels. Note that +// partitioning of Histograms is expensive and should be used judiciously. // // If the wrapped Handler does not set a status code, a status code of 200 is assumed. // @@ -79,12 +79,13 @@ func InstrumentHandlerDuration(obs prometheus.ObserverVec, next http.Handler) ht } // InstrumentHandlerCounter is a middleware that wraps the provided http.Handler -// to observe the request result with the provided CounterVec. The CounterVec -// must have zero, one, or two non-const non-curried labels. For those, the only -// allowed label names are "code" and "method". The function panics -// otherwise. Partitioning of the CounterVec happens by HTTP status code and/or -// HTTP method if the respective instance label names are present in the -// CounterVec. For unpartitioned counting, use a CounterVec with zero labels. +// to observe the request result with the provided CounterVec. The CounterVec +// must have valid metric and label names and must have zero, one, or two +// non-const non-curried labels. For those, the only allowed label names are +// "code" and "method". The function panics otherwise. Partitioning of the +// CounterVec happens by HTTP status code and/or HTTP method if the respective +// instance label names are present in the CounterVec. For unpartitioned +// counting, use a CounterVec with zero labels. // // If the wrapped Handler does not set a status code, a status code of 200 is assumed. // @@ -110,14 +111,15 @@ func InstrumentHandlerCounter(counter *prometheus.CounterVec, next http.Handler) // InstrumentHandlerTimeToWriteHeader is a middleware that wraps the provided // http.Handler to observe with the provided ObserverVec the request duration -// until the response headers are written. The ObserverVec must have zero, one, -// or two non-const non-curried labels. For those, the only allowed label names -// are "code" and "method". The function panics otherwise. The Observe method of -// the Observer in the ObserverVec is called with the request duration in -// seconds. Partitioning happens by HTTP status code and/or HTTP method if the -// respective instance label names are present in the ObserverVec. For -// unpartitioned observations, use an ObserverVec with zero labels. Note that -// partitioning of Histograms is expensive and should be used judiciously. +// until the response headers are written. The ObserverVec must have valid +// metric and label names and must have zero, one, or two non-const non-curried +// labels. For those, the only allowed label names are "code" and "method". The +// function panics otherwise. The Observe method of the Observer in the +// ObserverVec is called with the request duration in seconds. Partitioning +// happens by HTTP status code and/or HTTP method if the respective instance +// label names are present in the ObserverVec. For unpartitioned observations, +// use an ObserverVec with zero labels. Note that partitioning of Histograms is +// expensive and should be used judiciously. // // If the wrapped Handler panics before calling WriteHeader, no value is // reported. @@ -139,15 +141,15 @@ func InstrumentHandlerTimeToWriteHeader(obs prometheus.ObserverVec, next http.Ha } // InstrumentHandlerRequestSize is a middleware that wraps the provided -// http.Handler to observe the request size with the provided ObserverVec. The -// ObserverVec must have zero, one, or two non-const non-curried labels. For -// those, the only allowed label names are "code" and "method". The function -// panics otherwise. The Observe method of the Observer in the ObserverVec is -// called with the request size in bytes. Partitioning happens by HTTP status -// code and/or HTTP method if the respective instance label names are present in -// the ObserverVec. For unpartitioned observations, use an ObserverVec with zero -// labels. Note that partitioning of Histograms is expensive and should be used -// judiciously. +// http.Handler to observe the request size with the provided ObserverVec. The +// ObserverVec must have valid metric and label names and must have zero, one, +// or two non-const non-curried labels. For those, the only allowed label names +// are "code" and "method". The function panics otherwise. The Observe method of +// the Observer in the ObserverVec is called with the request size in +// bytes. Partitioning happens by HTTP status code and/or HTTP method if the +// respective instance label names are present in the ObserverVec. For +// unpartitioned observations, use an ObserverVec with zero labels. Note that +// partitioning of Histograms is expensive and should be used judiciously. // // If the wrapped Handler does not set a status code, a status code of 200 is assumed. // @@ -174,15 +176,15 @@ func InstrumentHandlerRequestSize(obs prometheus.ObserverVec, next http.Handler) } // InstrumentHandlerResponseSize is a middleware that wraps the provided -// http.Handler to observe the response size with the provided ObserverVec. The -// ObserverVec must have zero, one, or two non-const non-curried labels. For -// those, the only allowed label names are "code" and "method". The function -// panics otherwise. The Observe method of the Observer in the ObserverVec is -// called with the response size in bytes. Partitioning happens by HTTP status -// code and/or HTTP method if the respective instance label names are present in -// the ObserverVec. For unpartitioned observations, use an ObserverVec with zero -// labels. Note that partitioning of Histograms is expensive and should be used -// judiciously. +// http.Handler to observe the response size with the provided ObserverVec. The +// ObserverVec must have valid metric and label names and must have zero, one, +// or two non-const non-curried labels. For those, the only allowed label names +// are "code" and "method". The function panics otherwise. The Observe method of +// the Observer in the ObserverVec is called with the response size in +// bytes. Partitioning happens by HTTP status code and/or HTTP method if the +// respective instance label names are present in the ObserverVec. For +// unpartitioned observations, use an ObserverVec with zero labels. Note that +// partitioning of Histograms is expensive and should be used judiciously. // // If the wrapped Handler does not set a status code, a status code of 200 is assumed. // @@ -198,6 +200,11 @@ func InstrumentHandlerResponseSize(obs prometheus.ObserverVec, next http.Handler }) } +// checkLabels returns whether the provided Collector has a non-const, +// non-curried label named "code" and/or "method". It panics if the provided +// Collector does not have a Desc or has more than one Desc or its Desc is +// invalid. It also panics if the Collector has any non-const, non-curried +// labels that are not named "code" or "method". func checkLabels(c prometheus.Collector) (code bool, method bool) { // TODO(beorn7): Remove this hacky way to check for instance labels // once Descriptors can have their dimensionality queried. @@ -225,6 +232,10 @@ func checkLabels(c prometheus.Collector) (code bool, method bool) { close(descc) + // Make sure the Collector has a valid Desc by registering it with a + // temporary registry. + prometheus.NewRegistry().MustRegister(c) + // Create a ConstMetric with the Desc. Since we don't know how many // variable labels there are, try for as long as it needs. for err := errors.New("dummy"); err != nil; lvs = append(lvs, magicString) { diff --git a/vendor/github.com/prometheus/client_golang/prometheus/registry.go b/vendor/github.com/prometheus/client_golang/prometheus/registry.go index ba94405af4..48f5ef9d72 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/registry.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/registry.go @@ -215,6 +215,8 @@ func (err AlreadyRegisteredError) Error() string { // by a Gatherer to report multiple errors during MetricFamily gathering. type MultiError []error +// Error formats the contained errors as a bullet point list, preceded by the +// total number of errors. Note that this results in a multi-line string. func (errs MultiError) Error() string { if len(errs) == 0 { return "" diff --git a/vendor/github.com/prometheus/common/model/time.go b/vendor/github.com/prometheus/common/model/time.go index c40e6403ca..e684ebd11a 100644 --- a/vendor/github.com/prometheus/common/model/time.go +++ b/vendor/github.com/prometheus/common/model/time.go @@ -14,6 +14,7 @@ package model import ( + "encoding/json" "fmt" "math" "regexp" @@ -254,6 +255,37 @@ func (d Duration) String() string { return r } +// MarshalJSON implements the json.Marshaler interface. +func (d Duration) MarshalJSON() ([]byte, error) { + return json.Marshal(d.String()) +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (d *Duration) UnmarshalJSON(bytes []byte) error { + var s string + if err := json.Unmarshal(bytes, &s); err != nil { + return err + } + dur, err := ParseDuration(s) + if err != nil { + return err + } + *d = dur + return nil +} + +// MarshalText implements the encoding.TextMarshaler interface. +func (d *Duration) MarshalText() ([]byte, error) { + return []byte(d.String()), nil +} + +// UnmarshalText implements the encoding.TextUnmarshaler interface. +func (d *Duration) UnmarshalText(text []byte) error { + var err error + *d, err = ParseDuration(string(text)) + return err +} + // MarshalYAML implements the yaml.Marshaler interface. func (d Duration) MarshalYAML() (interface{}, error) { return d.String(), nil diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/config/feature_flags.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/config/feature_flags.go index 007b2a869e..5073ea5d16 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/config/feature_flags.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/config/feature_flags.go @@ -20,11 +20,14 @@ import ( "fmt" "os" "strconv" + "strings" corev1 "k8s.io/api/core/v1" ) const ( + StableAPIFields = "stable" + AlphaAPIFields = "alpha" disableHomeEnvOverwriteKey = "disable-home-env-overwrite" disableWorkingDirOverwriteKey = "disable-working-directory-overwrite" disableAffinityAssistantKey = "disable-affinity-assistant" @@ -33,14 +36,16 @@ const ( requireGitSSHSecretKnownHostsKey = "require-git-ssh-secret-known-hosts" // nolint: gosec enableTektonOCIBundles = "enable-tekton-oci-bundles" enableCustomTasks = "enable-custom-tasks" - DefaultDisableHomeEnvOverwrite = false - DefaultDisableWorkingDirOverwrite = false + enableAPIFields = "enable-api-fields" + DefaultDisableHomeEnvOverwrite = true + DefaultDisableWorkingDirOverwrite = true DefaultDisableAffinityAssistant = false DefaultDisableCredsInit = false DefaultRunningInEnvWithInjectedSidecars = true DefaultRequireGitSSHSecretKnownHosts = false DefaultEnableTektonOciBundles = false DefaultEnableCustomTasks = false + DefaultEnableAPIFields = StableAPIFields ) // FeatureFlags holds the features configurations @@ -54,6 +59,7 @@ type FeatureFlags struct { RequireGitSSHSecretKnownHosts bool EnableTektonOCIBundles bool EnableCustomTasks bool + EnableAPIFields string } // GetFeatureFlagsConfigName returns the name of the configmap containing all @@ -99,15 +105,46 @@ func NewFeatureFlagsFromMap(cfgMap map[string]string) (*FeatureFlags, error) { if err := setFeature(requireGitSSHSecretKnownHostsKey, DefaultRequireGitSSHSecretKnownHosts, &tc.RequireGitSSHSecretKnownHosts); err != nil { return nil, err } - if err := setFeature(enableTektonOCIBundles, DefaultEnableTektonOciBundles, &tc.EnableTektonOCIBundles); err != nil { + if err := setEnabledAPIFields(cfgMap, DefaultEnableAPIFields, &tc.EnableAPIFields); err != nil { return nil, err } - if err := setFeature(enableCustomTasks, DefaultEnableCustomTasks, &tc.EnableCustomTasks); err != nil { - return nil, err + + // Given that they are alpha features, Tekton Bundles and Custom Tasks should be switched on if + // enable-api-fields is "alpha". If enable-api-fields is not "alpha" then fall back to the value of + // each feature's individual flag. + // + // Note: the user cannot enable "alpha" while disabling bundles or custom tasks - that would + // defeat the purpose of having a single shared gate for all alpha features. + if tc.EnableAPIFields == AlphaAPIFields { + tc.EnableTektonOCIBundles = true + tc.EnableCustomTasks = true + } else { + if err := setFeature(enableTektonOCIBundles, DefaultEnableTektonOciBundles, &tc.EnableTektonOCIBundles); err != nil { + return nil, err + } + if err := setFeature(enableCustomTasks, DefaultEnableCustomTasks, &tc.EnableCustomTasks); err != nil { + return nil, err + } } return &tc, nil } +// setEnabledAPIFields sets the "enable-api-fields" flag based on the content of a given map. +// If the feature gate is invalid or missing then an error is returned. +func setEnabledAPIFields(cfgMap map[string]string, defaultValue string, feature *string) error { + value := defaultValue + if cfg, ok := cfgMap[enableAPIFields]; ok { + value = strings.ToLower(cfg) + } + switch value { + case AlphaAPIFields, StableAPIFields: + *feature = value + default: + return fmt.Errorf("invalid value for feature flag %q: %q", enableAPIFields, value) + } + return nil +} + // NewFeatureFlagsFromConfigMap returns a Config for the given configmap func NewFeatureFlagsFromConfigMap(config *corev1.ConfigMap) (*FeatureFlags, error) { return NewFeatureFlagsFromMap(config.Data) diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/pod/template.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/pod/template.go index f5244b795f..7d5488e3b5 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/pod/template.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/pod/template.go @@ -101,6 +101,11 @@ type Template struct { // +optional ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"` + // HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts + // file if specified. This is only valid for non-hostNetwork pods. + // +optional + HostAliases []corev1.HostAlias `json:"hostAliases,omitempty"` + // HostNetwork specifies whether the pod may use the node network namespace // +optional HostNetwork bool `json:"hostNetwork,omitempty"` diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/pod/zz_generated.deepcopy.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/pod/zz_generated.deepcopy.go index 77cb864fed..c87df89163 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/pod/zz_generated.deepcopy.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/pod/zz_generated.deepcopy.go @@ -93,6 +93,13 @@ func (in *Template) DeepCopyInto(out *Template) { *out = make([]v1.LocalObjectReference, len(*in)) copy(*out, *in) } + if in.HostAliases != nil { + in, out := &in.HostAliases, &out.HostAliases + *out = make([]v1.HostAlias, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/openapi_generated.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/openapi_generated.go index c4b9c992f8..8b47e4b412 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/openapi_generated.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/openapi_generated.go @@ -99,6 +99,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceBinding": schema_pkg_apis_pipeline_v1beta1_WorkspaceBinding(ref), "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceDeclaration": schema_pkg_apis_pipeline_v1beta1_WorkspaceDeclaration(ref), "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspacePipelineTaskBinding": schema_pkg_apis_pipeline_v1beta1_WorkspacePipelineTaskBinding(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceUsage": schema_pkg_apis_pipeline_v1beta1_WorkspaceUsage(ref), "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResource": schema_pkg_apis_resource_v1alpha1_PipelineResource(ref), "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceList": schema_pkg_apis_resource_v1alpha1_PipelineResourceList(ref), "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1.PipelineResourceSpec": schema_pkg_apis_resource_v1alpha1_PipelineResourceSpec(ref), @@ -240,6 +241,20 @@ func schema_pkg_apis_pipeline_pod_Template(ref common.ReferenceCallback) common. }, }, }, + "hostAliases": { + SchemaProps: spec.SchemaProps{ + Description: "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.HostAlias"), + }, + }, + }, + }, + }, "hostNetwork": { SchemaProps: spec.SchemaProps{ Description: "HostNetwork specifies whether the pod may use the node network namespace", @@ -251,7 +266,7 @@ func schema_pkg_apis_pipeline_pod_Template(ref common.ReferenceCallback) common. }, }, Dependencies: []string{ - "k8s.io/api/core/v1.Affinity", "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/api/core/v1.PodDNSConfig", "k8s.io/api/core/v1.PodSecurityContext", "k8s.io/api/core/v1.Toleration", "k8s.io/api/core/v1.Volume"}, + "k8s.io/api/core/v1.Affinity", "k8s.io/api/core/v1.HostAlias", "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/api/core/v1.PodDNSConfig", "k8s.io/api/core/v1.PodSecurityContext", "k8s.io/api/core/v1.Toleration", "k8s.io/api/core/v1.Volume"}, } } @@ -2672,12 +2687,26 @@ func schema_pkg_apis_pipeline_v1beta1_Sidecar(ref common.ReferenceCallback) comm Format: "", }, }, + "Workspaces": { + SchemaProps: spec.SchemaProps{ + Description: "This is an alpha field. You must set the \"enable-api-fields\" feature flag to \"alpha\" for this field to be supported.\n\nWorkspaces is a list of workspaces from the Task that this Sidecar wants exclusive access to. Adding a workspace to this list means that any other Step or Sidecar that does not also request this Workspace will not have access to it.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceUsage"), + }, + }, + }, + }, + }, }, Required: []string{"name"}, }, }, Dependencies: []string{ - "k8s.io/api/core/v1.ContainerPort", "k8s.io/api/core/v1.EnvFromSource", "k8s.io/api/core/v1.EnvVar", "k8s.io/api/core/v1.Lifecycle", "k8s.io/api/core/v1.Probe", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.SecurityContext", "k8s.io/api/core/v1.VolumeDevice", "k8s.io/api/core/v1.VolumeMount"}, + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceUsage", "k8s.io/api/core/v1.ContainerPort", "k8s.io/api/core/v1.EnvFromSource", "k8s.io/api/core/v1.EnvVar", "k8s.io/api/core/v1.Lifecycle", "k8s.io/api/core/v1.Probe", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.SecurityContext", "k8s.io/api/core/v1.VolumeDevice", "k8s.io/api/core/v1.VolumeMount"}, } } @@ -3020,12 +3049,26 @@ func schema_pkg_apis_pipeline_v1beta1_Step(ref common.ReferenceCallback) common. Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Duration"), }, }, + "workspaces": { + SchemaProps: spec.SchemaProps{ + Description: "This is an alpha field. You must set the \"enable-api-fields\" feature flag to \"alpha\" for this field to be supported.\n\nWorkspaces is a list of workspaces from the Task that this Step wants exclusive access to. Adding a workspace to this list means that any other Step or Sidecar that does not also request this Workspace will not have access to it.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceUsage"), + }, + }, + }, + }, + }, }, Required: []string{"name"}, }, }, Dependencies: []string{ - "k8s.io/api/core/v1.ContainerPort", "k8s.io/api/core/v1.EnvFromSource", "k8s.io/api/core/v1.EnvVar", "k8s.io/api/core/v1.Lifecycle", "k8s.io/api/core/v1.Probe", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.SecurityContext", "k8s.io/api/core/v1.VolumeDevice", "k8s.io/api/core/v1.VolumeMount", "k8s.io/apimachinery/pkg/apis/meta/v1.Duration"}, + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.WorkspaceUsage", "k8s.io/api/core/v1.ContainerPort", "k8s.io/api/core/v1.EnvFromSource", "k8s.io/api/core/v1.EnvVar", "k8s.io/api/core/v1.Lifecycle", "k8s.io/api/core/v1.Probe", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.SecurityContext", "k8s.io/api/core/v1.VolumeDevice", "k8s.io/api/core/v1.VolumeMount", "k8s.io/apimachinery/pkg/apis/meta/v1.Duration"}, } } @@ -4135,13 +4178,6 @@ func schema_pkg_apis_pipeline_v1beta1_WhenExpression(ref common.ReferenceCallbac Format: "", }, }, - "Input": { - SchemaProps: spec.SchemaProps{ - Description: "DeprecatedInput for backwards compatibility with 0 { return &apis.FieldError{ - Message: "Invalid resource name: special character . must not be present", + Message: fmt.Sprintf("invalid resource name %q: must be a valid DNS label", name), Paths: []string{"name"}, } } diff --git a/vendor/github.com/tektoncd/pipeline/pkg/client/injection/client/client.go b/vendor/github.com/tektoncd/pipeline/pkg/client/injection/client/client.go index 13c3847a39..043293206c 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/client/injection/client/client.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/client/injection/client/client.go @@ -29,6 +29,9 @@ import ( func init() { injection.Default.RegisterClient(withClient) + injection.Default.RegisterClientFetcher(func(ctx context.Context) interface{} { + return Get(ctx) + }) } // Key is used as the key for associating information with a context.Context. diff --git a/vendor/github.com/tektoncd/pipeline/pkg/client/injection/client/fake/fake.go b/vendor/github.com/tektoncd/pipeline/pkg/client/injection/client/fake/fake.go index b3cff4152c..a2814d38ac 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/client/injection/client/fake/fake.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/client/injection/client/fake/fake.go @@ -31,6 +31,9 @@ import ( func init() { injection.Fake.RegisterClient(withClient) + injection.Fake.RegisterClientFetcher(func(ctx context.Context) interface{} { + return Get(ctx) + }) } func withClient(ctx context.Context, cfg *rest.Config) context.Context { diff --git a/vendor/github.com/tektoncd/pipeline/pkg/client/resource/injection/client/client.go b/vendor/github.com/tektoncd/pipeline/pkg/client/resource/injection/client/client.go index f514060dab..10c74d9efc 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/client/resource/injection/client/client.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/client/resource/injection/client/client.go @@ -29,6 +29,9 @@ import ( func init() { injection.Default.RegisterClient(withClient) + injection.Default.RegisterClientFetcher(func(ctx context.Context) interface{} { + return Get(ctx) + }) } // Key is used as the key for associating information with a context.Context. diff --git a/vendor/github.com/tektoncd/pipeline/pkg/client/resource/injection/client/fake/fake.go b/vendor/github.com/tektoncd/pipeline/pkg/client/resource/injection/client/fake/fake.go index 88a4e25672..1447b8e6ac 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/client/resource/injection/client/fake/fake.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/client/resource/injection/client/fake/fake.go @@ -31,6 +31,9 @@ import ( func init() { injection.Fake.RegisterClient(withClient) + injection.Fake.RegisterClientFetcher(func(ctx context.Context) interface{} { + return Get(ctx) + }) } func withClient(ctx context.Context, cfg *rest.Config) context.Context { diff --git a/vendor/github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag/dag.go b/vendor/github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag/dag.go index 703747b892..abd2d3d229 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag/dag.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag/dag.go @@ -46,7 +46,7 @@ type Node struct { // Graph represents the Pipeline Graph type Graph struct { - //Nodes represent map of PipelineTask name to Node in Pipeline Graph + // Nodes represent map of PipelineTask name to Node in Pipeline Graph Nodes map[string]*Node } diff --git a/vendor/github.com/tektoncd/pipeline/pkg/remote/oci/resolver.go b/vendor/github.com/tektoncd/pipeline/pkg/remote/oci/resolver.go index 8e85acfad5..9b13fca0bb 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/remote/oci/resolver.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/remote/oci/resolver.go @@ -22,6 +22,7 @@ import ( "fmt" "io" "io/ioutil" + "strings" "time" "github.com/google/go-containerregistry/pkg/authn" @@ -104,12 +105,21 @@ func (o *Resolver) Get(kind, name string) (runtime.Object, error) { return nil, fmt.Errorf("could not read image layers: %w", err) } + layerMap := map[string]v1.Layer{} + for _, l := range layers { + digest, err := l.Digest() + if err != nil { + return nil, fmt.Errorf("failed to find digest for layer: %w", err) + } + layerMap[digest.String()] = l + } + for idx, l := range manifest.Layers { lKind := l.Annotations[KindAnnotation] lName := l.Annotations[TitleAnnotation] if kind == lKind && name == lName { - obj, err := readTarLayer(layers[idx]) + obj, err := readTarLayer(layerMap[l.Digest.String()]) if err != nil { // This could still be a raw layer so try to read it as that instead. return readRawLayer(layers[idx]) @@ -135,6 +145,27 @@ func (o *Resolver) checkImageCompliance(manifest *v1.Manifest) error { if len(manifest.Layers) > MaximumBundleObjects { return fmt.Errorf("bundle %s contained more than the maximum %d allow objects", o.imageReference, MaximumBundleObjects) } + + // Ensure each layer complies to the spec. + for _, l := range manifest.Layers { + refDigest := fmt.Sprintf("%s:%s", o.imageReference, l.Digest.String()) + if _, ok := l.Annotations[APIVersionAnnotation]; !ok { + return fmt.Errorf("invalid tekton bundle: %s does not contain a %s annotation", refDigest, APIVersionAnnotation) + } + + if _, ok := l.Annotations[TitleAnnotation]; !ok { + return fmt.Errorf("invalid tekton bundle: %s does not contain a %s annotation", refDigest, TitleAnnotation) + } + + kind, ok := l.Annotations[KindAnnotation] + if !ok { + return fmt.Errorf("invalid tekton bundle: %s does not contain a %s annotation", refDigest, KindAnnotation) + } + if strings.TrimSuffix(strings.ToLower(kind), "s") != kind { + return fmt.Errorf("invalid tekton bundle: %s annotation for %s must be lowercased and singular, found %s", KindAnnotation, refDigest, kind) + } + } + return nil } diff --git a/vendor/github.com/tektoncd/pipeline/test/e2e-tests.sh b/vendor/github.com/tektoncd/pipeline/test/e2e-tests.sh index 9fd4694004..8480bbc1af 100644 --- a/vendor/github.com/tektoncd/pipeline/test/e2e-tests.sh +++ b/vendor/github.com/tektoncd/pipeline/test/e2e-tests.sh @@ -29,14 +29,34 @@ install_pipeline_crd failed=0 -# Run the integration tests -header "Running Go e2e tests" -go_test_e2e -timeout=20m ./test/... || failed=1 - -# Run these _after_ the integration tests b/c they don't quite work all the way -# and they cause a lot of noise in the logs, making it harder to debug integration -# test failures. -go_test_e2e -tags=examples -timeout=20m ./test/ || failed=1 +function set_feature_gate() { + local gate="$1" + if [ "$gate" != "alpha" ] && [ "$gate" != "stable" ] && [ "$gate" != "beta" ] ; then + printf "Invalid gate %s\n" ${gate} + exit 255 + fi + printf "Setting feature gate to %s\n", ${gate} + jsonpatch=$(printf "{\"data\": {\"enable-api-fields\": \"%s\"}}" $1) + echo "feature-flags ConfigMap patch: ${jsonpatch}" + kubectl patch configmap feature-flags -n tekton-pipelines -p "$jsonpatch" +} + +function run_e2e() { + # Run the integration tests + header "Running Go e2e tests" + go_test_e2e -timeout=20m ./test/... || failed=1 + + # Run these _after_ the integration tests b/c they don't quite work all the way + # and they cause a lot of noise in the logs, making it harder to debug integration + # test failures. + go_test_e2e -tags=examples -timeout=20m ./test/ || failed=1 +} + +set_feature_gate "stable" +run_e2e + +set_feature_gate "alpha" +run_e2e (( failed )) && fail_test success diff --git a/vendor/github.com/tektoncd/pipeline/test/gate.go b/vendor/github.com/tektoncd/pipeline/test/gate.go new file mode 100644 index 0000000000..13292e1c41 --- /dev/null +++ b/vendor/github.com/tektoncd/pipeline/test/gate.go @@ -0,0 +1,34 @@ +package test + +import ( + "context" + "fmt" + "strings" + "testing" + + "github.com/tektoncd/pipeline/pkg/apis/config" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/system" +) + +// requireAnyGate returns a setup func that will skip the current +// test if none of the feature-flags in the given map match +// what's in the feature-flags ConfigMap. It will fatally fail +// the test if it cannot get the feature-flag configmap. +func requireAnyGate(gates map[string]string) func(context.Context, *testing.T, *clients, string) { + return func(ctx context.Context, t *testing.T, c *clients, namespace string) { + featureFlagsCM, err := c.KubeClient.CoreV1().ConfigMaps(system.Namespace()).Get(ctx, config.GetFeatureFlagsConfigName(), metav1.GetOptions{}) + if err != nil { + t.Fatalf("Failed to get ConfigMap `%s`: %s", config.GetFeatureFlagsConfigName(), err) + } + pairs := []string{} + for name, value := range gates { + actual, ok := featureFlagsCM.Data[name] + if ok && value == actual { + return + } + pairs = append(pairs, fmt.Sprintf("%q: %q", name, value)) + } + t.Skipf("No feature flag matching %s", strings.Join(pairs, " or ")) + } +} diff --git a/vendor/github.com/tektoncd/pipeline/test/multiarch_utils.go b/vendor/github.com/tektoncd/pipeline/test/multiarch_utils.go index cb355fb7b3..e01788f26c 100644 --- a/vendor/github.com/tektoncd/pipeline/test/multiarch_utils.go +++ b/vendor/github.com/tektoncd/pipeline/test/multiarch_utils.go @@ -36,11 +36,11 @@ const ( busyboxImage = iota // Registry image registryImage - //kubectl image + // kubectl image kubectlImage - //helm image + // helm image helmImage - //kaniko executor image + // kaniko executor image kanikoImage // dockerize image dockerizeImage @@ -147,7 +147,7 @@ func initExcludedTests() sets.String { switch getTestArch() { case "s390x": return sets.NewString( - //examples + // examples "TestExamples/v1alpha1/taskruns/gcs-resource", "TestExamples/v1beta1/taskruns/gcs-resource", "TestExamples/v1beta1/pipelineruns/pipelinerun", @@ -155,7 +155,7 @@ func initExcludedTests() sets.String { ) case "ppc64le": return sets.NewString( - //examples + // examples "TestExamples/v1alpha1/taskruns/gcs-resource", "TestExamples/v1beta1/taskruns/gcs-resource", "TestExamples/v1beta1/pipelineruns/pipelinerun", diff --git a/vendor/github.com/tektoncd/pipeline/test/path_filtering.go b/vendor/github.com/tektoncd/pipeline/test/path_filtering.go new file mode 100644 index 0000000000..aab714f88e --- /dev/null +++ b/vendor/github.com/tektoncd/pipeline/test/path_filtering.go @@ -0,0 +1,99 @@ +// +build examples + +/* +Copyright 2021 The Tekton 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 test + +import ( + "bytes" + "fmt" + "os" + "os/exec" + "strings" + "testing" +) + +type pathFilter func(string) bool + +const ( + systemNamespaceEnvVar = "SYSTEM_NAMESPACE" + defaultSystemNamespace = "tekton-pipelines" +) + +// getPathFilter returns a pathFilter that filters out examples +// unsuitable for the current feature-gate. For example, +// if the enable-api-fields feature flag is currently set +// to "alpha" then all stable and alpha examples would be +// allowed. When the flag is set to "stable", only stable +// examples are allowed. +func getPathFilter(t *testing.T) (pathFilter, error) { + ns := os.Getenv(systemNamespaceEnvVar) + if ns == "" { + ns = defaultSystemNamespace + } + enabledFeatureGate, err := getFeatureGate(ns) + if err != nil { + return nil, fmt.Errorf("error reading enabled feature gate: %v", err) + } + var f pathFilter + switch enabledFeatureGate { + case "stable": + f = stablePathFilter + case "alpha": + f = alphaPathFilter + } + if f == nil { + return nil, fmt.Errorf("unable to create path filter from feature gate %q", enabledFeatureGate) + } + t.Logf("Allowing only %q examples", enabledFeatureGate) + return f, nil +} + +// Memoize value of enable-api-fields flag so we don't +// need to repeatedly query the feature flag configmap +var enableAPIFields = "" + +// getFeatureGate queries the tekton pipelines namespace for the +// current value of the "enable-api-fields" feature gate. +func getFeatureGate(namespace string) (string, error) { + if enableAPIFields == "" { + cmd := exec.Command("kubectl", "get", "configmap", "feature-flags", "-n", namespace, "-o", `jsonpath="{.data['enable-api-fields']}"`) + output, err := cmd.Output() + if err != nil { + return "", fmt.Errorf("error getting feature-flags configmap: %v", err) + } + output = bytes.TrimSpace(output) + output = bytes.Trim(output, "\"") + if len(output) == 0 { + output = []byte("stable") + } + enableAPIFields = string(output) + } + return enableAPIFields, nil +} + +// stablePathFilter returns true for any example that should be allowed to run +// when "enable-api-fields" is "stable". +func stablePathFilter(p string) bool { + return !(strings.Contains(p, "/alpha/") || strings.Contains(p, "/beta/")) +} + +// alphaPathFilter returns true for any example that should be allowed to run +// when "enable-api-fields" is "alpha". +func alphaPathFilter(p string) bool { + return strings.Contains(p, "/alpha/") || strings.Contains(p, "/beta/") || stablePathFilter(p) +} diff --git a/vendor/github.com/tektoncd/pipeline/test/remote.go b/vendor/github.com/tektoncd/pipeline/test/remote.go index bed6a417ba..f0ff11807f 100644 --- a/vendor/github.com/tektoncd/pipeline/test/remote.go +++ b/vendor/github.com/tektoncd/pipeline/test/remote.go @@ -33,10 +33,30 @@ import ( "k8s.io/apimachinery/pkg/runtime" ) +// ObjectAnnotationMapper is a func alias that maps a runtime Object to the Tekton Bundle annotations map. +type ObjectAnnotationMapper func(object runtime.Object) map[string]string + +var ( + // DefaultObjectAnnotationMapper does the "right" thing by conforming to the Tekton Bundle spec. + DefaultObjectAnnotationMapper = func(obj runtime.Object) map[string]string { + return map[string]string{ + tkremote.TitleAnnotation: getObjectName(obj), + tkremote.KindAnnotation: strings.TrimSuffix(strings.ToLower(obj.GetObjectKind().GroupVersionKind().Kind), "s"), + tkremote.APIVersionAnnotation: obj.GetObjectKind().GroupVersionKind().Version, + } + } +) + // CreateImage will push a new OCI image artifact with the provided raw data object as a layer and return the full image // reference with a digest to fetch the image. Key must be specified as [lowercase kind]/[object name]. The image ref // with a digest is returned. func CreateImage(ref string, objs ...runtime.Object) (string, error) { + return CreateImageWithAnnotations(ref, DefaultObjectAnnotationMapper, objs...) +} + +// CreateImageWithAnnotations is the base form of #CreateImage which accepts an ObjectAnnotationMapper to map an object +// to the annotations for it. +func CreateImageWithAnnotations(ref string, mapper ObjectAnnotationMapper, objs ...runtime.Object) (string, error) { imgRef, err := name.ParseReference(ref) if err != nil { return "", fmt.Errorf("undexpected error producing image reference %w", err) @@ -73,13 +93,10 @@ func CreateImage(ref string, objs ...runtime.Object) (string, error) { return "", fmt.Errorf("unexpected error adding layer to image %w", err) } + annotations := mapper(obj) img, err = mutate.Append(img, mutate.Addendum{ - Layer: layer, - Annotations: map[string]string{ - tkremote.TitleAnnotation: getObjectName(obj), - tkremote.KindAnnotation: strings.ToLower(obj.GetObjectKind().GroupVersionKind().Kind), - tkremote.APIVersionAnnotation: strings.ToLower(obj.GetObjectKind().GroupVersionKind().Version), - }, + Layer: layer, + Annotations: annotations, }) if err != nil { return "", fmt.Errorf("could not add layer to image %w", err) diff --git a/vendor/github.com/tektoncd/pipeline/test/yaml.go b/vendor/github.com/tektoncd/pipeline/test/yaml.go new file mode 100644 index 0000000000..3118b851ff --- /dev/null +++ b/vendor/github.com/tektoncd/pipeline/test/yaml.go @@ -0,0 +1,67 @@ +/* +Copyright 2021 The Tekton 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 test + +import ( + "testing" + + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/scheme" + "k8s.io/apimachinery/pkg/runtime" +) + +func mustParseYAML(t *testing.T, yaml string, i runtime.Object) { + if _, _, err := scheme.Codecs.UniversalDeserializer().Decode([]byte(yaml), nil, i); err != nil { + t.Fatalf("mustParseYAML (%s): %v", yaml, err) + } +} + +func mustParseTaskRun(t *testing.T, yaml string) *v1beta1.TaskRun { + var tr v1beta1.TaskRun + yaml = `apiVersion: tekton.dev/v1beta1 +kind: TaskRun +` + yaml + mustParseYAML(t, yaml, &tr) + return &tr +} + +func mustParseTask(t *testing.T, yaml string) *v1beta1.Task { + var task v1beta1.Task + yaml = `apiVersion: tekton.dev/v1beta1 +kind: Task +` + yaml + mustParseYAML(t, yaml, &task) + return &task +} + +func mustParsePipelineRun(t *testing.T, yaml string) *v1beta1.PipelineRun { + var pr v1beta1.PipelineRun + yaml = `apiVersion: tekton.dev/v1beta1 +kind: PipelineRun +` + yaml + mustParseYAML(t, yaml, &pr) + return &pr +} + +func mustParsePipeline(t *testing.T, yaml string) *v1beta1.Pipeline { + var pipeline v1beta1.Pipeline + yaml = `apiVersion: tekton.dev/v1beta1 +kind: Pipeline +` + yaml + mustParseYAML(t, yaml, &pipeline) + return &pipeline +} diff --git a/vendor/go.opencensus.io/.travis.yml b/vendor/go.opencensus.io/.travis.yml deleted file mode 100644 index bd6b66ee83..0000000000 --- a/vendor/go.opencensus.io/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: go - -go_import_path: go.opencensus.io - -go: - - 1.11.x - -env: - global: - GO111MODULE=on - -before_script: - - make install-tools - -script: - - make travis-ci - - go run internal/check/version.go # TODO move this to makefile diff --git a/vendor/go.opencensus.io/go.mod b/vendor/go.opencensus.io/go.mod index 2970715626..95b2522a7f 100644 --- a/vendor/go.opencensus.io/go.mod +++ b/vendor/go.opencensus.io/go.mod @@ -1,15 +1,12 @@ module go.opencensus.io require ( - github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 - github.com/golang/protobuf v1.3.1 - github.com/google/go-cmp v0.3.0 - github.com/stretchr/testify v1.4.0 - golang.org/x/net v0.0.0-20190620200207-3b0461eec859 - golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd // indirect - golang.org/x/text v0.3.3 // indirect - google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb // indirect - google.golang.org/grpc v1.20.1 + github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e + github.com/golang/protobuf v1.4.3 + github.com/google/go-cmp v0.5.3 + github.com/stretchr/testify v1.6.1 + golang.org/x/net v0.0.0-20201110031124-69a78807bb2b + google.golang.org/grpc v1.33.2 ) go 1.13 diff --git a/vendor/go.opencensus.io/go.sum b/vendor/go.opencensus.io/go.sum index 01c02972c7..c97cd1b551 100644 --- a/vendor/go.opencensus.io/go.sum +++ b/vendor/go.opencensus.io/go.sum @@ -1,25 +1,47 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 h1:ZgQEtGgCBiWRM39fZuwSd1LwSqqSW0hOdXCYYDX0R3I= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3 h1:x95R7cp+rSeeqAMI2knLtQ0DKlaBhv2NrtrOvafPHRo= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -30,24 +52,25 @@ golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd h1:r7DufRZuZbWB7j439YfAzP8RPDa9unLkpwQKUYbIMPI= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -55,20 +78,39 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3 golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd h1:/e+gpKk9r3dJobndpTytxS2gOy6m5uvpg+ISQoEcusQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb h1:i1Ppqkc3WQXikh8bXiwHqAN5Rv3/qDCcRk0/Otx73BY= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8= google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1 h1:Hz2g2wirWK7H0qIIhGIqRGTuMwTE8HEKFnDZZ7lm9NU= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/vendor/go.opencensus.io/metric/metricexport/reader.go b/vendor/go.opencensus.io/metric/metricexport/reader.go index b920bacd87..8a09d0f007 100644 --- a/vendor/go.opencensus.io/metric/metricexport/reader.go +++ b/vendor/go.opencensus.io/metric/metricexport/reader.go @@ -130,7 +130,7 @@ func (ir *IntervalReader) Start() error { reportingInterval = ir.ReportingInterval } - if ir.done != nil { + if ir.quit != nil { return errAlreadyStarted } ir.timer = time.NewTicker(reportingInterval) @@ -172,6 +172,19 @@ func (ir *IntervalReader) Stop() { ir.quit = nil } +// Flush flushes the metrics if IntervalReader is stopped, otherwise no-op. +func (ir *IntervalReader) Flush() { + ir.mu.Lock() + defer ir.mu.Unlock() + + // No-op if IntervalReader is not stopped + if ir.quit != nil { + return + } + + ir.reader.ReadAndExport(ir.exporter) +} + // ReadAndExport reads metrics from all producer registered with // producer manager and then exports them using provided exporter. func (r *Reader) ReadAndExport(exporter Exporter) { diff --git a/vendor/go.opencensus.io/trace/basetypes.go b/vendor/go.opencensus.io/trace/basetypes.go index 0c54492a2b..c8e26ed635 100644 --- a/vendor/go.opencensus.io/trace/basetypes.go +++ b/vendor/go.opencensus.io/trace/basetypes.go @@ -49,6 +49,16 @@ type Attribute struct { value interface{} } +// Key returns the attribute's key +func (a *Attribute) Key() string { + return a.key +} + +// Value returns the attribute's value +func (a *Attribute) Value() interface{} { + return a.value +} + // BoolAttribute returns a bool-valued attribute. func BoolAttribute(key string, value bool) Attribute { return Attribute{key: key, value: value} diff --git a/vendor/go.opencensus.io/trace/spanstore.go b/vendor/go.opencensus.io/trace/spanstore.go index c442d99021..e601f76f2c 100644 --- a/vendor/go.opencensus.io/trace/spanstore.go +++ b/vendor/go.opencensus.io/trace/spanstore.go @@ -48,8 +48,10 @@ func (i internalOnly) ReportActiveSpans(name string) []*SpanData { var out []*SpanData s.mu.Lock() defer s.mu.Unlock() - for span := range s.active { - out = append(out, span.makeSpanData()) + for activeSpan := range s.active { + if s, ok := activeSpan.(*span); ok { + out = append(out, s.makeSpanData()) + } } return out } @@ -185,7 +187,7 @@ func (i internalOnly) ReportSpansByLatency(name string, minLatency, maxLatency t // bucketed by latency. type spanStore struct { mu sync.Mutex // protects everything below. - active map[*Span]struct{} + active map[SpanInterface]struct{} errors map[int32]*bucket latency []bucket maxSpansPerErrorBucket int @@ -194,7 +196,7 @@ type spanStore struct { // newSpanStore creates a span store. func newSpanStore(name string, latencyBucketSize int, errorBucketSize int) *spanStore { s := &spanStore{ - active: make(map[*Span]struct{}), + active: make(map[SpanInterface]struct{}), latency: make([]bucket, len(defaultLatencies)+1), maxSpansPerErrorBucket: errorBucketSize, } @@ -271,7 +273,7 @@ func (s *spanStore) resize(latencyBucketSize int, errorBucketSize int) { } // add adds a span to the active bucket of the spanStore. -func (s *spanStore) add(span *Span) { +func (s *spanStore) add(span SpanInterface) { s.mu.Lock() s.active[span] = struct{}{} s.mu.Unlock() @@ -279,7 +281,7 @@ func (s *spanStore) add(span *Span) { // finished removes a span from the active set, and adds a corresponding // SpanData to a latency or error bucket. -func (s *spanStore) finished(span *Span, sd *SpanData) { +func (s *spanStore) finished(span SpanInterface, sd *SpanData) { latency := sd.EndTime.Sub(sd.StartTime) if latency < 0 { latency = 0 diff --git a/vendor/go.opencensus.io/trace/trace.go b/vendor/go.opencensus.io/trace/trace.go index daf895596a..861df9d391 100644 --- a/vendor/go.opencensus.io/trace/trace.go +++ b/vendor/go.opencensus.io/trace/trace.go @@ -28,12 +28,16 @@ import ( "go.opencensus.io/trace/tracestate" ) +type tracer struct{} + +var _ Tracer = &tracer{} + // Span represents a span of a trace. It has an associated SpanContext, and // stores data accumulated while the span is active. // // Ideally users should interact with Spans by calling the functions in this // package that take a Context parameter. -type Span struct { +type span struct { // data contains information recorded about the span. // // It will be non-nil if we are exporting the span or recording events for it. @@ -66,7 +70,7 @@ type Span struct { // IsRecordingEvents returns true if events are being recorded for this span. // Use this check to avoid computing expensive annotations when they will never // be used. -func (s *Span) IsRecordingEvents() bool { +func (s *span) IsRecordingEvents() bool { if s == nil { return false } @@ -109,13 +113,13 @@ type SpanContext struct { type contextKey struct{} // FromContext returns the Span stored in a context, or nil if there isn't one. -func FromContext(ctx context.Context) *Span { +func (t *tracer) FromContext(ctx context.Context) *Span { s, _ := ctx.Value(contextKey{}).(*Span) return s } // NewContext returns a new context with the given Span attached. -func NewContext(parent context.Context, s *Span) context.Context { +func (t *tracer) NewContext(parent context.Context, s *Span) context.Context { return context.WithValue(parent, contextKey{}, s) } @@ -166,12 +170,14 @@ func WithSampler(sampler Sampler) StartOption { // // Returned context contains the newly created span. You can use it to // propagate the returned span in process. -func StartSpan(ctx context.Context, name string, o ...StartOption) (context.Context, *Span) { +func (t *tracer) StartSpan(ctx context.Context, name string, o ...StartOption) (context.Context, *Span) { var opts StartOptions var parent SpanContext - if p := FromContext(ctx); p != nil { - p.addChild() - parent = p.spanContext + if p := t.FromContext(ctx); p != nil { + if ps, ok := p.internal.(*span); ok { + ps.addChild() + } + parent = p.SpanContext() } for _, op := range o { op(&opts) @@ -180,7 +186,8 @@ func StartSpan(ctx context.Context, name string, o ...StartOption) (context.Cont ctx, end := startExecutionTracerTask(ctx, name) span.executionTracerTaskEnd = end - return NewContext(ctx, span), span + extSpan := NewSpan(span) + return t.NewContext(ctx, extSpan), extSpan } // StartSpanWithRemoteParent starts a new child span of the span from the given parent. @@ -190,7 +197,7 @@ func StartSpan(ctx context.Context, name string, o ...StartOption) (context.Cont // // Returned context contains the newly created span. You can use it to // propagate the returned span in process. -func StartSpanWithRemoteParent(ctx context.Context, name string, parent SpanContext, o ...StartOption) (context.Context, *Span) { +func (t *tracer) StartSpanWithRemoteParent(ctx context.Context, name string, parent SpanContext, o ...StartOption) (context.Context, *Span) { var opts StartOptions for _, op := range o { op(&opts) @@ -198,12 +205,13 @@ func StartSpanWithRemoteParent(ctx context.Context, name string, parent SpanCont span := startSpanInternal(name, parent != SpanContext{}, parent, true, opts) ctx, end := startExecutionTracerTask(ctx, name) span.executionTracerTaskEnd = end - return NewContext(ctx, span), span + extSpan := NewSpan(span) + return t.NewContext(ctx, extSpan), extSpan } -func startSpanInternal(name string, hasParent bool, parent SpanContext, remoteParent bool, o StartOptions) *Span { - span := &Span{} - span.spanContext = parent +func startSpanInternal(name string, hasParent bool, parent SpanContext, remoteParent bool, o StartOptions) *span { + s := &span{} + s.spanContext = parent cfg := config.Load().(*Config) if gen, ok := cfg.IDGenerator.(*defaultIDGenerator); ok { @@ -212,9 +220,9 @@ func startSpanInternal(name string, hasParent bool, parent SpanContext, remotePa } if !hasParent { - span.spanContext.TraceID = cfg.IDGenerator.NewTraceID() + s.spanContext.TraceID = cfg.IDGenerator.NewTraceID() } - span.spanContext.SpanID = cfg.IDGenerator.NewSpanID() + s.spanContext.SpanID = cfg.IDGenerator.NewSpanID() sampler := cfg.DefaultSampler if !hasParent || remoteParent || o.Sampler != nil { @@ -226,47 +234,47 @@ func startSpanInternal(name string, hasParent bool, parent SpanContext, remotePa if o.Sampler != nil { sampler = o.Sampler } - span.spanContext.setIsSampled(sampler(SamplingParameters{ + s.spanContext.setIsSampled(sampler(SamplingParameters{ ParentContext: parent, - TraceID: span.spanContext.TraceID, - SpanID: span.spanContext.SpanID, + TraceID: s.spanContext.TraceID, + SpanID: s.spanContext.SpanID, Name: name, HasRemoteParent: remoteParent}).Sample) } - if !internal.LocalSpanStoreEnabled && !span.spanContext.IsSampled() { - return span + if !internal.LocalSpanStoreEnabled && !s.spanContext.IsSampled() { + return s } - span.data = &SpanData{ - SpanContext: span.spanContext, + s.data = &SpanData{ + SpanContext: s.spanContext, StartTime: time.Now(), SpanKind: o.SpanKind, Name: name, HasRemoteParent: remoteParent, } - span.lruAttributes = newLruMap(cfg.MaxAttributesPerSpan) - span.annotations = newEvictedQueue(cfg.MaxAnnotationEventsPerSpan) - span.messageEvents = newEvictedQueue(cfg.MaxMessageEventsPerSpan) - span.links = newEvictedQueue(cfg.MaxLinksPerSpan) + s.lruAttributes = newLruMap(cfg.MaxAttributesPerSpan) + s.annotations = newEvictedQueue(cfg.MaxAnnotationEventsPerSpan) + s.messageEvents = newEvictedQueue(cfg.MaxMessageEventsPerSpan) + s.links = newEvictedQueue(cfg.MaxLinksPerSpan) if hasParent { - span.data.ParentSpanID = parent.SpanID + s.data.ParentSpanID = parent.SpanID } if internal.LocalSpanStoreEnabled { var ss *spanStore ss = spanStoreForNameCreateIfNew(name) if ss != nil { - span.spanStore = ss - ss.add(span) + s.spanStore = ss + ss.add(s) } } - return span + return s } // End ends the span. -func (s *Span) End() { +func (s *span) End() { if s == nil { return } @@ -296,7 +304,7 @@ func (s *Span) End() { // makeSpanData produces a SpanData representing the current state of the Span. // It requires that s.data is non-nil. -func (s *Span) makeSpanData() *SpanData { +func (s *span) makeSpanData() *SpanData { var sd SpanData s.mu.Lock() sd = *s.data @@ -321,7 +329,7 @@ func (s *Span) makeSpanData() *SpanData { } // SpanContext returns the SpanContext of the span. -func (s *Span) SpanContext() SpanContext { +func (s *span) SpanContext() SpanContext { if s == nil { return SpanContext{} } @@ -329,7 +337,7 @@ func (s *Span) SpanContext() SpanContext { } // SetName sets the name of the span, if it is recording events. -func (s *Span) SetName(name string) { +func (s *span) SetName(name string) { if !s.IsRecordingEvents() { return } @@ -339,7 +347,7 @@ func (s *Span) SetName(name string) { } // SetStatus sets the status of the span, if it is recording events. -func (s *Span) SetStatus(status Status) { +func (s *span) SetStatus(status Status) { if !s.IsRecordingEvents() { return } @@ -348,7 +356,7 @@ func (s *Span) SetStatus(status Status) { s.mu.Unlock() } -func (s *Span) interfaceArrayToLinksArray() []Link { +func (s *span) interfaceArrayToLinksArray() []Link { linksArr := make([]Link, 0, len(s.links.queue)) for _, value := range s.links.queue { linksArr = append(linksArr, value.(Link)) @@ -356,7 +364,7 @@ func (s *Span) interfaceArrayToLinksArray() []Link { return linksArr } -func (s *Span) interfaceArrayToMessageEventArray() []MessageEvent { +func (s *span) interfaceArrayToMessageEventArray() []MessageEvent { messageEventArr := make([]MessageEvent, 0, len(s.messageEvents.queue)) for _, value := range s.messageEvents.queue { messageEventArr = append(messageEventArr, value.(MessageEvent)) @@ -364,7 +372,7 @@ func (s *Span) interfaceArrayToMessageEventArray() []MessageEvent { return messageEventArr } -func (s *Span) interfaceArrayToAnnotationArray() []Annotation { +func (s *span) interfaceArrayToAnnotationArray() []Annotation { annotationArr := make([]Annotation, 0, len(s.annotations.queue)) for _, value := range s.annotations.queue { annotationArr = append(annotationArr, value.(Annotation)) @@ -372,7 +380,7 @@ func (s *Span) interfaceArrayToAnnotationArray() []Annotation { return annotationArr } -func (s *Span) lruAttributesToAttributeMap() map[string]interface{} { +func (s *span) lruAttributesToAttributeMap() map[string]interface{} { attributes := make(map[string]interface{}, s.lruAttributes.len()) for _, key := range s.lruAttributes.keys() { value, ok := s.lruAttributes.get(key) @@ -384,13 +392,13 @@ func (s *Span) lruAttributesToAttributeMap() map[string]interface{} { return attributes } -func (s *Span) copyToCappedAttributes(attributes []Attribute) { +func (s *span) copyToCappedAttributes(attributes []Attribute) { for _, a := range attributes { s.lruAttributes.add(a.key, a.value) } } -func (s *Span) addChild() { +func (s *span) addChild() { if !s.IsRecordingEvents() { return } @@ -402,7 +410,7 @@ func (s *Span) addChild() { // AddAttributes sets attributes in the span. // // Existing attributes whose keys appear in the attributes parameter are overwritten. -func (s *Span) AddAttributes(attributes ...Attribute) { +func (s *span) AddAttributes(attributes ...Attribute) { if !s.IsRecordingEvents() { return } @@ -411,49 +419,27 @@ func (s *Span) AddAttributes(attributes ...Attribute) { s.mu.Unlock() } -// copyAttributes copies a slice of Attributes into a map. -func copyAttributes(m map[string]interface{}, attributes []Attribute) { - for _, a := range attributes { - m[a.key] = a.value - } -} - -func (s *Span) lazyPrintfInternal(attributes []Attribute, format string, a ...interface{}) { +func (s *span) printStringInternal(attributes []Attribute, str string) { now := time.Now() - msg := fmt.Sprintf(format, a...) - var m map[string]interface{} - s.mu.Lock() + var am map[string]interface{} if len(attributes) != 0 { - m = make(map[string]interface{}, len(attributes)) - copyAttributes(m, attributes) + am = make(map[string]interface{}, len(attributes)) + for _, attr := range attributes { + am[attr.key] = attr.value + } } - s.annotations.add(Annotation{ - Time: now, - Message: msg, - Attributes: m, - }) - s.mu.Unlock() -} - -func (s *Span) printStringInternal(attributes []Attribute, str string) { - now := time.Now() - var a map[string]interface{} s.mu.Lock() - if len(attributes) != 0 { - a = make(map[string]interface{}, len(attributes)) - copyAttributes(a, attributes) - } s.annotations.add(Annotation{ Time: now, Message: str, - Attributes: a, + Attributes: am, }) s.mu.Unlock() } // Annotate adds an annotation with attributes. // Attributes can be nil. -func (s *Span) Annotate(attributes []Attribute, str string) { +func (s *span) Annotate(attributes []Attribute, str string) { if !s.IsRecordingEvents() { return } @@ -461,11 +447,11 @@ func (s *Span) Annotate(attributes []Attribute, str string) { } // Annotatef adds an annotation with attributes. -func (s *Span) Annotatef(attributes []Attribute, format string, a ...interface{}) { +func (s *span) Annotatef(attributes []Attribute, format string, a ...interface{}) { if !s.IsRecordingEvents() { return } - s.lazyPrintfInternal(attributes, format, a...) + s.printStringInternal(attributes, fmt.Sprintf(format, a...)) } // AddMessageSendEvent adds a message send event to the span. @@ -474,7 +460,7 @@ func (s *Span) Annotatef(attributes []Attribute, format string, a ...interface{} // unique in this span and the same between the send event and the receive // event (this allows to identify a message between the sender and receiver). // For example, this could be a sequence id. -func (s *Span) AddMessageSendEvent(messageID, uncompressedByteSize, compressedByteSize int64) { +func (s *span) AddMessageSendEvent(messageID, uncompressedByteSize, compressedByteSize int64) { if !s.IsRecordingEvents() { return } @@ -496,7 +482,7 @@ func (s *Span) AddMessageSendEvent(messageID, uncompressedByteSize, compressedBy // unique in this span and the same between the send event and the receive // event (this allows to identify a message between the sender and receiver). // For example, this could be a sequence id. -func (s *Span) AddMessageReceiveEvent(messageID, uncompressedByteSize, compressedByteSize int64) { +func (s *span) AddMessageReceiveEvent(messageID, uncompressedByteSize, compressedByteSize int64) { if !s.IsRecordingEvents() { return } @@ -513,7 +499,7 @@ func (s *Span) AddMessageReceiveEvent(messageID, uncompressedByteSize, compresse } // AddLink adds a link to the span. -func (s *Span) AddLink(l Link) { +func (s *span) AddLink(l Link) { if !s.IsRecordingEvents() { return } @@ -522,7 +508,7 @@ func (s *Span) AddLink(l Link) { s.mu.Unlock() } -func (s *Span) String() string { +func (s *span) String() string { if s == nil { return "" } diff --git a/vendor/go.opencensus.io/trace/trace_api.go b/vendor/go.opencensus.io/trace/trace_api.go new file mode 100644 index 0000000000..9e2c3a9992 --- /dev/null +++ b/vendor/go.opencensus.io/trace/trace_api.go @@ -0,0 +1,265 @@ +// Copyright 2020, OpenCensus 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 trace + +import ( + "context" +) + +// DefaultTracer is the tracer used when package-level exported functions are invoked. +var DefaultTracer Tracer = &tracer{} + +// Tracer can start spans and access context functions. +type Tracer interface { + + // StartSpan starts a new child span of the current span in the context. If + // there is no span in the context, creates a new trace and span. + // + // Returned context contains the newly created span. You can use it to + // propagate the returned span in process. + StartSpan(ctx context.Context, name string, o ...StartOption) (context.Context, *Span) + + // StartSpanWithRemoteParent starts a new child span of the span from the given parent. + // + // If the incoming context contains a parent, it ignores. StartSpanWithRemoteParent is + // preferred for cases where the parent is propagated via an incoming request. + // + // Returned context contains the newly created span. You can use it to + // propagate the returned span in process. + StartSpanWithRemoteParent(ctx context.Context, name string, parent SpanContext, o ...StartOption) (context.Context, *Span) + + // FromContext returns the Span stored in a context, or nil if there isn't one. + FromContext(ctx context.Context) *Span + + // NewContext returns a new context with the given Span attached. + NewContext(parent context.Context, s *Span) context.Context +} + +// StartSpan starts a new child span of the current span in the context. If +// there is no span in the context, creates a new trace and span. +// +// Returned context contains the newly created span. You can use it to +// propagate the returned span in process. +func StartSpan(ctx context.Context, name string, o ...StartOption) (context.Context, *Span) { + return DefaultTracer.StartSpan(ctx, name, o...) +} + +// StartSpanWithRemoteParent starts a new child span of the span from the given parent. +// +// If the incoming context contains a parent, it ignores. StartSpanWithRemoteParent is +// preferred for cases where the parent is propagated via an incoming request. +// +// Returned context contains the newly created span. You can use it to +// propagate the returned span in process. +func StartSpanWithRemoteParent(ctx context.Context, name string, parent SpanContext, o ...StartOption) (context.Context, *Span) { + return DefaultTracer.StartSpanWithRemoteParent(ctx, name, parent, o...) +} + +// FromContext returns the Span stored in a context, or a Span that is not +// recording events if there isn't one. +func FromContext(ctx context.Context) *Span { + return DefaultTracer.FromContext(ctx) +} + +// NewContext returns a new context with the given Span attached. +func NewContext(parent context.Context, s *Span) context.Context { + return DefaultTracer.NewContext(parent, s) +} + +// SpanInterface represents a span of a trace. It has an associated SpanContext, and +// stores data accumulated while the span is active. +// +// Ideally users should interact with Spans by calling the functions in this +// package that take a Context parameter. +type SpanInterface interface { + + // IsRecordingEvents returns true if events are being recorded for this span. + // Use this check to avoid computing expensive annotations when they will never + // be used. + IsRecordingEvents() bool + + // End ends the span. + End() + + // SpanContext returns the SpanContext of the span. + SpanContext() SpanContext + + // SetName sets the name of the span, if it is recording events. + SetName(name string) + + // SetStatus sets the status of the span, if it is recording events. + SetStatus(status Status) + + // AddAttributes sets attributes in the span. + // + // Existing attributes whose keys appear in the attributes parameter are overwritten. + AddAttributes(attributes ...Attribute) + + // Annotate adds an annotation with attributes. + // Attributes can be nil. + Annotate(attributes []Attribute, str string) + + // Annotatef adds an annotation with attributes. + Annotatef(attributes []Attribute, format string, a ...interface{}) + + // AddMessageSendEvent adds a message send event to the span. + // + // messageID is an identifier for the message, which is recommended to be + // unique in this span and the same between the send event and the receive + // event (this allows to identify a message between the sender and receiver). + // For example, this could be a sequence id. + AddMessageSendEvent(messageID, uncompressedByteSize, compressedByteSize int64) + + // AddMessageReceiveEvent adds a message receive event to the span. + // + // messageID is an identifier for the message, which is recommended to be + // unique in this span and the same between the send event and the receive + // event (this allows to identify a message between the sender and receiver). + // For example, this could be a sequence id. + AddMessageReceiveEvent(messageID, uncompressedByteSize, compressedByteSize int64) + + // AddLink adds a link to the span. + AddLink(l Link) + + // String prints a string representation of a span. + String() string +} + +// NewSpan is a convenience function for creating a *Span out of a *span +func NewSpan(s SpanInterface) *Span { + return &Span{internal: s} +} + +// Span is a struct wrapper around the SpanInt interface, which allows correctly handling +// nil spans, while also allowing the SpanInterface implementation to be swapped out. +type Span struct { + internal SpanInterface +} + +// Internal returns the underlying implementation of the Span +func (s *Span) Internal() SpanInterface { + return s.internal +} + +// IsRecordingEvents returns true if events are being recorded for this span. +// Use this check to avoid computing expensive annotations when they will never +// be used. +func (s *Span) IsRecordingEvents() bool { + if s == nil { + return false + } + return s.internal.IsRecordingEvents() +} + +// End ends the span. +func (s *Span) End() { + if s == nil { + return + } + s.internal.End() +} + +// SpanContext returns the SpanContext of the span. +func (s *Span) SpanContext() SpanContext { + if s == nil { + return SpanContext{} + } + return s.internal.SpanContext() +} + +// SetName sets the name of the span, if it is recording events. +func (s *Span) SetName(name string) { + if !s.IsRecordingEvents() { + return + } + s.internal.SetName(name) +} + +// SetStatus sets the status of the span, if it is recording events. +func (s *Span) SetStatus(status Status) { + if !s.IsRecordingEvents() { + return + } + s.internal.SetStatus(status) +} + +// AddAttributes sets attributes in the span. +// +// Existing attributes whose keys appear in the attributes parameter are overwritten. +func (s *Span) AddAttributes(attributes ...Attribute) { + if !s.IsRecordingEvents() { + return + } + s.internal.AddAttributes(attributes...) +} + +// Annotate adds an annotation with attributes. +// Attributes can be nil. +func (s *Span) Annotate(attributes []Attribute, str string) { + if !s.IsRecordingEvents() { + return + } + s.internal.Annotate(attributes, str) +} + +// Annotatef adds an annotation with attributes. +func (s *Span) Annotatef(attributes []Attribute, format string, a ...interface{}) { + if !s.IsRecordingEvents() { + return + } + s.internal.Annotatef(attributes, format, a...) +} + +// AddMessageSendEvent adds a message send event to the span. +// +// messageID is an identifier for the message, which is recommended to be +// unique in this span and the same between the send event and the receive +// event (this allows to identify a message between the sender and receiver). +// For example, this could be a sequence id. +func (s *Span) AddMessageSendEvent(messageID, uncompressedByteSize, compressedByteSize int64) { + if !s.IsRecordingEvents() { + return + } + s.internal.AddMessageSendEvent(messageID, uncompressedByteSize, compressedByteSize) +} + +// AddMessageReceiveEvent adds a message receive event to the span. +// +// messageID is an identifier for the message, which is recommended to be +// unique in this span and the same between the send event and the receive +// event (this allows to identify a message between the sender and receiver). +// For example, this could be a sequence id. +func (s *Span) AddMessageReceiveEvent(messageID, uncompressedByteSize, compressedByteSize int64) { + if !s.IsRecordingEvents() { + return + } + s.internal.AddMessageReceiveEvent(messageID, uncompressedByteSize, compressedByteSize) +} + +// AddLink adds a link to the span. +func (s *Span) AddLink(l Link) { + if !s.IsRecordingEvents() { + return + } + s.internal.AddLink(l) +} + +// String prints a string representation of a span. +func (s *Span) String() string { + if s == nil { + return "" + } + return s.internal.String() +} diff --git a/vendor/knative.dev/pkg/apis/duck/ABOUT.md b/vendor/knative.dev/pkg/apis/duck/ABOUT.md index 98ffc9424b..b223412a01 100644 --- a/vendor/knative.dev/pkg/apis/duck/ABOUT.md +++ b/vendor/knative.dev/pkg/apis/duck/ABOUT.md @@ -73,7 +73,7 @@ the resulting JSON Patch can only contain fields relevant to the resource. In Knative, we follow the Kubernetes API principles of using `conditions` as a key part of our resources’ status, but we go a step further in -[defining particular conventions](https://github.com/knative/serving/blob/master/docs/spec/errors.md#error-conditions-and-reporting) +[defining particular conventions](https://github.com/knative/serving/blob/main/docs/spec/errors.md#error-conditions-and-reporting) on how these are used. To support this, we define: diff --git a/vendor/knative.dev/pkg/client/injection/kube/client/client.go b/vendor/knative.dev/pkg/client/injection/kube/client/client.go index 00591ff578..b7994cb725 100644 --- a/vendor/knative.dev/pkg/client/injection/kube/client/client.go +++ b/vendor/knative.dev/pkg/client/injection/kube/client/client.go @@ -29,6 +29,9 @@ import ( func init() { injection.Default.RegisterClient(withClient) + injection.Default.RegisterClientFetcher(func(ctx context.Context) interface{} { + return Get(ctx) + }) } // Key is used as the key for associating information with a context.Context. diff --git a/vendor/knative.dev/pkg/client/injection/kube/client/fake/fake.go b/vendor/knative.dev/pkg/client/injection/kube/client/fake/fake.go index 022ae42f0f..e166222949 100644 --- a/vendor/knative.dev/pkg/client/injection/kube/client/fake/fake.go +++ b/vendor/knative.dev/pkg/client/injection/kube/client/fake/fake.go @@ -31,6 +31,9 @@ import ( func init() { injection.Fake.RegisterClient(withClient) + injection.Fake.RegisterClientFetcher(func(ctx context.Context) interface{} { + return Get(ctx) + }) } func withClient(ctx context.Context, cfg *rest.Config) context.Context { diff --git a/vendor/knative.dev/pkg/controller/controller.go b/vendor/knative.dev/pkg/controller/controller.go index 26030626ec..747cf58efc 100644 --- a/vendor/knative.dev/pkg/controller/controller.go +++ b/vendor/knative.dev/pkg/controller/controller.go @@ -31,6 +31,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/record" "k8s.io/client-go/util/workqueue" @@ -152,6 +153,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 { @@ -514,7 +522,7 @@ func (c *Impl) processNextWorkItem() bool { // Embed the key into the logger and attach that to the context we pass // to the Reconciler. - logger := c.logger.With(zap.String(logkey.TraceID, uuid.New().String()), zap.String(logkey.Key, keyStr)) + logger := c.logger.With(zap.String(logkey.TraceID, uuid.NewString()), zap.String(logkey.Key, keyStr)) ctx := logging.WithLogger(context.Background(), logger) // Run Reconcile, passing it the namespace/name string of the @@ -578,8 +586,8 @@ func NewSkipKey(key string) error { return skipKeyError{key: key} } -// permanentError is an error that is considered not transient. -// We should not re-queue keys when it returns with thus error in reconcile. +// skipKeyError is an error that indicates a key was skipped. +// We should not re-queue keys when it returns this error from Reconcile. type skipKeyError struct { key string } @@ -685,13 +693,29 @@ func RunInformers(stopCh <-chan struct{}, informers ...Informer) (func(), error) } for i, informer := range informers { - if ok := cache.WaitForCacheSync(stopCh, informer.HasSynced); !ok { + if ok := WaitForCacheSyncQuick(stopCh, informer.HasSynced); !ok { return wg.Wait, fmt.Errorf("failed to wait for cache at index %d to sync", i) } } return wg.Wait, nil } +// WaitForCacheSyncQuick is the same as cache.WaitForCacheSync but with a much reduced +// check-rate for the sync period. +func WaitForCacheSyncQuick(stopCh <-chan struct{}, cacheSyncs ...cache.InformerSynced) bool { + err := wait.PollImmediateUntil(time.Millisecond, + func() (bool, error) { + for _, syncFunc := range cacheSyncs { + if !syncFunc() { + return false, nil + } + } + return true, nil + }, + stopCh) + return err == nil +} + // StartAll kicks off all of the passed controllers with DefaultThreadsPerController. func StartAll(ctx context.Context, controllers ...*Impl) { wg := sync.WaitGroup{} diff --git a/vendor/knative.dev/pkg/controller/options.go b/vendor/knative.dev/pkg/controller/options.go index b40b5a3596..8d61835e69 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/controller/stats_reporter.go b/vendor/knative.dev/pkg/controller/stats_reporter.go index 92a5848a1d..474bab3fc6 100644 --- a/vendor/knative.dev/pkg/controller/stats_reporter.go +++ b/vendor/knative.dev/pkg/controller/stats_reporter.go @@ -26,7 +26,6 @@ import ( "go.opencensus.io/tag" "go.uber.org/zap" "k8s.io/apimachinery/pkg/types" - "k8s.io/client-go/tools/cache" kubemetrics "k8s.io/client-go/tools/metrics" "k8s.io/client-go/util/workqueue" "knative.dev/pkg/metrics" @@ -34,8 +33,8 @@ import ( ) var ( - workQueueDepthStat = stats.Int64("work_queue_depth", "Depth of the work queue", stats.UnitNone) - reconcileCountStat = stats.Int64("reconcile_count", "Number of reconcile operations", stats.UnitNone) + workQueueDepthStat = stats.Int64("work_queue_depth", "Depth of the work queue", stats.UnitDimensionless) + reconcileCountStat = stats.Int64("reconcile_count", "Number of reconcile operations", stats.UnitDimensionless) reconcileLatencyStat = stats.Int64("reconcile_latency", "Latency of reconcile operations", stats.UnitMilliseconds) // reconcileDistribution defines the bucket boundaries for the histogram of reconcile latency metric. @@ -58,104 +57,51 @@ func init() { Adds: stats.Int64( "workqueue_adds_total", "Total number of adds handled by workqueue", - stats.UnitNone, + stats.UnitDimensionless, ), Depth: stats.Int64( "workqueue_depth", "Current depth of workqueue", - stats.UnitNone, + stats.UnitDimensionless, ), Latency: stats.Float64( "workqueue_queue_latency_seconds", "How long in seconds an item stays in workqueue before being requested.", - "s", + stats.UnitSeconds, ), Retries: stats.Int64( "workqueue_retries_total", "Total number of retries handled by workqueue", - "s", + stats.UnitDimensionless, ), WorkDuration: stats.Float64( "workqueue_work_duration_seconds", "How long in seconds processing an item from workqueue takes.", - "s", + stats.UnitSeconds, ), UnfinishedWorkSeconds: stats.Float64( "workqueue_unfinished_work_seconds", "How long in seconds the outstanding workqueue items have been in flight (total).", - "s", + stats.UnitSeconds, ), LongestRunningProcessorSeconds: stats.Float64( "workqueue_longest_running_processor_seconds", "How long in seconds the longest outstanding workqueue item has been in flight.", - "s", + stats.UnitSeconds, ), } workqueue.SetProvider(wp) - // Register to receive metrics from kubernetes reflectors (what powers informers) - // NOTE: today these don't actually seem to wire up to anything in Kubernetes. - rp := &metrics.ReflectorProvider{ - ItemsInList: stats.Float64( - "reflector_items_in_list", - "How many items an API list returns to the reflectors", - stats.UnitNone, - ), - // TODO(mattmoor): This is not in the latest version, so it will - // be removed in a future version. - ItemsInMatch: stats.Float64( - "reflector_items_in_match", - "", - stats.UnitNone, - ), - ItemsInWatch: stats.Float64( - "reflector_items_in_watch", - "How many items an API watch returns to the reflectors", - stats.UnitNone, - ), - LastResourceVersion: stats.Float64( - "reflector_last_resource_version", - "Last resource version seen for the reflectors", - stats.UnitNone, - ), - ListDuration: stats.Float64( - "reflector_list_duration_seconds", - "How long an API list takes to return and decode for the reflectors", - stats.UnitNone, - ), - Lists: stats.Int64( - "reflector_lists_total", - "Total number of API lists done by the reflectors", - stats.UnitNone, - ), - ShortWatches: stats.Int64( - "reflector_short_watches_total", - "Total number of short API watches done by the reflectors", - stats.UnitNone, - ), - WatchDuration: stats.Float64( - "reflector_watch_duration_seconds", - "How long an API watch takes to return and decode for the reflectors", - stats.UnitNone, - ), - Watches: stats.Int64( - "reflector_watches_total", - "Total number of API watches done by the reflectors", - stats.UnitNone, - ), - } - cache.SetReflectorMetricsProvider(rp) - cp := &metrics.ClientProvider{ Latency: stats.Float64( "client_latency", "How long Kubernetes API requests take", - "s", + stats.UnitSeconds, ), Result: stats.Int64( "client_results", "Total number of API requests (broken down by status code)", - stats.UnitNone, + stats.UnitDimensionless, ), } opts := kubemetrics.RegisterOpts{ @@ -181,7 +127,6 @@ func init() { TagKeys: []tag.Key{reconcilerTagKey, successTagKey, NamespaceTagKey}, }} views = append(views, wp.DefaultViews()...) - views = append(views, rp.DefaultViews()...) views = append(views, cp.DefaultViews()...) // Create views to see our measurements. This can return an error if diff --git a/vendor/knative.dev/pkg/injection/clients.go b/vendor/knative.dev/pkg/injection/clients.go index 5c464924c7..b71ef1d943 100644 --- a/vendor/knative.dev/pkg/injection/clients.go +++ b/vendor/knative.dev/pkg/injection/clients.go @@ -26,6 +26,10 @@ import ( // client type to a context. type ClientInjector func(context.Context, *rest.Config) context.Context +// ClientFetcher holds the type of a callback that returns a particular client type +// from a context. +type ClientFetcher func(context.Context) interface{} + func (i *impl) RegisterClient(ci ClientInjector) { i.m.Lock() defer i.m.Unlock() @@ -40,3 +44,21 @@ func (i *impl) GetClients() []ClientInjector { // Copy the slice before returning. return append(i.clients[:0:0], i.clients...) } + +func (i *impl) RegisterClientFetcher(f ClientFetcher) { + i.m.Lock() + defer i.m.Unlock() + + i.clientFetchers = append(i.clientFetchers, f) +} + +func (i *impl) FetchAllClients(ctx context.Context) []interface{} { + i.m.RLock() + defer i.m.RUnlock() + + clients := make([]interface{}, 0, len(i.clientFetchers)) + for _, f := range i.clientFetchers { + clients = append(clients, f(ctx)) + } + return clients +} diff --git a/vendor/knative.dev/pkg/injection/interface.go b/vendor/knative.dev/pkg/injection/interface.go index 7d2764cdcc..112a6415f2 100644 --- a/vendor/knative.dev/pkg/injection/interface.go +++ b/vendor/knative.dev/pkg/injection/interface.go @@ -36,6 +36,13 @@ type Interface interface { // GetClients fetches all of the registered client injectors. GetClients() []ClientInjector + // RegisterClientFetcher registers a new callback that fetches a client from + // a given context. + RegisterClientFetcher(ClientFetcher) + + // FetchAllClients returns all known clients from the given context. + FetchAllClients(context.Context) []interface{} + // RegisterInformerFactory registers a new injector callback for associating // a new informer factory with a context. RegisterInformerFactory(InformerFactoryInjector) @@ -92,6 +99,7 @@ type impl struct { m sync.RWMutex clients []ClientInjector + clientFetchers []ClientFetcher factories []InformerFactoryInjector informers []InformerInjector filteredInformers []FilteredInformersInjector diff --git a/vendor/knative.dev/pkg/leaderelection/config.go b/vendor/knative.dev/pkg/leaderelection/config.go index 96164bd001..3d9df1dc79 100644 --- a/vendor/knative.dev/pkg/leaderelection/config.go +++ b/vendor/knative.dev/pkg/leaderelection/config.go @@ -134,8 +134,8 @@ type statefulSetID struct { func (ssID *statefulSetID) Decode(v string) error { if i := strings.LastIndex(v, "-"); i != -1 { - ui, err := strconv.ParseUint(v[i+1:], 10, 64) - ssID.ordinal = int(ui) + ui, err := strconv.Atoi(v[i+1:]) + ssID.ordinal = ui ssID.ssName = v[:i] return err } diff --git a/vendor/knative.dev/pkg/metrics/config.go b/vendor/knative.dev/pkg/metrics/config.go index c4c9c7f84e..6407a1b0de 100644 --- a/vendor/knative.dev/pkg/metrics/config.go +++ b/vendor/knative.dev/pkg/metrics/config.go @@ -41,7 +41,7 @@ const ( DomainEnv = "METRICS_DOMAIN" // The following keys are used to configure metrics reporting. - // See https://github.com/knative/serving/blob/master/config/config-observability.yaml + // See https://github.com/knative/serving/blob/main/config/config-observability.yaml // for details. allowStackdriverCustomMetricsKey = "metrics.allow-stackdriver-custom-metrics" collectorAddressKey = "metrics.opencensus-address" diff --git a/vendor/knative.dev/pkg/metrics/exporter.go b/vendor/knative.dev/pkg/metrics/exporter.go index b98a18de1f..46e5916dec 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) @@ -77,7 +81,7 @@ type ExporterOptions struct { PrometheusHost string // ConfigMap is the data from config map config-observability. Must be present. - // See https://github.com/knative/serving/blob/master/config/config-observability.yaml + // See https://github.com/knative/serving/blob/main/config/config-observability.yaml // for details. ConfigMap map[string]string @@ -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/memstats.go b/vendor/knative.dev/pkg/metrics/memstats.go index 719c7e0189..d96a0f4bc5 100644 --- a/vendor/knative.dev/pkg/metrics/memstats.go +++ b/vendor/knative.dev/pkg/metrics/memstats.go @@ -33,112 +33,112 @@ func NewMemStatsAll() *MemStatsProvider { Alloc: stats.Int64( "go_alloc", "The number of bytes of allocated heap objects.", - stats.UnitNone, + stats.UnitDimensionless, ), TotalAlloc: stats.Int64( "go_total_alloc", "The cumulative bytes allocated for heap objects.", - stats.UnitNone, + stats.UnitDimensionless, ), Sys: stats.Int64( "go_sys", "The total bytes of memory obtained from the OS.", - stats.UnitNone, + stats.UnitDimensionless, ), Lookups: stats.Int64( "go_lookups", "The number of pointer lookups performed by the runtime.", - stats.UnitNone, + stats.UnitDimensionless, ), Mallocs: stats.Int64( "go_mallocs", "The cumulative count of heap objects allocated.", - stats.UnitNone, + stats.UnitDimensionless, ), Frees: stats.Int64( "go_frees", "The cumulative count of heap objects freed.", - stats.UnitNone, + stats.UnitDimensionless, ), HeapAlloc: stats.Int64( "go_heap_alloc", "The number of bytes of allocated heap objects.", - stats.UnitNone, + stats.UnitDimensionless, ), HeapSys: stats.Int64( "go_heap_sys", "The number of bytes of heap memory obtained from the OS.", - stats.UnitNone, + stats.UnitDimensionless, ), HeapIdle: stats.Int64( "go_heap_idle", "The number of bytes in idle (unused) spans.", - stats.UnitNone, + stats.UnitDimensionless, ), HeapInuse: stats.Int64( "go_heap_in_use", "The number of bytes in in-use spans.", - stats.UnitNone, + stats.UnitDimensionless, ), HeapReleased: stats.Int64( "go_heap_released", "The number of bytes of physical memory returned to the OS.", - stats.UnitNone, + stats.UnitDimensionless, ), HeapObjects: stats.Int64( "go_heap_objects", "The number of allocated heap objects.", - stats.UnitNone, + stats.UnitDimensionless, ), StackInuse: stats.Int64( "go_stack_in_use", "The number of bytes in stack spans.", - stats.UnitNone, + stats.UnitDimensionless, ), StackSys: stats.Int64( "go_stack_sys", "The number of bytes of stack memory obtained from the OS.", - stats.UnitNone, + stats.UnitDimensionless, ), MSpanInuse: stats.Int64( "go_mspan_in_use", "The number of bytes of allocated mspan structures.", - stats.UnitNone, + stats.UnitDimensionless, ), MSpanSys: stats.Int64( "go_mspan_sys", "The number of bytes of memory obtained from the OS for mspan structures.", - stats.UnitNone, + stats.UnitDimensionless, ), MCacheInuse: stats.Int64( "go_mcache_in_use", "The number of bytes of allocated mcache structures.", - stats.UnitNone, + stats.UnitDimensionless, ), MCacheSys: stats.Int64( "go_mcache_sys", "The number of bytes of memory obtained from the OS for mcache structures.", - stats.UnitNone, + stats.UnitDimensionless, ), BuckHashSys: stats.Int64( "go_bucket_hash_sys", "The number of bytes of memory in profiling bucket hash tables.", - stats.UnitNone, + stats.UnitDimensionless, ), GCSys: stats.Int64( "go_gc_sys", "The number of bytes of memory in garbage collection metadata.", - stats.UnitNone, + stats.UnitDimensionless, ), OtherSys: stats.Int64( "go_other_sys", "The number of bytes of memory in miscellaneous off-heap runtime allocations.", - stats.UnitNone, + stats.UnitDimensionless, ), NextGC: stats.Int64( "go_next_gc", "The target heap size of the next GC cycle.", - stats.UnitNone, + stats.UnitDimensionless, ), LastGC: stats.Int64( "go_last_gc", @@ -153,17 +153,17 @@ func NewMemStatsAll() *MemStatsProvider { NumGC: stats.Int64( "go_num_gc", "The number of completed GC cycles.", - stats.UnitNone, + stats.UnitDimensionless, ), NumForcedGC: stats.Int64( "go_num_forced_gc", "The number of GC cycles that were forced by the application calling the GC function.", - stats.UnitNone, + stats.UnitDimensionless, ), GCCPUFraction: stats.Float64( "go_gc_cpu_fraction", "The fraction of this program's available CPU time used by the GC since the program started.", - stats.UnitNone, + stats.UnitDimensionless, ), } } 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 0000000000..0b7753acb2 --- /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/reflector.go b/vendor/knative.dev/pkg/metrics/reflector.go deleted file mode 100644 index 548b811b60..0000000000 --- a/vendor/knative.dev/pkg/metrics/reflector.go +++ /dev/null @@ -1,176 +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 metrics - -import ( - "go.opencensus.io/stats" - "go.opencensus.io/stats/view" - "go.opencensus.io/tag" - "k8s.io/client-go/tools/cache" -) - -// ReflectorProvider implements reflector.MetricsProvider and may be used with -// reflector.SetProvider to have metrics exported to the provided metrics. -type ReflectorProvider struct { - ItemsInList *stats.Float64Measure - // TODO(mattmoor): This is not in the latest version, so it will - // be removed in a future version. - ItemsInMatch *stats.Float64Measure - ItemsInWatch *stats.Float64Measure - LastResourceVersion *stats.Float64Measure - ListDuration *stats.Float64Measure - Lists *stats.Int64Measure - ShortWatches *stats.Int64Measure - WatchDuration *stats.Float64Measure - Watches *stats.Int64Measure -} - -var ( - _ cache.MetricsProvider = (*ReflectorProvider)(nil) -) - -// NewItemsInListMetric implements MetricsProvider -func (rp *ReflectorProvider) NewItemsInListMetric(name string) cache.SummaryMetric { - return floatMetric{ - mutators: []tag.Mutator{tag.Insert(tagName, name)}, - measure: rp.ItemsInList, - } -} - -// ItemsInListView returns a view of the ItemsInList metric. -func (rp *ReflectorProvider) ItemsInListView() *view.View { - return measureView(rp.ItemsInList, view.Distribution(BucketsNBy10(0.1, 6)...)) -} - -// NewItemsInMatchMetric implements MetricsProvider -func (rp *ReflectorProvider) NewItemsInMatchMetric(name string) cache.SummaryMetric { - return floatMetric{ - mutators: []tag.Mutator{tag.Insert(tagName, name)}, - measure: rp.ItemsInMatch, - } -} - -// ItemsInMatchView returns a view of the ItemsInMatch metric. -func (rp *ReflectorProvider) ItemsInMatchView() *view.View { - return measureView(rp.ItemsInMatch, view.Distribution(BucketsNBy10(0.1, 6)...)) -} - -// NewItemsInWatchMetric implements MetricsProvider -func (rp *ReflectorProvider) NewItemsInWatchMetric(name string) cache.SummaryMetric { - return floatMetric{ - mutators: []tag.Mutator{tag.Insert(tagName, name)}, - measure: rp.ItemsInWatch, - } -} - -// ItemsInWatchView returns a view of the ItemsInWatch metric. -func (rp *ReflectorProvider) ItemsInWatchView() *view.View { - return measureView(rp.ItemsInWatch, view.Distribution(BucketsNBy10(0.1, 6)...)) -} - -// NewLastResourceVersionMetric implements MetricsProvider -func (rp *ReflectorProvider) NewLastResourceVersionMetric(name string) cache.GaugeMetric { - return floatMetric{ - mutators: []tag.Mutator{tag.Insert(tagName, name)}, - measure: rp.LastResourceVersion, - } -} - -// LastResourceVersionView returns a view of the LastResourceVersion metric. -func (rp *ReflectorProvider) LastResourceVersionView() *view.View { - return measureView(rp.LastResourceVersion, view.LastValue()) -} - -// NewListDurationMetric implements MetricsProvider -func (rp *ReflectorProvider) NewListDurationMetric(name string) cache.SummaryMetric { - return floatMetric{ - mutators: []tag.Mutator{tag.Insert(tagName, name)}, - measure: rp.ListDuration, - } -} - -// ListDurationView returns a view of the ListDuration metric. -func (rp *ReflectorProvider) ListDurationView() *view.View { - return measureView(rp.ListDuration, view.Distribution(BucketsNBy10(0.1, 6)...)) -} - -// NewListsMetric implements MetricsProvider -func (rp *ReflectorProvider) NewListsMetric(name string) cache.CounterMetric { - return counterMetric{ - mutators: []tag.Mutator{tag.Insert(tagName, name)}, - measure: rp.Lists, - } -} - -// ListsView returns a view of the Lists metric. -func (rp *ReflectorProvider) ListsView() *view.View { - return measureView(rp.Lists, view.Count()) -} - -// NewShortWatchesMetric implements MetricsProvider -func (rp *ReflectorProvider) NewShortWatchesMetric(name string) cache.CounterMetric { - return counterMetric{ - mutators: []tag.Mutator{tag.Insert(tagName, name)}, - measure: rp.ShortWatches, - } -} - -// ShortWatchesView returns a view of the ShortWatches metric. -func (rp *ReflectorProvider) ShortWatchesView() *view.View { - return measureView(rp.ShortWatches, view.Count()) -} - -// NewWatchDurationMetric implements MetricsProvider -func (rp *ReflectorProvider) NewWatchDurationMetric(name string) cache.SummaryMetric { - return floatMetric{ - mutators: []tag.Mutator{tag.Insert(tagName, name)}, - measure: rp.WatchDuration, - } -} - -// WatchDurationView returns a view of the WatchDuration metric. -func (rp *ReflectorProvider) WatchDurationView() *view.View { - return measureView(rp.WatchDuration, view.Distribution(BucketsNBy10(0.1, 6)...)) -} - -// NewWatchesMetric implements MetricsProvider -func (rp *ReflectorProvider) NewWatchesMetric(name string) cache.CounterMetric { - return counterMetric{ - mutators: []tag.Mutator{tag.Insert(tagName, name)}, - measure: rp.Watches, - } -} - -// WatchesView returns a view of the Watches metric. -func (rp *ReflectorProvider) WatchesView() *view.View { - return measureView(rp.Watches, view.Count()) -} - -// DefaultViews returns a list of views suitable for passing to view.Register -func (rp *ReflectorProvider) DefaultViews() []*view.View { - return []*view.View{ - rp.ItemsInListView(), - rp.ItemsInMatchView(), - rp.ItemsInWatchView(), - rp.LastResourceVersionView(), - rp.ListDurationView(), - rp.ListsView(), - rp.ShortWatchesView(), - rp.WatchDurationView(), - rp.WatchesView(), - } -} diff --git a/vendor/knative.dev/pkg/metrics/resource_view.go b/vendor/knative.dev/pkg/metrics/resource_view.go index 7135af70aa..236fd588ba 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/network.go b/vendor/knative.dev/pkg/network/network.go index b2ac63ce77..cf5feaa8fa 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/system/clock.go b/vendor/knative.dev/pkg/system/clock.go deleted file mode 100644 index 7d99d9b5cd..0000000000 --- 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/knative.dev/pkg/test/README.md b/vendor/knative.dev/pkg/test/README.md index d106ffec96..c56070878b 100644 --- a/vendor/knative.dev/pkg/test/README.md +++ b/vendor/knative.dev/pkg/test/README.md @@ -28,7 +28,7 @@ You can use the test library in this dir to: These flags are useful for running against an existing cluster, making use of your existing -[environment setup](https://github.com/knative/serving/blob/master/DEVELOPMENT.md#environment-setup). +[environment setup](https://github.com/knative/serving/blob/main/DEVELOPMENT.md#environment-setup). By importing `knative.dev/pkg/test` you get access to a global variable called `test.Flags` which holds the values of @@ -46,7 +46,7 @@ _See [e2e_flags.go](./e2e_flags.go)._ debug logs will be emitted to stdout. We are using a generic -[FormatLogger](https://github.com/knative/pkg/blob/master/test/logging/logging.go#L49) +[FormatLogger](https://github.com/knative/pkg/blob/main/test/logging/logging.go#L49) that can be passed in any existing logger that satisfies it. Test can use the generic [logging methods](https://golang.org/pkg/testing/#T) to log info and error logs. All the common methods accept generic FormatLogger as a parameter @@ -64,7 +64,7 @@ _See [logging.go](./logging/logging.go)._ ### Check Knative Serving resources _WARNING: this code also exists in -[`knative/serving`](https://github.com/knative/serving/blob/master/test/adding_tests.md#make-requests-against-deployed-services)._ +[`knative/serving`](https://github.com/knative/serving/blob/main/test/adding_tests.md#make-requests-against-deployed-services)._ After creating Knative Serving resources or making changes to them, you will need to wait for the system to realize those changes. You can use the Knative diff --git a/vendor/knative.dev/pkg/test/zipkin/util.go b/vendor/knative.dev/pkg/test/zipkin/util.go index 95659c3b4f..5e9cb5feb4 100644 --- a/vendor/knative.dev/pkg/test/zipkin/util.go +++ b/vendor/knative.dev/pkg/test/zipkin/util.go @@ -46,7 +46,7 @@ const ( ZipkinTraceIDHeader = "ZIPKIN_TRACE_ID" // ZipkinPort is port exposed by the Zipkin Pod - // https://github.com/knative/serving/blob/master/config/monitoring/200-common/100-zipkin.yaml#L25 configures the Zipkin Port on the cluster. + // https://github.com/knative/serving/blob/main/config/monitoring/200-common/100-zipkin.yaml#L25 configures the Zipkin Port on the cluster. ZipkinPort = 9411 // ZipkinTraceEndpoint port-forwarded zipkin endpoint diff --git a/vendor/modules.txt b/vendor/modules.txt index 56b7a255ca..58df1c553d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ cloud.google.com/go/trace/apiv2 contrib.go.opencensus.io/exporter/ocagent # contrib.go.opencensus.io/exporter/prometheus v0.2.1-0.20200609204449-6bcf6f8577f0 contrib.go.opencensus.io/exporter/prometheus -# contrib.go.opencensus.io/exporter/stackdriver v0.13.4 +# contrib.go.opencensus.io/exporter/stackdriver v0.13.5 contrib.go.opencensus.io/exporter/stackdriver contrib.go.opencensus.io/exporter/stackdriver/monitoredresource contrib.go.opencensus.io/exporter/stackdriver/monitoredresource/aws @@ -329,13 +329,13 @@ github.com/openzipkin/zipkin-go/model github.com/peterbourgon/diskv # github.com/pkg/errors v0.9.1 github.com/pkg/errors -# github.com/prometheus/client_golang v1.8.0 +# github.com/prometheus/client_golang v1.9.0 github.com/prometheus/client_golang/prometheus github.com/prometheus/client_golang/prometheus/internal github.com/prometheus/client_golang/prometheus/promhttp # github.com/prometheus/client_model v0.2.0 github.com/prometheus/client_model/go -# github.com/prometheus/common v0.15.0 +# github.com/prometheus/common v0.19.0 github.com/prometheus/common/expfmt github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg github.com/prometheus/common/log @@ -378,7 +378,7 @@ github.com/tektoncd/hub/api/pkg/cli/printer github.com/tektoncd/hub/api/pkg/cli/version github.com/tektoncd/hub/api/pkg/git github.com/tektoncd/hub/api/pkg/parser -# github.com/tektoncd/pipeline v0.23.0 +# github.com/tektoncd/pipeline v0.24.1 github.com/tektoncd/pipeline/pkg/apis/config github.com/tektoncd/pipeline/pkg/apis/pipeline github.com/tektoncd/pipeline/pkg/apis/pipeline/pod @@ -491,7 +491,7 @@ github.com/tektoncd/triggers/pkg/client/injection/informers/triggers/v1alpha1/tr github.com/tektoncd/triggers/pkg/client/listers/triggers/v1alpha1 github.com/tektoncd/triggers/test github.com/tektoncd/triggers/test/builder -# go.opencensus.io v0.22.5 +# go.opencensus.io v0.23.0 go.opencensus.io go.opencensus.io/internal go.opencensus.io/internal/tagencoding @@ -1081,7 +1081,7 @@ k8s.io/utils/buffer k8s.io/utils/integer k8s.io/utils/pointer k8s.io/utils/trace -# knative.dev/pkg v0.0.0-20210208131226-4b2ae073fa06 +# knative.dev/pkg v0.0.0-20210331065221-952fdd90dbb0 knative.dev/pkg/apis knative.dev/pkg/apis/duck knative.dev/pkg/apis/duck/ducktypes