diff --git a/go.mod b/go.mod index a165a1975..0fa4e1b81 100644 --- a/go.mod +++ b/go.mod @@ -21,11 +21,11 @@ require ( k8s.io/cli-runtime v0.19.7 k8s.io/client-go v0.19.7 k8s.io/code-generator v0.19.7 - knative.dev/eventing v0.21.0 + knative.dev/eventing v0.21.1-0.20210228124848-2db68776f120 knative.dev/hack v0.0.0-20210203173706-8368e1f6eacf - knative.dev/networking v0.0.0-20210216014426-94bfc013982b - knative.dev/pkg v0.0.0-20210216013737-584933f8280b - knative.dev/serving v0.21.0 + knative.dev/networking v0.0.0-20210301023148-54c0eb153147 + knative.dev/pkg v0.0.0-20210226182947-9039dc189ced + knative.dev/serving v0.21.1-0.20210301115148-472f8e2bacf2 sigs.k8s.io/yaml v1.2.0 ) diff --git a/go.sum b/go.sum index 869be65d5..9ec76cf04 100644 --- a/go.sum +++ b/go.sum @@ -1305,21 +1305,21 @@ k8s.io/utils v0.0.0-20200729134348-d5654de09c73 h1:uJmqzgNWG7XyClnU/mLPBWwfKKF1K k8s.io/utils v0.0.0-20200729134348-d5654de09c73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= 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/caching v0.0.0-20210215030244-1212288570f0/go.mod h1:rAPalJe9Lx3jHffJpackk5WjZYl3j2QvXUgw0GPllxQ= -knative.dev/eventing v0.21.0 h1:oZoL0lXXslUClNvoi5mLO2YI6zn2C8qg80mz8Y6Vmkg= -knative.dev/eventing v0.21.0/go.mod h1:JjbVEOTJJHqo9CTxbTfrMn018hG8fOr3UfBoCJ7KWaA= +knative.dev/caching v0.0.0-20210216192653-d1dfa6451cd1/go.mod h1:1UeUQ6zQ3vHtZRpfuAW/f5oXb11EBqICfJqIzOeOrqU= +knative.dev/eventing v0.21.1-0.20210228124848-2db68776f120 h1:FMOaAAdp0EQEQRPckjGgVtOZIuT3XxcSUcfF1bloOzQ= +knative.dev/eventing v0.21.1-0.20210228124848-2db68776f120/go.mod h1:KtN2FEhPzxyqXKxpJufdq0lzL3Iu+5qjFqBal8Lg2tQ= knative.dev/hack v0.0.0-20210203173706-8368e1f6eacf h1:u4cY4jr2LYvhoz/1HBWEPsMiLkm0HMdDTfmmw1RE8zE= knative.dev/hack v0.0.0-20210203173706-8368e1f6eacf/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= -knative.dev/networking v0.0.0-20210215030235-088986a1c2a3/go.mod h1:pmAMQjMqQUxpK0UyjE71KljMs6rwDMVIAlvrZsU3I6Y= -knative.dev/networking v0.0.0-20210216014426-94bfc013982b h1:708bHZC2RPjdx8MLH7OASqGP+fhmarJJxVIZoIy+msY= -knative.dev/networking v0.0.0-20210216014426-94bfc013982b/go.mod h1:Crdn87hxdFd3Jj6PIyrjzGnr8OGHX35k5xo9jlOrjjA= -knative.dev/pkg v0.0.0-20210212203835-448ae657fb5f/go.mod h1:TJSdebQOWX5N2bszohOYVi0H1QtXbtlYLuMghAFBMhY= +knative.dev/networking v0.0.0-20210216193011-d5e05ad323f0/go.mod h1:Crdn87hxdFd3Jj6PIyrjzGnr8OGHX35k5xo9jlOrjjA= +knative.dev/networking v0.0.0-20210301023148-54c0eb153147 h1:dX51VdzJFfOcpbz3qvD3ohmg0A+oX/qil3r+dHbFtS8= +knative.dev/networking v0.0.0-20210301023148-54c0eb153147/go.mod h1:AZjAFUWHJp9+HCc3Zg6766X9FSptM10HaWP7Ff1U63I= knative.dev/pkg v0.0.0-20210215165523-84c98f3c3e7a/go.mod h1:TJSdebQOWX5N2bszohOYVi0H1QtXbtlYLuMghAFBMhY= -knative.dev/pkg v0.0.0-20210216013737-584933f8280b h1:2v+GBBenjPXhtk3KX/YqxCQVBU6o/AaRkkqE58lgFRQ= -knative.dev/pkg v0.0.0-20210216013737-584933f8280b/go.mod h1:TJSdebQOWX5N2bszohOYVi0H1QtXbtlYLuMghAFBMhY= -knative.dev/reconciler-test v0.0.0-20210216030508-77f50054d024/go.mod h1:RP/K5xJylB72Go6eAsXYEsQHp4zCCNMNjmsqhvq7wko= -knative.dev/serving v0.21.0 h1:bdg0JqNovzlMQB2IxXU/iJKF2zPZH6/yXiwiUtr7vtY= -knative.dev/serving v0.21.0/go.mod h1:PU9k1Y6YMG27XQldEu5agNkcebvSafUXKXPircQYCsE= +knative.dev/pkg v0.0.0-20210225221047-07b5ddfaea60/go.mod h1:TJSdebQOWX5N2bszohOYVi0H1QtXbtlYLuMghAFBMhY= +knative.dev/pkg v0.0.0-20210226182947-9039dc189ced h1:OCtTbXsJhiR35qCDxFj9Xc8sU3i87ePbc7YlHCt0al4= +knative.dev/pkg v0.0.0-20210226182947-9039dc189ced/go.mod h1:TJSdebQOWX5N2bszohOYVi0H1QtXbtlYLuMghAFBMhY= +knative.dev/reconciler-test v0.0.0-20210223181346-209f32c8cdc4/go.mod h1:RP/K5xJylB72Go6eAsXYEsQHp4zCCNMNjmsqhvq7wko= +knative.dev/serving v0.21.1-0.20210301115148-472f8e2bacf2 h1:XC/vJOFmwOAzOQXs1vCEOfk/3ya79SFhpVHGqDQToSk= +knative.dev/serving v0.21.1-0.20210301115148-472f8e2bacf2/go.mod h1:a4eAD31lUwrx8M7xu1EX7Q5tPEIcGdT/XmA3RRezV70= 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/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go index 06d436648..78ff96730 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go @@ -271,6 +271,9 @@ func NewImpl(ctx {{.contextContext|raw}}, r Interface{{if .hasClass}}, classValu rec.skipStatusUpdates = true } {{- end}} + if opts.DemoteFunc != nil { + rec.DemoteFunc = opts.DemoteFunc + } } rec.Recorder = createRecorder(ctx, agentName) diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go index 10149fadd..cc6757da8 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go @@ -363,6 +363,9 @@ func NewReconciler(ctx {{.contextContext|raw}}, logger *{{.zapSugaredLogger|raw} rec.skipStatusUpdates = true } {{- end}} + if opts.DemoteFunc != nil { + rec.DemoteFunc = opts.DemoteFunc + } } return rec diff --git a/vendor/knative.dev/pkg/controller/controller.go b/vendor/knative.dev/pkg/controller/controller.go index 27fe75e40..2a28497fa 100644 --- a/vendor/knative.dev/pkg/controller/controller.go +++ b/vendor/knative.dev/pkg/controller/controller.go @@ -152,6 +152,13 @@ func FilterControllerGK(gk schema.GroupKind) func(obj interface{}) bool { } } +// FilterController makes it simple to create FilterFunc's for use with +// cache.FilteringResourceEventHandler that filter based on the +// controlling resource. +func FilterController(r kmeta.OwnerRefable) func(obj interface{}) bool { + return FilterControllerGK(r.GetGroupVersionKind().GroupKind()) +} + // FilterWithName makes it simple to create FilterFunc's for use with // cache.FilteringResourceEventHandler that filter based on a name. func FilterWithName(name string) func(obj interface{}) bool { diff --git a/vendor/knative.dev/pkg/controller/options.go b/vendor/knative.dev/pkg/controller/options.go index b40b5a359..8d61835e6 100644 --- a/vendor/knative.dev/pkg/controller/options.go +++ b/vendor/knative.dev/pkg/controller/options.go @@ -35,6 +35,9 @@ type Options struct { // SkipStatusUpdates configures this reconciler to either do automated status // updates (default) or skip them if this is set to true. SkipStatusUpdates bool + + // DemoteFunc configures the demote function this reconciler uses + DemoteFunc func(b reconciler.Bucket) } // OptionsFn is a callback method signature that accepts an Impl and returns diff --git a/vendor/knative.dev/pkg/metrics/exporter.go b/vendor/knative.dev/pkg/metrics/exporter.go index b98a18de1..3fc4966fd 100644 --- a/vendor/knative.dev/pkg/metrics/exporter.go +++ b/vendor/knative.dev/pkg/metrics/exporter.go @@ -21,7 +21,6 @@ import ( "errors" "fmt" "strings" - "sync" "go.opencensus.io/resource" "go.opencensus.io/stats/view" @@ -32,9 +31,14 @@ import ( var ( curMetricsExporter view.Exporter curMetricsConfig *metricsConfig - metricsMux sync.RWMutex + mWorker *metricsWorker ) +func init() { + mWorker = newMetricsWorker() + go mWorker.start() +} + // SecretFetcher is a function (extracted from SecretNamespaceLister) for fetching // a specific Secret. This avoids requiring global or namespace list in controllers. type SecretFetcher func(string) (*corev1.Secret, error) @@ -154,28 +158,14 @@ func UpdateExporter(ctx context.Context, ops ExporterOptions, logger *zap.Sugare // Updating the metrics config and the metrics exporters needs to be atomic to // avoid using an outdated metrics config with new exporters. - metricsMux.Lock() - defer metricsMux.Unlock() - - if isNewExporterRequired(newConfig) { - logger.Info("Flushing the existing exporter before setting up the new exporter.") - flushGivenExporter(curMetricsExporter) - e, f, err := newMetricsExporter(newConfig, logger) - if err != nil { - logger.Errorw("Failed to update a new metrics exporter based on metric config", zap.Error(err), "config", newConfig) - return err - } - existingConfig := curMetricsConfig - curMetricsExporter = e - if err := setFactory(f); err != nil { - logger.Errorw("Failed to update metrics factory when loading metric config", zap.Error(err), "config", newConfig) - return err - } - logger.Infof("Successfully updated the metrics exporter; old config: %v; new config %v", existingConfig, newConfig) + updateCmd := &updateMetricsConfigWithExporter{ + ctx: ctx, + newConfig: newConfig, + done: make(chan error), } - - setCurMetricsConfigUnlocked(newConfig) - return nil + mWorker.c <- updateCmd + err = <-updateCmd.done + return err } // isNewExporterRequired compares the non-nil newConfig against curMetricsConfig. When backend changes, @@ -228,27 +218,35 @@ func newMetricsExporter(config *metricsConfig, logger *zap.SugaredLogger) (view. } func getCurMetricsExporter() view.Exporter { - metricsMux.RLock() - defer metricsMux.RUnlock() - return curMetricsExporter + readCmd := &readExporter{done: make(chan *view.Exporter)} + mWorker.c <- readCmd + e := <-readCmd.done + return *e } func setCurMetricsExporter(e view.Exporter) { - metricsMux.Lock() - defer metricsMux.Unlock() - curMetricsExporter = e + setCmd := &setExporter{ + newExporter: &e, + done: make(chan struct{}), + } + mWorker.c <- setCmd + <-setCmd.done } func getCurMetricsConfig() *metricsConfig { - metricsMux.RLock() - defer metricsMux.RUnlock() - return curMetricsConfig + readCmd := &readMetricsConfig{done: make(chan *metricsConfig)} + mWorker.c <- readCmd + cfg := <-readCmd.done + return cfg } func setCurMetricsConfig(c *metricsConfig) { - metricsMux.Lock() - defer metricsMux.Unlock() - setCurMetricsConfigUnlocked(c) + setCmd := &setMetricsConfig{ + newConfig: c, + done: make(chan struct{}), + } + mWorker.c <- setCmd + <-setCmd.done } func setCurMetricsConfigUnlocked(c *metricsConfig) { diff --git a/vendor/knative.dev/pkg/metrics/metrics_worker.go b/vendor/knative.dev/pkg/metrics/metrics_worker.go new file mode 100644 index 000000000..0b7753acb --- /dev/null +++ b/vendor/knative.dev/pkg/metrics/metrics_worker.go @@ -0,0 +1,111 @@ +/* +Copyright 2021 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package metrics + +import ( + "context" + + "go.opencensus.io/stats/view" + "go.uber.org/zap" + "knative.dev/pkg/logging" +) + +type metricsWorker struct { + c chan command +} + +func newMetricsWorker() *metricsWorker { + return &metricsWorker{c: make(chan command)} +} + +type command interface { + handleCommand(w *metricsWorker) +} + +type readExporter struct { + done chan *view.Exporter +} + +type setExporter struct { + newExporter *view.Exporter + done chan struct{} +} + +type readMetricsConfig struct { + done chan *metricsConfig +} + +type updateMetricsConfigWithExporter struct { + ctx context.Context + newConfig *metricsConfig + done chan error +} + +type setMetricsConfig struct { + newConfig *metricsConfig + done chan struct{} +} + +func (cmd *readMetricsConfig) handleCommand(w *metricsWorker) { + cmd.done <- curMetricsConfig +} + +func (cmd *setMetricsConfig) handleCommand(w *metricsWorker) { + setCurMetricsConfigUnlocked(cmd.newConfig) + cmd.done <- struct{}{} +} + +func (cmd *updateMetricsConfigWithExporter) handleCommand(w *metricsWorker) { + ctx := cmd.ctx + logger := logging.FromContext(ctx) + if isNewExporterRequired(cmd.newConfig) { + logger.Info("Flushing the existing exporter before setting up the new exporter.") + flushGivenExporter(curMetricsExporter) + e, f, err := newMetricsExporter(cmd.newConfig, logger) + if err != nil { + logger.Errorw("Failed to update a new metrics exporter based on metric config", zap.Error(err), "config", cmd.newConfig) + cmd.done <- err + return + } + existingConfig := curMetricsConfig + curMetricsExporter = e + if err := setFactory(f); err != nil { + logger.Errorw("Failed to update metrics factory when loading metric config", zap.Error(err), "config", cmd.newConfig) + cmd.done <- err + return + } + logger.Infof("Successfully updated the metrics exporter; old config: %v; new config %v", existingConfig, cmd.newConfig) + } + setCurMetricsConfigUnlocked(cmd.newConfig) + cmd.done <- nil +} + +func (w *metricsWorker) start() { + for { + cmd := <-w.c + cmd.handleCommand(w) + } +} + +func (cmd *setExporter) handleCommand(w *metricsWorker) { + curMetricsExporter = *cmd.newExporter + cmd.done <- struct{}{} +} + +func (cmd *readExporter) handleCommand(w *metricsWorker) { + cmd.done <- &curMetricsExporter +} diff --git a/vendor/knative.dev/pkg/metrics/resource_view.go b/vendor/knative.dev/pkg/metrics/resource_view.go index 7135af70a..236fd588b 100644 --- a/vendor/knative.dev/pkg/metrics/resource_view.go +++ b/vendor/knative.dev/pkg/metrics/resource_view.go @@ -82,10 +82,16 @@ func cleanup() { expiryCutoff := allMeters.clock.Now().Add(-1 * maxMeterExporterAge) allMeters.lock.Lock() defer allMeters.lock.Unlock() + resourceViews.lock.Lock() + defer resourceViews.lock.Unlock() for key, meter := range allMeters.meters { if key != "" && meter.t.Before(expiryCutoff) { flushGivenExporter(meter.e) + // Make a copy of views to avoid data races + viewsCopy := copyViews(resourceViews.views) + meter.m.Unregister(viewsCopy...) delete(allMeters.meters, key) + meter.m.Stop() } } } @@ -139,7 +145,7 @@ func RegisterResourceView(views ...*view.View) error { return nil } -// UnregisterResourceView is similar to view.Unregiste(), except that it will +// UnregisterResourceView is similar to view.Unregister(), except that it will // unregister the view across all Resources tracked byt he system, rather than // simply the default view. func UnregisterResourceView(views ...*view.View) { diff --git a/vendor/knative.dev/pkg/network/network.go b/vendor/knative.dev/pkg/network/network.go index b2ac63ce7..cf5feaa8f 100644 --- a/vendor/knative.dev/pkg/network/network.go +++ b/vendor/knative.dev/pkg/network/network.go @@ -17,7 +17,6 @@ limitations under the License. package network import ( - "fmt" "net/http" "strings" "time" @@ -52,33 +51,19 @@ const ( // uses to find out which version of the networking config is deployed. HashHeaderName = "K-Network-Hash" + // KubeProbeUAPrefix is the prefix for the User-Agent header. // Since K8s 1.8, prober requests have // User-Agent = "kube-probe/{major-version}.{minor-version}". KubeProbeUAPrefix = "kube-probe/" + // KubeletProbeHeaderName is the header name to augment the probes, because // Istio with mTLS rewrites probes, but their probes pass a different - // user-agent. So we augment the probes with this header. + // user-agent. KubeletProbeHeaderName = "K-Kubelet-Probe" ) // IsKubeletProbe returns true if the request is a Kubernetes probe. func IsKubeletProbe(r *http.Request) bool { - return strings.HasPrefix(r.Header.Get("User-Agent"), KubeProbeUAPrefix) || + return strings.HasPrefix(r.Header.Get(UserAgentKey), KubeProbeUAPrefix) || r.Header.Get(KubeletProbeHeaderName) != "" } - -// IsKProbe returns true if the request is a knatvie probe. -func IsKProbe(r *http.Request) bool { - return r.Header.Get(ProbeHeaderName) == ProbeHeaderValue -} - -// ServeKProbe serve KProbe requests. -func ServeKProbe(w http.ResponseWriter, r *http.Request) { - hh := r.Header.Get(HashHeaderName) - if hh == "" { - http.Error(w, fmt.Sprintf("a probe request must contain a non-empty %q header", HashHeaderName), http.StatusBadRequest) - return - } - w.Header().Set(HashHeaderName, hh) - w.WriteHeader(http.StatusOK) -} diff --git a/vendor/knative.dev/pkg/system/clock.go b/vendor/knative.dev/pkg/system/clock.go deleted file mode 100644 index 7d99d9b5c..000000000 --- a/vendor/knative.dev/pkg/system/clock.go +++ /dev/null @@ -1,32 +0,0 @@ -/* -Copyright 2019 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package system - -import ( - "time" -) - -// Mockable interface for time based testing -type Clock interface { - Now() time.Time -} - -type RealClock struct{} - -func (RealClock) Now() time.Time { - return time.Now() -} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/annotation_validation.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/annotation_validation.go index d4230a165..805047e24 100644 --- a/vendor/knative.dev/serving/pkg/apis/autoscaling/annotation_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/annotation_validation.go @@ -58,6 +58,7 @@ func ValidateAnnotations(ctx context.Context, config *autoscalerconfig.Config, a Also(validateLastPodRetention(anns)). Also(validateScaleDownDelay(anns)). Also(validateMetric(anns)). + Also(validateAlgorithm(anns)). Also(validateInitialScale(config, anns)) } @@ -70,6 +71,22 @@ func validateClass(annotations map[string]string) *apis.FieldError { return nil } +func validateAlgorithm(annotations map[string]string) *apis.FieldError { + // Not a KPA? Don't validate, custom autoscalers might have custom values. + if c := annotations[ClassAnnotationKey]; c != KPA { + return nil + } + if a := annotations[MetricAggregationAlgorithmKey]; a != "" { + switch a { + case MetricAggregationAlgorithmLinear, MetricAggregationAlgorithmWeightedExponential: + return nil + default: + return apis.ErrInvalidValue(a, MetricAggregationAlgorithmKey) + } + } + return nil +} + func validateFloats(annotations map[string]string) (errs *apis.FieldError) { if v, ok := annotations[PanicWindowPercentageAnnotationKey]; ok { if fv, err := strconv.ParseFloat(v, 64); err != nil { diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/register.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/register.go index 27920743d..8fe83fb75 100644 --- a/vendor/knative.dev/serving/pkg/apis/autoscaling/register.go +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/register.go @@ -83,6 +83,28 @@ const ( // scale-to-zero-pod-retention-period global setting. ScaleToZeroPodRetentionPeriodKey = GroupName + "/scaleToZeroPodRetentionPeriod" + // MetricAggregationAlgorithmKey is the annotation that can be used for selection + // of the algorithm to use for averaging metric data in the Autoscaler. + // Since autoscalers are a pluggable concept, this field is only validated + // for Revisions that are owned by Knative Pod Autoscaler. + // The algorithm will apply to both panic and stagble windows. + // NB: this is an Alpha feature and can be removed or modified + // at any point. + // Possible values for KPA are: + // - empty/missing or "linear" — linear average over the whole + // metric window (default); + // - weightedExponential — weighted average with exponential decay. + // KPA will compute the decay multiplier automatically based on the window size + // and it is at least 0.2. This algorithm might not utilize all the values + // in the window, due to their coefficients being infinitesimal. + MetricAggregationAlgorithmKey = GroupName + "/metricAggregationAlgorithm" + // MetricAggregationAlgorithmLinear is the linear aggregation algorithm with all weights + // equal to 1. + MetricAggregationAlgorithmLinear = "linear" + // MetricAggregationAlgorithmWeightedExponential is the weighted aggregation algorithm + // with exponentially decaying weights. + MetricAggregationAlgorithmWeightedExponential = "weightedExponential" + // WindowAnnotationKey is the annotation to specify the time // interval over which to calculate the average metric. Larger // values result in more smoothing. For example, diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_validation.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_validation.go index fd1adb049..f2f40f3d9 100644 --- a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_validation.go @@ -26,7 +26,7 @@ import ( // Validate validates the entire Metric. func (m *Metric) Validate(ctx context.Context) *apis.FieldError { - return serving.ValidateObjectMetadata(ctx, m.GetObjectMeta()).ViaField("metadata"). + return serving.ValidateObjectMetadata(ctx, m.GetObjectMeta(), true).ViaField("metadata"). Also(m.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) } diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go index 1a17d8ab7..cb9db30c9 100644 --- a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go @@ -26,7 +26,7 @@ import ( // Validate implements apis.Validatable interface. func (pa *PodAutoscaler) Validate(ctx context.Context) *apis.FieldError { - return serving.ValidateObjectMetadata(ctx, pa.GetObjectMeta()).ViaField("metadata"). + return serving.ValidateObjectMetadata(ctx, pa.GetObjectMeta(), true).ViaField("metadata"). Also(pa.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) } diff --git a/vendor/knative.dev/serving/pkg/apis/config/features.go b/vendor/knative.dev/serving/pkg/apis/config/features.go index f916df878..2cf7fbbba 100644 --- a/vendor/knative.dev/serving/pkg/apis/config/features.go +++ b/vendor/knative.dev/serving/pkg/apis/config/features.go @@ -51,6 +51,7 @@ func defaultFeaturesConfig() *Features { PodSpecSecurityContext: Disabled, PodSpecTolerations: Disabled, TagHeaderBasedRouting: Disabled, + AutoDetectHTTP2: Disabled, } } @@ -68,7 +69,8 @@ func NewFeaturesConfigFromMap(data map[string]string) (*Features, error) { asFlag("kubernetes.podspec-runtimeclassname", &nc.PodSpecRuntimeClassName), asFlag("kubernetes.podspec-securitycontext", &nc.PodSpecSecurityContext), asFlag("kubernetes.podspec-tolerations", &nc.PodSpecTolerations), - asFlag("tag-header-based-routing", &nc.TagHeaderBasedRouting)); err != nil { + asFlag("tag-header-based-routing", &nc.TagHeaderBasedRouting), + asFlag("autodetect-http2", &nc.AutoDetectHTTP2)); err != nil { return nil, err } return nc, nil @@ -91,6 +93,7 @@ type Features struct { PodSpecSecurityContext Flag PodSpecTolerations Flag TagHeaderBasedRouting Flag + AutoDetectHTTP2 Flag } // asFlag parses the value at key as a Flag into the target, if it exists. diff --git a/vendor/knative.dev/serving/pkg/apis/serving/metadata_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/metadata_validation.go index 81c6e39d9..3b08ee66c 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/metadata_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/metadata_validation.go @@ -24,33 +24,27 @@ import ( "k8s.io/apimachinery/pkg/api/equality" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/sets" "knative.dev/pkg/apis" "knative.dev/serving/pkg/apis/autoscaling" "knative.dev/serving/pkg/apis/config" ) -var ( - allowedAnnotations = sets.NewString( - CreatorAnnotation, - ForceUpgradeAnnotationKey, - RevisionLastPinnedAnnotationKey, - RevisionPreservedAnnotationKey, - RolloutDurationKey, - RoutesAnnotationKey, - RoutingStateModifiedAnnotationKey, - UpdaterAnnotation, - ) -) - -// ValidateObjectMetadata validates that `metadata` stanza of the +// ValidateObjectMetadata validates that the `metadata` stanza of the // resources is correct. -func ValidateObjectMetadata(ctx context.Context, meta metav1.Object) *apis.FieldError { - return apis.ValidateObjectMetadata(meta). - Also(autoscaling.ValidateAnnotations(ctx, config.FromContextOrDefaults(ctx).Autoscaler, meta.GetAnnotations()). - Also(validateKnativeAnnotations(meta.GetAnnotations())). - ViaField("annotations")) +// If `allowAutoscalingAnnotations` is true autoscaling annotations, if +// present, are validated. If `allowAutoscalingAnnotations` is false +// autoscaling annotations are validated not to be present. +func ValidateObjectMetadata(ctx context.Context, meta metav1.Object, allowAutoscalingAnnotations bool) *apis.FieldError { + errs := apis.ValidateObjectMetadata(meta) + + if allowAutoscalingAnnotations { + errs = errs.Also(autoscaling.ValidateAnnotations(ctx, config.FromContextOrDefaults(ctx).Autoscaler, meta.GetAnnotations()).ViaField("annotations")) + } else { + errs = errs.Also(ValidateHasNoAutoscalingAnnotation(meta.GetAnnotations()).ViaField("annotations")) + } + + return errs } // ValidateRolloutDurationAnnotation validates the rollout duration annotation. @@ -81,15 +75,6 @@ func ValidateRolloutDurationAnnotation(annos map[string]string) (errs *apis.Fiel return errs } -func validateKnativeAnnotations(annotations map[string]string) (errs *apis.FieldError) { - for key := range annotations { - if !allowedAnnotations.Has(key) && strings.HasPrefix(key, GroupNamePrefix) { - errs = errs.Also(apis.ErrInvalidKeyName(key, apis.CurrentField)) - } - } - return errs -} - // ValidateHasNoAutoscalingAnnotation validates that the respective entity does not have // annotations from the autoscaling group. It's to be used to validate Service and // Configuration. diff --git a/vendor/knative.dev/serving/pkg/apis/serving/register.go b/vendor/knative.dev/serving/pkg/apis/serving/register.go index ea8d6471e..c0e1dd61b 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/register.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/register.go @@ -91,18 +91,12 @@ const ( // DomainMappingLabelKey is the label key attached to Ingress resources to indicate // which DomainMapping triggered their creation. - DomainMappingLabelKey = GroupName + "/domainmapping" + DomainMappingLabelKey = GroupName + "/domainMapping" // ConfigurationGenerationLabelKey is the label key attached to a Revision indicating the // metadata generation of the Configuration that created this revision ConfigurationGenerationLabelKey = GroupName + "/configurationGeneration" - // ForceUpgradeAnnotationKey is the annotation which was added to resources - // upgraded from v1alpha1. - // This annotation is no longer used since v1alpha1 was removed, but - // must continue to be allowed since it may be present on existing resources. - ForceUpgradeAnnotationKey = GroupName + "/forceUpgrade" - // CreatorAnnotation is the annotation key to describe the user that // created the resource. CreatorAnnotation = GroupName + "/creator" diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_validation.go index 6b719ae6b..bc253be6e 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_validation.go @@ -31,9 +31,8 @@ func (c *Configuration) Validate(ctx context.Context) (errs *apis.FieldError) { // have changed (i.e. due to config-defaults changes), we elide the metadata and // spec validation. if !apis.IsInStatusUpdate(ctx) { - errs = errs.Also(serving.ValidateObjectMetadata(ctx, c.GetObjectMeta())) + errs = errs.Also(serving.ValidateObjectMetadata(ctx, c.GetObjectMeta(), false)) errs = errs.Also(c.validateLabels().ViaField("labels")) - errs = errs.Also(serving.ValidateHasNoAutoscalingAnnotation(c.GetAnnotations()).ViaField("annotations")) errs = errs.ViaField("metadata") ctx = apis.WithinParent(ctx, c.ObjectMeta) diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_validation.go index e5c961bde..c5371167e 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_validation.go @@ -32,7 +32,7 @@ import ( // Validate ensures Revision is properly configured. func (r *Revision) Validate(ctx context.Context) *apis.FieldError { - errs := serving.ValidateObjectMetadata(ctx, r.GetObjectMeta()).Also( + errs := serving.ValidateObjectMetadata(ctx, r.GetObjectMeta(), true).Also( r.ValidateLabels().ViaField("labels")).ViaField("metadata") errs = errs.Also(r.Status.Validate(apis.WithinStatus(ctx)).ViaField("status")) diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/route_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_validation.go index 0a9a4c9d6..f0ba15213 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1/route_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_validation.go @@ -28,7 +28,7 @@ import ( // Validate makes sure that Route is properly configured. func (r *Route) Validate(ctx context.Context) *apis.FieldError { - errs := serving.ValidateObjectMetadata(ctx, r.GetObjectMeta()).Also( + errs := serving.ValidateObjectMetadata(ctx, r.GetObjectMeta(), false).Also( r.validateLabels().ViaField("labels")) errs = errs.Also(serving.ValidateRolloutDurationAnnotation( r.GetAnnotations()).ViaField("annotations")) diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/service_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_validation.go index eb1ecbf63..33b54aadb 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1/service_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_validation.go @@ -31,12 +31,10 @@ func (s *Service) Validate(ctx context.Context) (errs *apis.FieldError) { // have changed (i.e. due to config-defaults changes), we elide the metadata and // spec validation. if !apis.IsInStatusUpdate(ctx) { - errs = errs.Also(serving.ValidateObjectMetadata(ctx, s.GetObjectMeta())) + errs = errs.Also(serving.ValidateObjectMetadata(ctx, s.GetObjectMeta(), false)) errs = errs.Also(s.validateLabels().ViaField("labels")) errs = errs.Also(serving.ValidateRolloutDurationAnnotation( s.GetAnnotations()).ViaField("annotations")) - errs = errs.Also(serving.ValidateHasNoAutoscalingAnnotation( - s.GetAnnotations()).ViaField("annotations")) errs = errs.ViaField("metadata") ctx = apis.WithinParent(ctx, s.ObjectMeta) diff --git a/vendor/modules.txt b/vendor/modules.txt index 0caa2404d..baaa5d130 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -771,7 +771,7 @@ k8s.io/kube-openapi/pkg/util/sets k8s.io/utils/buffer k8s.io/utils/integer k8s.io/utils/trace -# knative.dev/eventing v0.21.0 +# knative.dev/eventing v0.21.1-0.20210228124848-2db68776f120 ## explicit knative.dev/eventing/pkg/apis/config knative.dev/eventing/pkg/apis/configs @@ -805,12 +805,12 @@ knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake # knative.dev/hack v0.0.0-20210203173706-8368e1f6eacf ## explicit knative.dev/hack -# knative.dev/networking v0.0.0-20210216014426-94bfc013982b +# knative.dev/networking v0.0.0-20210301023148-54c0eb153147 ## explicit knative.dev/networking/pkg knative.dev/networking/pkg/apis/networking knative.dev/networking/pkg/apis/networking/v1alpha1 -# knative.dev/pkg v0.0.0-20210216013737-584933f8280b +# knative.dev/pkg v0.0.0-20210226182947-9039dc189ced ## explicit knative.dev/pkg/apis knative.dev/pkg/apis/duck @@ -854,7 +854,7 @@ knative.dev/pkg/tracing/config knative.dev/pkg/tracing/propagation knative.dev/pkg/tracing/propagation/tracecontextb3 knative.dev/pkg/tracker -# knative.dev/serving v0.21.0 +# knative.dev/serving v0.21.1-0.20210301115148-472f8e2bacf2 ## explicit knative.dev/serving/pkg/apis/autoscaling knative.dev/serving/pkg/apis/autoscaling/v1alpha1