From 848d632c199e189e6aedd0594c2e392c529d527a Mon Sep 17 00:00:00 2001 From: Matt Moore Date: Tue, 2 Jun 2020 10:57:17 -0700 Subject: [PATCH] [master] Auto-update dependencies (#1187) Produced via: `./hack/update-deps.sh --upgrade && ./hack/update-codegen.sh` /assign grantr ian-mi nachocano /cc grantr ian-mi nachocano --- go.mod | 7 +- go.sum | 25 +- .../pkg/apis/eventing/v1beta1/broker_types.go | 2 +- .../apis/eventing/v1beta1/eventtype_types.go | 2 +- .../apis/eventing/v1beta1/trigger_types.go | 2 +- .../pkg/apis/duck/v1/status_types.go | 2 +- .../pkg/apis/duck/v1beta1/status_types.go | 3 +- vendor/knative.dev/pkg/configmap/parse.go | 16 ++ .../pkg/metrics/stackdriver_exporter.go | 11 +- vendor/knative.dev/pkg/test/gcs/client.go | 51 ++++ vendor/knative.dev/pkg/test/gcs/gcs.go | 269 ++++++++++-------- vendor/knative.dev/pkg/test/gcs/helpers.go | 58 ++++ vendor/knative.dev/pkg/test/prow/prow.go | 25 +- vendor/knative.dev/pkg/webhook/webhook.go | 9 +- .../apis/autoscaling/v1alpha1/metric_types.go | 7 +- .../pkg/apis/autoscaling/v1alpha1/pa_types.go | 5 - .../serving/pkg/apis/config/defaults.go | 34 +-- .../pkg/apis/config/zz_generated.deepcopy.go | 10 + .../apis/networking/v1alpha1/ingress_types.go | 14 + .../v1alpha1/zz_generated.deepcopy.go | 23 ++ .../pkg/apis/serving/v1/revision_defaults.go | 40 +-- .../serving/pkg/autoscaler/config/config.go | 12 +- vendor/modules.txt | 9 +- 23 files changed, 416 insertions(+), 220 deletions(-) create mode 100644 vendor/knative.dev/pkg/test/gcs/client.go create mode 100644 vendor/knative.dev/pkg/test/gcs/helpers.go diff --git a/go.mod b/go.mod index fb0e7c8b05..bc5748c2ea 100644 --- a/go.mod +++ b/go.mod @@ -32,9 +32,10 @@ require ( k8s.io/api v0.17.6 k8s.io/apimachinery v0.18.1 k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible - knative.dev/eventing v0.15.1-0.20200529211210-a70e7c4a28f3 - knative.dev/pkg v0.0.0-20200527173759-2d1a04d1ff82 - knative.dev/serving v0.15.1-0.20200527151759-5b8ff09ace4f + knative.dev/eventing v0.15.1-0.20200602132917-9119a2e34905 + knative.dev/pkg v0.0.0-20200601184204-18c577c87d4f + knative.dev/serving v0.15.1-0.20200602105317-468ae278d9e3 + knative.dev/test-infra v0.0.0-20200602024303-e406de9f65c4 // indirect sigs.k8s.io/yaml v1.2.0 ) diff --git a/go.sum b/go.sum index 3bd2e5bb2f..f76f93c266 100644 --- a/go.sum +++ b/go.sum @@ -299,7 +299,6 @@ github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkg github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.9.5+incompatible h1:spTtZBk5DYEvbxMVutUuTyh1Ao2r4iyvLdACqsl/Ljk= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful-swagger12 v0.0.0-20170208215640-dcef7f557305/go.mod h1:qr0VowGBT4CS4Q8vFF8BSeKz34PuqKGxs/L0IAQA9DQ= github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= @@ -714,7 +713,6 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLD github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/munnerz/goautoneg v0.0.0-20190414153302-2ae31c8b6b30/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= @@ -1487,6 +1485,7 @@ k8s.io/kubernetes v1.14.7/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk= k8s.io/legacy-cloud-providers v0.17.0/go.mod h1:DdzaepJ3RtRy+e5YhNtrCYwlgyK87j/5+Yfp0L9Syp8= k8s.io/legacy-cloud-providers v0.17.4/go.mod h1:FikRNoD64ECjkxO36gkDgJeiQWwyZTuBkhu+yxOc1Js= k8s.io/metrics v0.17.2/go.mod h1:3TkNHET4ROd+NfzNxkjoVfQ0Ob4iZnaHmSEA4vYpwLw= +k8s.io/metrics v0.17.6/go.mod h1:5AuIG+m+U5ga8DpqAUqQWBhGVyY485HfKpn471pmWrQ= k8s.io/test-infra v0.0.0-20181019233642-2e10a0bbe9b3/go.mod h1:2NzXB13Ji0nqpyublHeiPC4FZwU0TknfvyaaNfl/BTA= k8s.io/test-infra v0.0.0-20191212060232-70b0b49fe247/go.mod h1:d8SKryJBXAwfCFVL4wieRez47J2NOOAb9d029sWLseQ= k8s.io/test-infra v0.0.0-20200407001919-bc7f71ef65b8/go.mod h1:/WpJWcaDvuykB322WXP4kJbX8IpalOzuPxA62GpwkJk= @@ -1501,8 +1500,8 @@ k8s.io/utils v0.0.0-20200124190032-861946025e34 h1:HjlUD6M0K3P8nRXmr2B9o4F9dUy9T k8s.io/utils v0.0.0-20200124190032-861946025e34/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= knative.dev/caching v0.0.0-20190719140829-2032732871ff/go.mod h1:dHXFU6CGlLlbzaWc32g80cR92iuBSpsslDNBWI8C7eg= knative.dev/caching v0.0.0-20200521155757-e78d17bc250e/go.mod h1:bsKPIG2XZFYL8uw5BAxg7EMBLp0vNpu9jZIGus8HUPU= -knative.dev/eventing v0.15.1-0.20200529211210-a70e7c4a28f3 h1:M+Wi41f0sKiiJ83MeYY54UaSClA2WfopBmV2nOCGKzc= -knative.dev/eventing v0.15.1-0.20200529211210-a70e7c4a28f3/go.mod h1:sHgMoXa+Hs9fqjQRy7Nqi7eq6FDlFZ1CKe96/Mg0aCE= +knative.dev/eventing v0.15.1-0.20200602132917-9119a2e34905 h1:MtC6whrxg5MOApJLrjE9PMNDHE98OmOSE57SGu9h3Y8= +knative.dev/eventing v0.15.1-0.20200602132917-9119a2e34905/go.mod h1:Rp3KyUnVKLsrKwdf6R86b73C7qIdssGV/AOOUvQUMCA= knative.dev/eventing-contrib v0.6.1-0.20190723221543-5ce18048c08b/go.mod h1:SnXZgSGgMSMLNFTwTnpaOH7hXDzTFtw0J8OmHflNx3g= knative.dev/pkg v0.0.0-20191101194912-56c2594e4f11 h1:w+AcPuGp389HAI5FDW9L0j7MQbxnU1RtZfLP7BMgNDI= knative.dev/pkg v0.0.0-20191101194912-56c2594e4f11/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q= @@ -1514,13 +1513,14 @@ knative.dev/pkg v0.0.0-20200515002500-16d7b963416f/go.mod h1:tMOHGbxtRz8zYFGEGpV knative.dev/pkg v0.0.0-20200519155757-14eb3ae3a5a7 h1:9S2r59HZJF9nKvoRLg5zJzx6XpVlVyvVRqz/C/h6h2s= knative.dev/pkg v0.0.0-20200519155757-14eb3ae3a5a7/go.mod h1:QgNZTxnwpB/oSpNcfnLVlw+WpEwwyKAvJlvR3hgeltA= knative.dev/pkg v0.0.0-20200520073958-94316e20e860/go.mod h1:QgNZTxnwpB/oSpNcfnLVlw+WpEwwyKAvJlvR3hgeltA= -knative.dev/pkg v0.0.0-20200526194649-c48d2ebdae96/go.mod h1:4ipprwHqpqiyYHbrEjSf1kNwL+sJOqHhj1ujO2WxvpE= knative.dev/pkg v0.0.0-20200527024749-495174c96651 h1:/LhCktTMhJrCDXGg3KCWeSQTLLGy3Ms4AaqM9O/05dI= knative.dev/pkg v0.0.0-20200527024749-495174c96651/go.mod h1:4ipprwHqpqiyYHbrEjSf1kNwL+sJOqHhj1ujO2WxvpE= -knative.dev/pkg v0.0.0-20200527173759-2d1a04d1ff82 h1:uC65bOUmC5UsVJgUI28QWis/oiqnZrU49wLM828ioJM= -knative.dev/pkg v0.0.0-20200527173759-2d1a04d1ff82/go.mod h1:ywZfX/0D8hoOf4uJVgeEvJpSmsOauQvr1IuAWld9UjM= -knative.dev/serving v0.15.1-0.20200527151759-5b8ff09ace4f h1:v10RN+CYS9Q+fZ/EBXkVDTK9VCQ1rTL8aqa80m6tUXE= -knative.dev/serving v0.15.1-0.20200527151759-5b8ff09ace4f/go.mod h1:Qv35BrBQ5NYXzwdi+gK4fIZu+Y2S+kxXOG8UfW0T8UE= +knative.dev/pkg v0.0.0-20200528190300-08a86da47d28/go.mod h1:ywZfX/0D8hoOf4uJVgeEvJpSmsOauQvr1IuAWld9UjM= +knative.dev/pkg v0.0.0-20200529164702-389d28f9b67a/go.mod h1:ywZfX/0D8hoOf4uJVgeEvJpSmsOauQvr1IuAWld9UjM= +knative.dev/pkg v0.0.0-20200601184204-18c577c87d4f h1:xVWLh9bMhQiFgU1ommpDLW5djc5fPOwi6ulnCt80CO0= +knative.dev/pkg v0.0.0-20200601184204-18c577c87d4f/go.mod h1:ywZfX/0D8hoOf4uJVgeEvJpSmsOauQvr1IuAWld9UjM= +knative.dev/serving v0.15.1-0.20200602105317-468ae278d9e3 h1:CxSJURHDcTDDdnBHnYGxHuR3HLdruqfdrCQuybfV7cE= +knative.dev/serving v0.15.1-0.20200602105317-468ae278d9e3/go.mod h1:ebxxoSXTWJjCBdyb3P6KU0kNuVEAUMi22OI2E7mAxxY= knative.dev/test-infra v0.0.0-20200407185800-1b88cb3b45a5/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ= knative.dev/test-infra v0.0.0-20200505052144-5ea2f705bb55/go.mod h1:WqF1Azka+FxPZ20keR2zCNtiQA1MP9ZB4BH4HuI+SIU= knative.dev/test-infra v0.0.0-20200513011557-d03429a76034 h1:JxqONCZVS7or+Fv3ebVQoipuIBH7Ig3Qbx170hgIF+A= @@ -1530,9 +1530,10 @@ knative.dev/test-infra v0.0.0-20200519015156-82551620b0a9/go.mod h1:A5b2OAXTOeHT knative.dev/test-infra v0.0.0-20200519161858-554a95a37986 h1:ZDy43jkWPQ75d4l4DGy+ENQIXlNcnHIh4tB6XxgovNc= knative.dev/test-infra v0.0.0-20200519161858-554a95a37986/go.mod h1:LeNa1Wvn47efeQUkpkn3XG7Fx9Ga+rhAP13SZyjaEGg= knative.dev/test-infra v0.0.0-20200522180958-6a0a9b9d893a/go.mod h1:n9eQkzmSNj8BiqNFl1lzoz68D09uMeJfyOjc132Gbik= -knative.dev/test-infra v0.0.0-20200526171149-39b911556285/go.mod h1:n9eQkzmSNj8BiqNFl1lzoz68D09uMeJfyOjc132Gbik= -knative.dev/test-infra v0.0.0-20200527185659-fc87694eb879 h1:3spi67ya78+ofPZLHpJkZlBSj6pBowXa8/1Zdha6MCY= -knative.dev/test-infra v0.0.0-20200527185659-fc87694eb879/go.mod h1:7JtOmoYiYxh2oFO23nwGanuJ6qT6mFrRlZV1LL6gomY= +knative.dev/test-infra v0.0.0-20200528222301-350178ab2a0e/go.mod h1:7JtOmoYiYxh2oFO23nwGanuJ6qT6mFrRlZV1LL6gomY= +knative.dev/test-infra v0.0.0-20200531185603-9c9dad87b366/go.mod h1:c02XF+uTFJ4WfBKjSlT3XCAv14hXVTZxLjMDA7lH63E= +knative.dev/test-infra v0.0.0-20200602024303-e406de9f65c4 h1:1l1kPOYdCd6d++wskVD32h5Bt56X1tpFKQF3FGkcu6w= +knative.dev/test-infra v0.0.0-20200602024303-e406de9f65c4/go.mod h1:JV4E61erdHLn4jT0X+svUP7lZYggJyXMCGDewTSQuO8= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/broker_types.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/broker_types.go index 7e785a4d48..2fdd97aa20 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/broker_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/broker_types.go @@ -28,7 +28,7 @@ import ( ) // +genclient -// +genreconciler:class=eventing.knative.dev/broker.class +// +genreconciler:class=eventing.knative.dev/broker.class,krshapedlogic=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // Broker collects a pool of events that are consumable using Triggers. Brokers diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/eventtype_types.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/eventtype_types.go index 6a480b6f00..6b24a2d0ee 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/eventtype_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/eventtype_types.go @@ -26,7 +26,7 @@ import ( ) // +genclient -// +genreconciler +// +genreconciler:krshapedlogic=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type EventType struct { diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/trigger_types.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/trigger_types.go index 3021028391..e6ce9a4e49 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/trigger_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/trigger_types.go @@ -34,7 +34,7 @@ const ( ) // +genclient -// +genreconciler +// +genreconciler:krshapedlogic=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // Trigger represents a request to have events delivered to a consumer from a diff --git a/vendor/knative.dev/pkg/apis/duck/v1/status_types.go b/vendor/knative.dev/pkg/apis/duck/v1/status_types.go index 53006708f6..aab246b1f9 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1/status_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1/status_types.go @@ -96,7 +96,7 @@ func (source *Status) ConvertTo(ctx context.Context, sink *Status, predicates .. sink.ObservedGeneration = source.ObservedGeneration if source.Annotations != nil { // This will deep copy the map. - sink.Annotations = kmeta.UnionMaps(source.Annotations, nil) + sink.Annotations = kmeta.UnionMaps(source.Annotations) } conditions := make(apis.Conditions, 0, len(source.Conditions)) diff --git a/vendor/knative.dev/pkg/apis/duck/v1beta1/status_types.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/status_types.go index d90e7dc696..107592e85d 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1beta1/status_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/status_types.go @@ -109,7 +109,8 @@ func (s *Status) GetCondition(t apis.ConditionType) *apis.Condition { func (source *Status) ConvertTo(ctx context.Context, sink *Status) { sink.ObservedGeneration = source.ObservedGeneration if source.Annotations != nil { - sink.Annotations = kmeta.UnionMaps(source.Annotations, nil) + // This will deep copy the map. + sink.Annotations = kmeta.UnionMaps(source.Annotations) } for _, c := range source.Conditions { switch c.Type { diff --git a/vendor/knative.dev/pkg/configmap/parse.go b/vendor/knative.dev/pkg/configmap/parse.go index 6479598b7e..210d2114ed 100644 --- a/vendor/knative.dev/pkg/configmap/parse.go +++ b/vendor/knative.dev/pkg/configmap/parse.go @@ -22,6 +22,7 @@ import ( "strings" "time" + "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/util/sets" ) @@ -114,6 +115,21 @@ func AsStringSet(key string, target *sets.String) ParseFunc { } } +// AsQuantity parses the value at key as a *resource.Quantity into the target, if it exists +func AsQuantity(key string, target **resource.Quantity) ParseFunc { + return func(data map[string]string) error { + if raw, ok := data[key]; ok { + val, err := resource.ParseQuantity(raw) + if err != nil { + return fmt.Errorf("failed to parse %q: %w", key, err) + } + + *target = &val + } + return nil + } +} + // Parse parses the given map using the parser functions passed in. func Parse(data map[string]string, parsers ...ParseFunc) error { for _, parse := range parsers { diff --git a/vendor/knative.dev/pkg/metrics/stackdriver_exporter.go b/vendor/knative.dev/pkg/metrics/stackdriver_exporter.go index 87bb722a2f..e4c2d08dce 100644 --- a/vendor/knative.dev/pkg/metrics/stackdriver_exporter.go +++ b/vendor/knative.dev/pkg/metrics/stackdriver_exporter.go @@ -102,10 +102,13 @@ func init() { func newOpencensusSDExporter(o stackdriver.Options) (view.Exporter, error) { e, err := stackdriver.NewExporter(o) - if err == nil { - // Start the exporter. - // TODO(https://github.com/knative/pkg/issues/866): Move this to an interface. - e.StartMetricsExporter() + if err != nil { + return nil, err + } + // Start the exporter. + // TODO(https://github.com/knative/pkg/issues/866): Move this to an interface. + if err := e.StartMetricsExporter(); err != nil { + return nil, err } return e, nil } diff --git a/vendor/knative.dev/pkg/test/gcs/client.go b/vendor/knative.dev/pkg/test/gcs/client.go new file mode 100644 index 0000000000..a78318abe8 --- /dev/null +++ b/vendor/knative.dev/pkg/test/gcs/client.go @@ -0,0 +1,51 @@ +/* +Copyright 2020 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 gcs + +import ( + "context" + + "cloud.google.com/go/storage" +) + +type Client interface { + // NewStorageBucket creates a new bucket in GCS with uniform access policy + NewStorageBucket(ctx context.Context, bkt, project string) error + // DeleteStorageBucket removes all children objects, force if not empty + DeleteStorageBucket(ctx context.Context, bkt string, force bool) error + // Exists check if an object exists under a bucket, assuming bucket exists + Exists(ctx context.Context, bkt, objPath string) bool + // ListChildrenFiles recursively lists all children files + ListChildrenFiles(ctx context.Context, bkt, dirPath string) ([]string, error) + // ListDirectChildren lists direct children paths (incl. files and dir) + ListDirectChildren(ctx context.Context, bkt, dirPath string) ([]string, error) + // AttrObject returns the object attributes + AttrObject(ctx context.Context, bkt, objPath string) (*storage.ObjectAttrs, error) + // CopyObject copies objects from one location to another, assuming both src and dst + // buckets both exist + CopyObject(ctx context.Context, srcBkt, srcObjPath, dstBkt, dstObjPath string) error + // ReadObject reads a GCS object and returns then contents in []byte + ReadObject(ctx context.Context, bkt, objPath string) ([]byte, error) + // WriteObject writes []byte content to a GCS object + WriteObject(ctx context.Context, bkt, objPath string, content []byte) (int, error) + // DeleteObject deletes an object + DeleteObject(ctx context.Context, bkt, objPath string) error + // Download downloads GCS object to a local file, assuming bucket exists + Download(ctx context.Context, bktName, objPath, filePath string) error + // Upload uploads a local file to a GCS object, assuming bucket exists + Upload(ctx context.Context, bktName, objPath, filePath string) error +} diff --git a/vendor/knative.dev/pkg/test/gcs/gcs.go b/vendor/knative.dev/pkg/test/gcs/gcs.go index 05208c1941..fc3cc3e21b 100644 --- a/vendor/knative.dev/pkg/test/gcs/gcs.go +++ b/vendor/knative.dev/pkg/test/gcs/gcs.go @@ -14,17 +14,14 @@ See the License for the specific language governing permissions and limitations under the License. */ -// gcs.go defines functions to use GCS - package gcs import ( "context" + "errors" "fmt" "io" "io/ioutil" - "log" - "net/url" "os" "path" "strings" @@ -34,54 +31,146 @@ import ( "google.golang.org/api/option" ) -var client *storage.Client +type GCSClient struct { + *storage.Client +} -// Authenticate explicitly sets up authentication for the rest of run -func Authenticate(ctx context.Context, serviceAccount string) error { - var err error - client, err = storage.NewClient(ctx, option.WithCredentialsFile(serviceAccount)) - return err +// NewClient creates new GCS client with given service account +func NewClient(ctx context.Context, serviceAccount string) (*GCSClient, error) { + client, err := storage.NewClient(ctx, option.WithCredentialsFile(serviceAccount)) + if err != nil { + return nil, err + } + return &GCSClient{Client: client}, nil +} + +// NewStorageBucket creates a new bucket in GCS with uniform access policy +func (g *GCSClient) NewStorageBucket(ctx context.Context, bucketName, project string) error { + if project == "" { + return errors.New("a project must be provided") + } + + if bucketName == "" { + return errors.New("a bucket name must be provided") + } + + bucket := g.Bucket(bucketName) + + // For now, this creates a bucket with uniform policy across its objects to make ACL + // and permission management simple instead of object-level granularity that we currently + // do not use anyway. + bucketAttr := &storage.BucketAttrs{ + BucketPolicyOnly: storage.BucketPolicyOnly{ + Enabled: true, + }, + } + + return bucket.Create(ctx, project, bucketAttr) +} + +// DeleteStorageBucket removes all children objects and then deletes the bucket +func (g *GCSClient) DeleteStorageBucket(ctx context.Context, bucketName string, force bool) error { + children, err := g.ListChildrenFiles(ctx, bucketName, "") + if err != nil { + return err + } + + if len(children) == 0 && !force { + return fmt.Errorf("bucket %s not empty, please use force=true", bucketName) + } + + for _, child := range children { + if err := g.DeleteObject(ctx, bucketName, child); err != nil { + return err + } + } + return g.Bucket(bucketName).Delete(ctx) +} + +// get objects iterator under given storagePath and bucketName, use exclusionFilter to eliminate some files. +func (g *GCSClient) getObjectsIter(ctx context.Context, bucketName, storagePath, exclusionFilter string) *storage.ObjectIterator { + return g.Bucket(bucketName).Objects(ctx, &storage.Query{ + Prefix: storagePath, + Delimiter: exclusionFilter, + }) } -// Exists checks if path exist under gcs bucket, -// this path can either be a directory or a file. -func Exists(ctx context.Context, bucketName, storagePath string) bool { +// Exists check if an object exists under a bucket, assuming bucket exists +func (g *GCSClient) Exists(ctx context.Context, bucketName, objPath string) bool { // Check if this is a file - handle := createStorageObject(bucketName, storagePath) - if _, err := handle.Attrs(ctx); err == nil { + objHandle := g.Bucket(bucketName).Object(objPath) + if _, err := objHandle.Attrs(ctx); err == nil { return true } + // Check if this is a directory, - // gcs directory paths are virtual paths, they automatically got deleted if there is no child file - _, err := getObjectsIter(ctx, bucketName, strings.TrimRight(storagePath, " /")+"/", "").Next() + // gcs directory paths are virtual paths, they automatically get deleted if there is no child file + _, err := g.getObjectsIter(ctx, bucketName, strings.TrimRight(objPath, " /")+"/", "").Next() return err == nil } +// list child under storagePath, use exclusionFilter for skipping some files. +// This function gets all child files recursively under given storagePath, +// then filter out filenames containing given exclusionFilter. +// If exclusionFilter is empty string, returns all files but not directories, +// if exclusionFilter is "/", returns all direct children, including both files and directories. +// see https://godoc.org/cloud.google.com/go/storage#Query +func (g *GCSClient) list(ctx context.Context, bucketName, storagePath, exclusionFilter string) ([]string, error) { + objsAttrs, err := g.getObjectsAttrs(ctx, bucketName, storagePath, exclusionFilter) + if err != nil { + return nil, err + } + var filePaths []string + for _, attrs := range objsAttrs { + filePaths = append(filePaths, path.Join(attrs.Prefix, attrs.Name)) + } + return filePaths, nil +} + +// Query items under given gcs storagePath, use exclusionFilter to eliminate some files. +func (g *GCSClient) getObjectsAttrs(ctx context.Context, bucketName, storagePath, + exclusionFilter string) ([]*storage.ObjectAttrs, error) { + var allAttrs []*storage.ObjectAttrs + it := g.getObjectsIter(ctx, bucketName, storagePath, exclusionFilter) + + for { + attrs, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + return nil, fmt.Errorf("error iterating: %v", err) + } + allAttrs = append(allAttrs, attrs) + } + return allAttrs, nil +} + // ListChildrenFiles recursively lists all children files. -func ListChildrenFiles(ctx context.Context, bucketName, storagePath string) []string { - return list(ctx, bucketName, strings.TrimRight(storagePath, " /")+"/", "") +func (g *GCSClient) ListChildrenFiles(ctx context.Context, bucketName, dirPath string) ([]string, error) { + return g.list(ctx, bucketName, strings.TrimRight(dirPath, " /")+"/", "") } // ListDirectChildren lists direct children paths (including files and directories). -func ListDirectChildren(ctx context.Context, bucketName, storagePath string) []string { +func (g *GCSClient) ListDirectChildren(ctx context.Context, bucketName, dirPath string) ([]string, error) { // If there are 2 directories named "foo" and "foobar", // then given storagePath "foo" will get files both under "foo" and "foobar". // Add trailling slash to storagePath, so that only gets children under given directory. - return list(ctx, bucketName, strings.TrimRight(storagePath, " /")+"/", "/") + return g.list(ctx, bucketName, strings.TrimRight(dirPath, " /")+"/", "/") } -// Copy file from within gcs -func Copy(ctx context.Context, srcBucketName, srcPath, dstBucketName, dstPath string) error { - src := createStorageObject(srcBucketName, srcPath) - dst := createStorageObject(dstBucketName, dstPath) +// CopyObject copies objects from one location to another. Assumes both source and destination buckets exist. +func (g *GCSClient) CopyObject(ctx context.Context, srcBucketName, srcPath, dstBucketName, dstPath string) error { + src := g.Bucket(srcBucketName).Object(srcPath) + dst := g.Bucket(dstBucketName).Object(dstPath) _, err := dst.CopierFrom(src).Run(ctx) return err } -// Download file from gcs -func Download(ctx context.Context, bucketName, srcPath, dstPath string) error { - handle := createStorageObject(bucketName, srcPath) +// Download gcs object to a file +func (g *GCSClient) Download(ctx context.Context, bucketName, objPath, dstPath string) error { + handle := g.Bucket(bucketName).Object(objPath) if _, err := handle.Attrs(ctx); err != nil { return err } @@ -99,22 +188,28 @@ func Download(ctx context.Context, bucketName, srcPath, dstPath string) error { return err } -// Upload file to gcs -func Upload(ctx context.Context, bucketName, dstPath, srcPath string) error { +// Upload file to gcs object +func (g *GCSClient) Upload(ctx context.Context, bucketName, objPath, srcPath string) error { src, err := os.Open(srcPath) if err != nil { return err } - dst := createStorageObject(bucketName, dstPath).NewWriter(ctx) + dst := g.Bucket(bucketName).Object(objPath).NewWriter(ctx) defer dst.Close() _, err = io.Copy(dst, src) return err } -// Read reads the specified file -func Read(ctx context.Context, bucketName, filePath string) ([]byte, error) { +// AttrObject returns the object attributes +func (g *GCSClient) AttrObject(ctx context.Context, bucketName, objPath string) (*storage.ObjectAttrs, error) { + objHandle := g.Bucket(bucketName).Object(objPath) + return objHandle.Attrs(ctx) +} + +// ReadObject reads the content of a gcs object +func (g *GCSClient) ReadObject(ctx context.Context, bucketName, objPath string) ([]byte, error) { var contents []byte - f, err := NewReader(ctx, bucketName, filePath) + f, err := g.NewReader(ctx, bucketName, objPath) if err != nil { return contents, err } @@ -122,103 +217,43 @@ func Read(ctx context.Context, bucketName, filePath string) ([]byte, error) { return ioutil.ReadAll(f) } -// ReadURL reads from a gsUrl and return a log structure -func ReadURL(ctx context.Context, gcsURL string) ([]byte, error) { - bucket, obj, err := linkToBucketAndObject(gcsURL) - if err != nil { - return nil, err - } - - return Read(ctx, bucket, obj) -} - // NewReader creates a new Reader of a gcs file. // Important: caller must call Close on the returned Reader when done reading -func NewReader(ctx context.Context, bucketName, filePath string) (*storage.Reader, error) { - o := createStorageObject(bucketName, filePath) +func (g *GCSClient) NewReader(ctx context.Context, bucketName, objPath string) (*storage.Reader, error) { + o := g.Bucket(bucketName).Object(objPath) if _, err := o.Attrs(ctx); err != nil { return nil, err } return o.NewReader(ctx) } -// BuildLogPath returns the build log path from the test result gcsURL -func BuildLogPath(gcsURL string) (string, error) { - u, err := url.Parse(gcsURL) - if err != nil { - return gcsURL, err - } - u.Path = path.Join(u.Path, "build-log.txt") - return u.String(), nil -} - -// GetConsoleURL returns the gcs link renderable directly from a browser -func GetConsoleURL(gcsURL string) (string, error) { - u, err := url.Parse(gcsURL) - if err != nil { - return gcsURL, err - } - u.Path = path.Join("storage/browser", u.Host, u.Path) - u.Scheme = "https" - u.Host = "console.cloud.google.com" - return u.String(), nil +// DeleteObject deletes an object +func (g *GCSClient) DeleteObject(ctx context.Context, bucketName, objPath string) error { + objHandle := g.Bucket(bucketName).Object(objPath) + return objHandle.Delete(ctx) } -// create storage object handle, this step doesn't access internet -func createStorageObject(bucketName, filePath string) *storage.ObjectHandle { - return client.Bucket(bucketName).Object(filePath) -} - -// Query items under given gcs storagePath, use exclusionFilter to eliminate some files. -func getObjectsAttrs(ctx context.Context, bucketName, storagePath, exclusionFilter string) []*storage.ObjectAttrs { - var allAttrs []*storage.ObjectAttrs - it := getObjectsIter(ctx, bucketName, storagePath, exclusionFilter) - - for { - attrs, err := it.Next() - if err == iterator.Done { - break +// WriteObject writes the content to a gcs object +func (g *GCSClient) WriteObject(ctx context.Context, bucketName, objPath string, + content []byte) (n int, err error) { + objWriter := g.Bucket(bucketName).Object(objPath).NewWriter(ctx) + defer func() { + cerr := objWriter.Close() + if err == nil { + err = cerr } - if err != nil { - log.Fatalf("Error iterating: %v", err) - } - allAttrs = append(allAttrs, attrs) - } - return allAttrs -} + }() -// list child under storagePath, use exclusionFilter for skipping some files. -// This function gets all child files recursively under given storagePath, -// then filter out filenames containing giving exclusionFilter. -// If exclusionFilter is empty string, returns all files but not directories, -// if exclusionFilter is "/", returns all direct children, including both files and directories. -// see https://godoc.org/cloud.google.com/go/storage#Query -func list(ctx context.Context, bucketName, storagePath, exclusionFilter string) []string { - objsAttrs := getObjectsAttrs(ctx, bucketName, storagePath, exclusionFilter) - filePaths := make([]string, 0, len(objsAttrs)) - for _, attrs := range objsAttrs { - filePaths = append(filePaths, path.Join(attrs.Prefix, attrs.Name)) - } - return filePaths + n, err = objWriter.Write(content) + return } -// get objects iterator under given storagePath and bucketName, use exclusionFilter to eliminate some files. -func getObjectsIter(ctx context.Context, bucketName, storagePath, exclusionFilter string) *storage.ObjectIterator { - return client.Bucket(bucketName).Objects(ctx, &storage.Query{ - Prefix: storagePath, - Delimiter: exclusionFilter, - }) -} - -// get the bucket and object from the gsURL -func linkToBucketAndObject(gsURL string) (string, string, error) { - var bucket, obj string - gsURL = strings.Replace(gsURL, "gs://", "", 1) - - sIdx := strings.IndexByte(gsURL, '/') - if sIdx == -1 || sIdx+1 >= len(gsURL) { - return bucket, obj, fmt.Errorf("the gsUrl (%s) cannot be converted to bucket/object", gsURL) +// ReadURL reads from a gsUrl and return a log structure +func (g *GCSClient) ReadURL(ctx context.Context, gcsURL string) ([]byte, error) { + bucket, obj, err := linkToBucketAndObject(gcsURL) + if err != nil { + return nil, err } - return gsURL[:sIdx], gsURL[sIdx+1:], nil + return g.ReadObject(ctx, bucket, obj) } diff --git a/vendor/knative.dev/pkg/test/gcs/helpers.go b/vendor/knative.dev/pkg/test/gcs/helpers.go new file mode 100644 index 0000000000..150999ed85 --- /dev/null +++ b/vendor/knative.dev/pkg/test/gcs/helpers.go @@ -0,0 +1,58 @@ +/* +Copyright 2020 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 gcs + +import ( + "fmt" + "net/url" + "path" + "strings" +) + +// get the bucket and object from the gsURL +func linkToBucketAndObject(gsURL string) (string, string, error) { + gsURL = strings.Replace(gsURL, "gs://", "", 1) + + sIdx := strings.IndexByte(gsURL, '/') + if sIdx == -1 || sIdx+1 >= len(gsURL) { + return "", "", fmt.Errorf("the gsUrl (%q) cannot be converted to bucket/object", gsURL) + } + + return gsURL[:sIdx], gsURL[sIdx+1:], nil +} + +// BuildLogPath returns the build log path from the test result gcsURL +func BuildLogPath(gcsURL string) (string, error) { + u, err := url.Parse(gcsURL) + if err != nil { + return gcsURL, err + } + u.Path = path.Join(u.Path, "build-log.txt") + return u.String(), nil +} + +// GetConsoleURL returns the gcs link renderable directly from a browser +func GetConsoleURL(gcsURL string) (string, error) { + u, err := url.Parse(gcsURL) + if err != nil { + return gcsURL, err + } + u.Path = path.Join("storage/browser", u.Host, u.Path) + u.Scheme = "https" + u.Host = "console.cloud.google.com" + return u.String(), nil +} diff --git a/vendor/knative.dev/pkg/test/prow/prow.go b/vendor/knative.dev/pkg/test/prow/prow.go index 2af8a0095c..c5304ce27e 100644 --- a/vendor/knative.dev/pkg/test/prow/prow.go +++ b/vendor/knative.dev/pkg/test/prow/prow.go @@ -59,8 +59,8 @@ const ( // defined here so that it can be mocked for unit testing var logFatalf = log.Fatalf - var ctx = context.Background() +var client *gcs.GCSClient // Job struct represents a job directory in gcs. // gcs job StoragePath will be derived from Type if it's defined, @@ -128,7 +128,9 @@ func GetLocalArtifactsDir() string { // Initialize wraps gcs authentication, have to be invoked before any other functions func Initialize(serviceAccount string) error { - return gcs.Authenticate(ctx, serviceAccount) + var err error + client, err = gcs.NewClient(ctx, serviceAccount) + return err } // NewJob creates new job struct @@ -158,13 +160,13 @@ func NewJob(jobName, jobType, orgName, repoName string, pullID int) *Job { // PathExists checks if the storage path of a job exists in gcs or not func (j *Job) PathExists() bool { - return gcs.Exists(ctx, BucketName, j.StoragePath) + return client.Exists(ctx, BucketName, j.StoragePath) } // GetLatestBuildNumber gets the latest build number for job func (j *Job) GetLatestBuildNumber() (int, error) { logFilePath := path.Join(j.StoragePath, Latest) - contents, err := gcs.Read(ctx, BucketName, logFilePath) + contents, err := client.ReadObject(ctx, BucketName, logFilePath) if err != nil { return 0, err } @@ -223,7 +225,7 @@ func (j *Job) GetBuilds() []Build { // for job, keeps the ones that can be parsed as integer func (j *Job) GetBuildIDs() []int { var buildIDs []int - gcsBuildPaths := gcs.ListDirectChildren(ctx, j.Bucket, j.StoragePath) + gcsBuildPaths, _ := client.ListDirectChildren(ctx, j.Bucket, j.StoragePath) for _, gcsBuildPath := range gcsBuildPaths { if buildID, err := getBuildIDFromBuildPath(gcsBuildPath); err == nil { buildIDs = append(buildIDs, buildID) @@ -256,12 +258,12 @@ func (j *Job) GetLatestBuilds(count int) []Build { // IsStarted check if build has started by looking at "started.json" file func (b *Build) IsStarted() bool { - return gcs.Exists(ctx, BucketName, path.Join(b.StoragePath, StartedJSON)) + return client.Exists(ctx, BucketName, path.Join(b.StoragePath, StartedJSON)) } // IsFinished check if build has finished by looking at "finished.json" file func (b *Build) IsFinished() bool { - return gcs.Exists(ctx, BucketName, path.Join(b.StoragePath, FinishedJSON)) + return client.Exists(ctx, BucketName, path.Join(b.StoragePath, FinishedJSON)) } // GetStartTime gets started timestamp of a build, @@ -286,7 +288,8 @@ func (b *Build) GetFinishTime() (int64, error) { // GetArtifacts gets gcs path for all artifacts of current build func (b *Build) GetArtifacts() []string { - return gcs.ListChildrenFiles(ctx, BucketName, b.GetArtifactsDir()) + artifacts, _ := client.ListChildrenFiles(ctx, BucketName, b.GetArtifactsDir()) + return artifacts } // GetArtifactsDir gets gcs path for artifacts of current build @@ -302,7 +305,7 @@ func (b *Build) GetBuildLogPath() string { // ReadFile reads given file of current build, // relPath is the file path relative to build directory func (b *Build) ReadFile(relPath string) ([]byte, error) { - return gcs.Read(ctx, BucketName, path.Join(b.StoragePath, relPath)) + return client.ReadObject(ctx, BucketName, path.Join(b.StoragePath, relPath)) } // ParseLog parses the build log and returns the lines where the checkLog func does not return an empty slice, @@ -310,7 +313,7 @@ func (b *Build) ReadFile(relPath string) ([]byte, error) { func (b *Build) ParseLog(checkLog func(s []string) *string) ([]string, error) { var logs []string - f, err := gcs.NewReader(ctx, b.Bucket, b.GetBuildLogPath()) + f, err := client.NewReader(ctx, b.Bucket, b.GetBuildLogPath()) if err != nil { return logs, err } @@ -333,7 +336,7 @@ func getBuildIDFromBuildPath(buildPath string) (int, error) { // unmarshalJSONFile reads a file from gcs, parses it with xml and write to v. // v must be an arbitrary struct, slice, or string. func unmarshalJSONFile(storagePath string, v interface{}) error { - contents, err := gcs.Read(ctx, BucketName, storagePath) + contents, err := client.ReadObject(ctx, BucketName, storagePath) if err != nil { return err } diff --git a/vendor/knative.dev/pkg/webhook/webhook.go b/vendor/knative.dev/pkg/webhook/webhook.go index ef7c238da8..869269b46d 100644 --- a/vendor/knative.dev/pkg/webhook/webhook.go +++ b/vendor/knative.dev/pkg/webhook/webhook.go @@ -73,13 +73,6 @@ const ( Connect Operation = admissionv1beta1.Connect ) -var ( - // GracePeriod is the duration that the webhook will wait after it's - // context is cancelled (and probes are failing) before shutting down - // the http server. - GracePeriod = 30 * time.Second -) - // Webhook implements the external webhook for validation of // resources and configuration. type Webhook struct { @@ -145,7 +138,7 @@ func New( Logger: logger, synced: cancel, stopCh: make(chan struct{}), - gracePeriod: GracePeriod, + gracePeriod: network.DefaultDrainTimeout, } webhook.mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_types.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_types.go index 8cb8a125a6..fb6a0360d5 100644 --- a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_types.go +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_types.go @@ -28,7 +28,7 @@ import ( // Metric represents a resource to configure the metric collector with. // // +genclient -// +genreconciler +// +genreconciler:krshapedlogic=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type Metric struct { metav1.TypeMeta `json:",inline"` @@ -82,11 +82,6 @@ type MetricList struct { Items []Metric `json:"items"` } -// GetTypeMeta retrieves the ObjectMeta of the Metric. Implements the KRShaped interface. -func (t *Metric) GetTypeMeta() *metav1.TypeMeta { - return &t.TypeMeta -} - // GetStatus retrieves the status of the Metric. Implements the KRShaped interface. func (t *Metric) GetStatus() *duckv1.Status { return &t.Status.Status diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_types.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_types.go index f4f66bea9b..e38cbfaa98 100644 --- a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_types.go +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_types.go @@ -145,11 +145,6 @@ type PodAutoscalerList struct { Items []PodAutoscaler `json:"items"` } -// GetTypeMeta retrieves the ObjectMeta of the PodAutoscaler. Implements the KRShaped interface. -func (t *PodAutoscaler) GetTypeMeta() *metav1.TypeMeta { - return &t.TypeMeta -} - // GetStatus retrieves the status of the PodAutoscaler. Implements the KRShaped interface. func (t *PodAutoscaler) GetStatus() *duckv1.Status { return &t.Status.Status diff --git a/vendor/knative.dev/serving/pkg/apis/config/defaults.go b/vendor/knative.dev/serving/pkg/apis/config/defaults.go index a458e71fd3..214e736415 100644 --- a/vendor/knative.dev/serving/pkg/apis/config/defaults.go +++ b/vendor/knative.dev/serving/pkg/apis/config/defaults.go @@ -83,10 +83,12 @@ func NewDefaultsConfigFromMap(data map[string]string) (*Defaults, error) { cm.AsInt64("container-concurrency", &nc.ContainerConcurrency), cm.AsInt64("container-concurrency-max-limit", &nc.ContainerConcurrencyMaxLimit), - asQuantity("revision-cpu-request", &nc.RevisionCPURequest), - asQuantity("revision-memory-request", &nc.RevisionMemoryRequest), - asQuantity("revision-cpu-limit", &nc.RevisionCPULimit), - asQuantity("revision-memory-limit", &nc.RevisionMemoryLimit), + cm.AsQuantity("revision-cpu-request", &nc.RevisionCPURequest), + cm.AsQuantity("revision-memory-request", &nc.RevisionMemoryRequest), + cm.AsQuantity("revision-ephemeral-storage-request", &nc.RevisionEphemeralStorageRequest), + cm.AsQuantity("revision-cpu-limit", &nc.RevisionCPULimit), + cm.AsQuantity("revision-memory-limit", &nc.RevisionMemoryLimit), + cm.AsQuantity("revision-ephemeral-storage-limit", &nc.RevisionEphemeralStorageLimit), ); err != nil { return nil, err } @@ -139,10 +141,12 @@ type Defaults struct { // a containerConcurrency of 0 (i.e. unbounded). AllowContainerConcurrencyZero bool - RevisionCPURequest *resource.Quantity - RevisionCPULimit *resource.Quantity - RevisionMemoryRequest *resource.Quantity - RevisionMemoryLimit *resource.Quantity + RevisionCPURequest *resource.Quantity + RevisionCPULimit *resource.Quantity + RevisionMemoryRequest *resource.Quantity + RevisionMemoryLimit *resource.Quantity + RevisionEphemeralStorageRequest *resource.Quantity + RevisionEphemeralStorageLimit *resource.Quantity } // UserContainerName returns the name of the user container based on the context. @@ -155,17 +159,3 @@ func (d *Defaults) UserContainerName(ctx context.Context) string { } return buf.String() } - -// asQuantity parses the value at key as a *resource.Quantity into the target, if it exists. -func asQuantity(key string, target **resource.Quantity) cm.ParseFunc { - return func(data map[string]string) error { - if raw, ok := data[key]; !ok { - *target = nil - } else if val, err := resource.ParseQuantity(raw); err != nil { - return err - } else { - *target = &val - } - return nil - } -} diff --git a/vendor/knative.dev/serving/pkg/apis/config/zz_generated.deepcopy.go b/vendor/knative.dev/serving/pkg/apis/config/zz_generated.deepcopy.go index 484d01ca34..bc124553d8 100644 --- a/vendor/knative.dev/serving/pkg/apis/config/zz_generated.deepcopy.go +++ b/vendor/knative.dev/serving/pkg/apis/config/zz_generated.deepcopy.go @@ -43,6 +43,16 @@ func (in *Defaults) DeepCopyInto(out *Defaults) { x := (*in).DeepCopy() *out = &x } + if in.RevisionEphemeralStorageRequest != nil { + in, out := &in.RevisionEphemeralStorageRequest, &out.RevisionEphemeralStorageRequest + x := (*in).DeepCopy() + *out = &x + } + if in.RevisionEphemeralStorageLimit != nil { + in, out := &in.RevisionEphemeralStorageLimit, &out.RevisionEphemeralStorageLimit + x := (*in).DeepCopy() + *out = &x + } return } diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_types.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_types.go index 607249fd41..c004cb0953 100644 --- a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_types.go +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_types.go @@ -221,6 +221,14 @@ type HTTPIngressPath struct { // If RewriteHost is specified, Splits must not be. RewriteHost string `json:"rewriteHost,omitempty"` + // Headers defines header matching rules which is a map from a header name + // to HeaderMatch which specify a matching condition. + // When a request matched with all the header matching rules, + // the request is routed by the corresponding ingress rule. + // If it is empty, the headers are not used for matching + // +optional + Headers map[string]HeaderMatch `json:"headers,omitempty"` + // Splits defines the referenced service endpoints to which the traffic // will be forwarded to. // @@ -361,3 +369,9 @@ const ( func (t *Ingress) GetStatus() *duckv1.Status { return &t.Status.Status } + +// HeaderMatch represents a matching value of Headers in HTTPIngressPath. +// Currently, only the exact matching is supported. +type HeaderMatch struct { + Exact string `json:"exact"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go index 0f4641d8b7..bd179bb46f 100644 --- a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go @@ -161,6 +161,13 @@ func (in *HTTP01Challenge) DeepCopy() *HTTP01Challenge { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HTTPIngressPath) DeepCopyInto(out *HTTPIngressPath) { *out = *in + if in.Headers != nil { + in, out := &in.Headers, &out.Headers + *out = make(map[string]HeaderMatch, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } if in.Splits != nil { in, out := &in.Splits, &out.Splits *out = make([]IngressBackendSplit, len(*in)) @@ -242,6 +249,22 @@ func (in *HTTPRetry) DeepCopy() *HTTPRetry { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HeaderMatch) DeepCopyInto(out *HeaderMatch) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HeaderMatch. +func (in *HeaderMatch) DeepCopy() *HeaderMatch { + if in == nil { + return nil + } + out := new(HeaderMatch) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Ingress) DeepCopyInto(out *Ingress) { *out = *in diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_defaults.go index 0849af3742..224288f614 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_defaults.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_defaults.go @@ -22,6 +22,7 @@ import ( "github.com/google/uuid" corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" "knative.dev/pkg/apis" "knative.dev/pkg/kmeta" "knative.dev/pkg/ptr" @@ -69,28 +70,33 @@ func (rs *RevisionSpec) applyDefault(container *corev1.Container, cfg *config.Co if container.Resources.Requests == nil { container.Resources.Requests = corev1.ResourceList{} } - if _, ok := container.Resources.Requests[corev1.ResourceCPU]; !ok { - if rc := cfg.Defaults.RevisionCPURequest; rc != nil { - container.Resources.Requests[corev1.ResourceCPU] = *rc - } - } - if _, ok := container.Resources.Requests[corev1.ResourceMemory]; !ok { - if rm := cfg.Defaults.RevisionMemoryRequest; rm != nil { - container.Resources.Requests[corev1.ResourceMemory] = *rm - } - } if container.Resources.Limits == nil { container.Resources.Limits = corev1.ResourceList{} } - if _, ok := container.Resources.Limits[corev1.ResourceCPU]; !ok { - if rc := cfg.Defaults.RevisionCPULimit; rc != nil { - container.Resources.Limits[corev1.ResourceCPU] = *rc + + for _, r := range []struct { + Name corev1.ResourceName + Request *resource.Quantity + Limit *resource.Quantity + }{{ + Name: corev1.ResourceCPU, + Request: cfg.Defaults.RevisionCPURequest, + Limit: cfg.Defaults.RevisionCPULimit, + }, { + Name: corev1.ResourceMemory, + Request: cfg.Defaults.RevisionMemoryRequest, + Limit: cfg.Defaults.RevisionMemoryLimit, + }, { + Name: corev1.ResourceEphemeralStorage, + Request: cfg.Defaults.RevisionEphemeralStorageRequest, + Limit: cfg.Defaults.RevisionEphemeralStorageLimit, + }} { + if _, ok := container.Resources.Requests[r.Name]; !ok && r.Request != nil { + container.Resources.Requests[r.Name] = *r.Request } - } - if _, ok := container.Resources.Limits[corev1.ResourceMemory]; !ok { - if rm := cfg.Defaults.RevisionMemoryLimit; rm != nil { - container.Resources.Limits[corev1.ResourceMemory] = *rm + if _, ok := container.Resources.Limits[r.Name]; !ok && r.Limit != nil { + container.Resources.Limits[r.Name] = *r.Limit } } diff --git a/vendor/knative.dev/serving/pkg/autoscaler/config/config.go b/vendor/knative.dev/serving/pkg/autoscaler/config/config.go index 6fe41e1caf..288286ab95 100644 --- a/vendor/knative.dev/serving/pkg/autoscaler/config/config.go +++ b/vendor/knative.dev/serving/pkg/autoscaler/config/config.go @@ -80,7 +80,6 @@ type Config struct { StableWindow time.Duration PanicWindowPercentage float64 PanicThresholdPercentage float64 - TickInterval time.Duration ScaleToZeroGracePeriod time.Duration ScaleToZeroPodRetentionPeriod time.Duration @@ -106,7 +105,6 @@ func defaultConfig() *Config { StableWindow: 60 * time.Second, ScaleToZeroGracePeriod: 30 * time.Second, ScaleToZeroPodRetentionPeriod: 0 * time.Second, - TickInterval: 2 * time.Second, PodAutoscalerClass: autoscaling.KPA, AllowZeroInitialScale: false, InitialScale: 1, @@ -139,7 +137,6 @@ func NewConfigFromMap(data map[string]string) (*Config, error) { cm.AsDuration("stable-window", &lc.StableWindow), cm.AsDuration("scale-to-zero-grace-period", &lc.ScaleToZeroGracePeriod), cm.AsDuration("scale-to-zero-pod-retention-period", &lc.ScaleToZeroPodRetentionPeriod), - cm.AsDuration("tick-interval", &lc.TickInterval), ); err != nil { return nil, fmt.Errorf("failed to parse data: %w", err) } @@ -203,9 +200,12 @@ func validate(lc *Config) (*Config, error) { return nil, fmt.Errorf("stable-window = %v, must be specified with at most second precision", lc.StableWindow) } - effPW := time.Duration(lc.PanicWindowPercentage / 100 * float64(lc.StableWindow)) - if effPW < BucketSize || effPW > lc.StableWindow { - return nil, fmt.Errorf("panic-window-percentage = %v, must be in [%v, 100] interval", lc.PanicWindowPercentage, 100*float64(BucketSize)/float64(lc.StableWindow)) + // We ensure BucketSize in the `MakeMetric`, so just ensure percentage is in the correct region. + if lc.PanicWindowPercentage < autoscaling.PanicWindowPercentageMin || + lc.PanicWindowPercentage > autoscaling.PanicWindowPercentageMax { + return nil, fmt.Errorf("panic-window-percentage = %v, must be in [%v, %v] interval", + lc.PanicWindowPercentage, autoscaling.PanicWindowPercentageMin, autoscaling.PanicWindowPercentageMax) + } if lc.InitialScale < 0 || (lc.InitialScale == 0 && !lc.AllowZeroInitialScale) { diff --git a/vendor/modules.txt b/vendor/modules.txt index 6b24ad762f..795c1c783c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1007,7 +1007,7 @@ k8s.io/utils/buffer k8s.io/utils/integer k8s.io/utils/pointer k8s.io/utils/trace -# knative.dev/eventing v0.15.1-0.20200529211210-a70e7c4a28f3 +# knative.dev/eventing v0.15.1-0.20200602132917-9119a2e34905 ## explicit knative.dev/eventing/pkg/apis/config knative.dev/eventing/pkg/apis/configs @@ -1107,7 +1107,7 @@ knative.dev/eventing/test/test_images/performance knative.dev/eventing/test/test_images/recordevents knative.dev/eventing/test/test_images/sendevents knative.dev/eventing/test/test_images/transformevents -# knative.dev/pkg v0.0.0-20200527173759-2d1a04d1ff82 +# knative.dev/pkg v0.0.0-20200601184204-18c577c87d4f ## explicit knative.dev/pkg/apis knative.dev/pkg/apis/duck @@ -1211,7 +1211,7 @@ knative.dev/pkg/webhook/resourcesemantics knative.dev/pkg/webhook/resourcesemantics/conversion knative.dev/pkg/webhook/resourcesemantics/defaulting knative.dev/pkg/webhook/resourcesemantics/validation -# knative.dev/serving v0.15.1-0.20200527151759-5b8ff09ace4f +# knative.dev/serving v0.15.1-0.20200602105317-468ae278d9e3 ## explicit knative.dev/serving/pkg/apis/autoscaling knative.dev/serving/pkg/apis/autoscaling/v1alpha1 @@ -1257,7 +1257,8 @@ knative.dev/serving/pkg/client/listers/networking/v1alpha1 knative.dev/serving/pkg/client/listers/serving/v1 knative.dev/serving/pkg/client/listers/serving/v1alpha1 knative.dev/serving/pkg/client/listers/serving/v1beta1 -# knative.dev/test-infra v0.0.0-20200527185659-fc87694eb879 +# knative.dev/test-infra v0.0.0-20200602024303-e406de9f65c4 +## explicit knative.dev/test-infra/scripts # sigs.k8s.io/yaml v1.2.0 => sigs.k8s.io/yaml v1.1.0 ## explicit