Vendor serving v0.12.0 (#618)

- Vendor serving release v0.12.0
 - Update `kn version command` to print serving v0.12.0
 - Update latest release e2e tests script to setup serving v0.12.0

Co-authored-by: Roland Huß <rhuss@redhat.com>
This commit is contained in:
Navid Shaikh 2020-01-22 14:18:23 +05:30 committed by Knative Prow Robot
parent 5001dcdc16
commit 8c417c1226
57 changed files with 152 additions and 314 deletions

4
go.mod
View File

@ -22,8 +22,8 @@ require (
k8s.io/cli-runtime v0.0.0-20191016113937-7693ce2cae74
k8s.io/client-go v0.0.0-20191016110837-54936ba21026
knative.dev/eventing v0.12.0
knative.dev/pkg v0.0.0-20200113182502-b8dc5fbc6d2f
knative.dev/serving v0.11.0
knative.dev/pkg v0.0.0-20200120180006-96d3b8c24c34
knative.dev/serving v0.12.0
knative.dev/test-infra v0.0.0-20200116044902-d5990f0e5a05
sigs.k8s.io/yaml v1.1.0
)

8
go.sum
View File

@ -523,10 +523,10 @@ k8s.io/utils v0.0.0-20190221042446-c2654d5206da h1:ElyM7RPonbKnQqOcw7dG2IK5uvQQn
k8s.io/utils v0.0.0-20190221042446-c2654d5206da/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0=
knative.dev/eventing v0.12.0 h1:u3Ck5+dpr2affDlsGfRKnBTb87Is/tfzWNfZz1FSAMI=
knative.dev/eventing v0.12.0/go.mod h1:UxweNv8yXhsdHJitcb9R6rmfNaUD2DFi9GWwNRyIs58=
knative.dev/pkg v0.0.0-20200113182502-b8dc5fbc6d2f h1:EFhlUkg97lfwyAxsNZUqbmHxVzQ0YpPdNyf/o16WkAw=
knative.dev/pkg v0.0.0-20200113182502-b8dc5fbc6d2f/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q=
knative.dev/serving v0.11.0 h1:FK8aPpMuiBHZbfBfT+Avxyk11TaIlOMDEw/Va2sw1w0=
knative.dev/serving v0.11.0/go.mod h1:x2n255JS2XBI39tmjZ8CwTxIf9EKNMCrkVuiOttLRm0=
knative.dev/pkg v0.0.0-20200120180006-96d3b8c24c34 h1:rzwD07KAeJ8IfHMV8VWZ0y4txfWHhA07fH2G1mYvKYs=
knative.dev/pkg v0.0.0-20200120180006-96d3b8c24c34/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q=
knative.dev/serving v0.12.0 h1:Jdtc3WwaBNhDY8n5mKwmLqldXra5RKk8FesjIR8k4ts=
knative.dev/serving v0.12.0/go.mod h1:x2n255JS2XBI39tmjZ8CwTxIf9EKNMCrkVuiOttLRm0=
knative.dev/test-infra v0.0.0-20200116044902-d5990f0e5a05 h1:DALgmfmA58b52qfouySXvyHCbc692C3RJUSYNjHNG5U=
knative.dev/test-infra v0.0.0-20200116044902-d5990f0e5a05/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ=
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=

View File

@ -29,7 +29,7 @@ var GitRevision string
// update this var as we add more deps
var apiVersions = map[string][]string{
"serving": {
"serving.knative.dev/v1alpha1 (knative-serving v0.11.0)",
"serving.knative.dev/v1alpha1 (knative-serving v0.12.0)",
},
"eventing": {
"sources.eventing.knative.dev/v1alpha1 (knative-eventing v0.12.0)",

View File

@ -36,7 +36,7 @@ Build Date: {{.BuildDate}}
Git Revision: {{.GitRevision}}
Supported APIs:
* Serving
- serving.knative.dev/v1alpha1 (knative-serving v0.11.0)
- serving.knative.dev/v1alpha1 (knative-serving v0.12.0)
* Eventing
- sources.eventing.knative.dev/v1alpha1 (knative-eventing v0.12.0)
- eventing.knative.dev/v1alpha1 (knative-eventing v0.12.0)

View File

@ -19,7 +19,7 @@
# We currently take 0.10.0 for Serving and 0.10.2 for Eventing as the
# latest release version.
export KNATIVE_SERVING_VERSION="0.11.0"
export KNATIVE_SERVING_VERSION="0.12.0"
export KNATIVE_EVENTING_VERSION="0.11.0"
$(dirname $0)/presubmit-tests.sh --integration-tests

View File

@ -27,6 +27,10 @@ import (
const (
// The following is used to set the default log url template
DefaultLogURLTemplate = "http://localhost:8001/api/v1/namespaces/knative-monitoring/services/kibana-logging/proxy/app/kibana#/discover?_a=(query:(match:(kubernetes.labels.knative-dev%2FrevisionUID:(query:'${REVISION_UID}',type:phrase))))"
// The following is used to set the default metrics backend
DefaultRequestMetricsBackend = "prometheus"
// The env var name for config-observability
ConfigMapNameEnv = "CONFIG_OBSERVABILITY_NAME"
)
@ -84,6 +88,8 @@ func NewObservabilityConfigFromConfigMap(configMap *corev1.ConfigMap) (*Observab
if mb, ok := configMap.Data["metrics.request-metrics-backend-destination"]; ok {
oc.RequestMetricsBackend = mb
} else {
oc.RequestMetricsBackend = DefaultRequestMetricsBackend
}
if prof, ok := configMap.Data["profiling.enable"]; ok {

View File

@ -8,3 +8,4 @@ Pivotal Software, Inc.
IBM Corp
Red Hat, Inc.
Cisco Systems, Inc.
VMware, Inc.

View File

@ -80,7 +80,7 @@ type PodAutoscalerSpec struct {
// This property will be dropped in future Knative releases and should
// not be used - use metadata.generation
//
// Tracking issue: https://knative.dev/serving/issues/643
// Tracking issue: https://github.com/knative/serving/issues/643
//
// +optional
DeprecatedGeneration int64 `json:"generation,omitempty"`

View File

@ -1,7 +1,7 @@
// +build !ignore_autogenerated
/*
Copyright 2019 The Knative Authors
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.

View File

@ -1,7 +1,7 @@
// +build !ignore_autogenerated
/*
Copyright 2019 The Knative Authors
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.

View File

@ -26,7 +26,7 @@ import (
// unlikely to change from version to version.
// ProtocolType is an enumeration of the supported application-layer protocols
// See also: https://knative.dev/serving/blob/master/docs/runtime-contract.md#protocols-and-ports
// See also: https://github.com/knative/serving/blob/master/docs/runtime-contract.md#protocols-and-ports
type ProtocolType string
const (

View File

@ -51,14 +51,9 @@ func (s *IngressSpec) SetDefaults(ctx context.Context) {
// SetDefaults populates default values in IngressTLS
func (t *IngressTLS) SetDefaults(ctx context.Context) {
// Default Secret key for ServerCertificate is `tls.crt`.
if t.ServerCertificate == "" {
t.ServerCertificate = "tls.crt"
}
// Default Secret key for PrivateKey is `tls.key`.
if t.PrivateKey == "" {
t.PrivateKey = "tls.key"
}
// Deprecated, do not use.
t.DeprecatedServerCertificate = ""
t.DeprecatedPrivateKey = ""
}
// SetDefaults populates default values in IngressRule

View File

@ -29,10 +29,6 @@ var ingressCondSet = apis.NewLivingConditionSet(
IngressConditionLoadBalancerReady,
)
// VirtualServiceNotReconciled is used for the reason of MarkLoadBalancerFailed
// when VirtualService is failed to be reconciled.
var VirtualServiceNotReconciled = "ReconcileVirtualServiceFailed"
// GetGroupVersionKind returns SchemeGroupVersion of an Ingress
func (i *Ingress) GetGroupVersionKind() schema.GroupVersionKind {
return SchemeGroupVersion.WithKind("Ingress")
@ -79,7 +75,7 @@ func (is *IngressStatus) MarkLoadBalancerReady(lbs []LoadBalancerIngressStatus,
// reflect that the load balancer is not ready yet.
func (is *IngressStatus) MarkLoadBalancerNotReady() {
ingressCondSet.Manage(is).MarkUnknown(IngressConditionLoadBalancerReady, "Uninitialized",
"Waiting for VirtualService to be ready")
"Waiting for load balancer to be ready")
}
// MarkLoadBalancerFailed marks the "IngressConditionLoadBalancerReady" condition to false.

View File

@ -90,7 +90,7 @@ type IngressSpec struct {
// This property will be dropped in future Knative releases and should
// not be used - use metadata.generation
//
// Tracking issue: https://knative.dev/serving/issues/643
// Tracking issue: https://github.com/knative/serving/issues/643
//
// +optional
DeprecatedGeneration int64 `json:"generation,omitempty"`
@ -143,12 +143,12 @@ type IngressTLS struct {
// ServerCertificate identifies the certificate filename in the secret.
// Defaults to `tls.crt`.
// +optional
ServerCertificate string `json:"serverCertificate,omitempty"`
DeprecatedServerCertificate string `json:"serverCertificate,omitempty"`
// PrivateKey identifies the private key filename in the secret.
// Defaults to `tls.key`.
// +optional
PrivateKey string `json:"privateKey,omitempty"`
DeprecatedPrivateKey string `json:"privateKey,omitempty"`
}
// IngressRule represents the rules mapping the paths under a specified host to

View File

@ -1,7 +1,7 @@
// +build !ignore_autogenerated
/*
Copyright 2019 The Knative Authors
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.

View File

@ -61,7 +61,7 @@ var (
// The port is named "user-port" on the deployment, but a user cannot set an arbitrary name on the port
// in Configuration. The name field is reserved for content-negotiation. Currently 'h2c' and 'http1' are
// allowed.
// https://knative.dev/serving/blob/master/docs/runtime-contract.md#inbound-network-connectivity
// https://github.com/knative/serving/blob/master/docs/runtime-contract.md#inbound-network-connectivity
validPortNames = sets.NewString(
"h2c",
"http1",

View File

@ -30,7 +30,7 @@ import (
// Users create new Revisions by updating the Configuration's spec.
// The "latest created" revision's name is available under status, as is the
// "latest ready" revision's name.
// See also: https://knative.dev/serving/blob/master/docs/spec/overview.md#configuration
// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#configuration
type Configuration struct {
metav1.TypeMeta `json:",inline"`
// +optional

View File

@ -31,7 +31,7 @@ import (
// references a container image. Revisions are created by updates to a
// Configuration.
//
// See also: https://knative.dev/serving/blob/master/docs/spec/overview.md#revision
// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#revision
type Revision struct {
metav1.TypeMeta `json:",inline"`
// +optional

View File

@ -32,7 +32,7 @@ import (
// referencing the Configuration responsible for creating them; in these cases
// the Route is additionally responsible for monitoring the Configuration for
// "latest ready revision" changes, and smoothly rolling out latest revisions.
// See also: https://knative.dev/serving/blob/master/docs/spec/overview.md#route
// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#route
type Route struct {
metav1.TypeMeta `json:",inline"`
// +optional

View File

@ -38,7 +38,7 @@ import (
// The Service's controller will track the statuses of its owned Configuration
// and Route, reflecting their statuses and conditions as its own.
//
// See also: https://knative.dev/serving/blob/master/docs/spec/overview.md#service
// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#service
type Service struct {
metav1.TypeMeta `json:",inline"`
// +optional

View File

@ -1,7 +1,7 @@
// +build !ignore_autogenerated
/*
Copyright 2019 The Knative Authors
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.

View File

@ -32,7 +32,7 @@ import (
// Users create new Revisions by updating the Configuration's spec.
// The "latest created" revision's name is available under status, as is the
// "latest ready" revision's name.
// See also: https://knative.dev/serving/blob/master/docs/spec/overview.md#configuration
// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#configuration
type Configuration struct {
metav1.TypeMeta `json:",inline"`
// +optional
@ -68,7 +68,7 @@ type ConfigurationSpec struct {
// This property will be dropped in future Knative releases and should
// not be used - use metadata.generation
//
// Tracking issue: https://knative.dev/serving/issues/643
// Tracking issue: https://github.com/knative/serving/issues/643
//
// +optional
DeprecatedGeneration int64 `json:"generation,omitempty"`

View File

@ -53,10 +53,6 @@ const (
// UserQueueMetricsPortName specifies the port name to use for metrics
// emitted by queue-proxy for end user.
UserQueueMetricsPortName = "http-usermetric"
// ServiceQueueMetricsPortName is the name of the port that serves metrics
// on the Kubernetes service.
ServiceQueueMetricsPortName = "http-metrics"
)
var revCondSet = apis.NewLivingConditionSet(

View File

@ -34,7 +34,7 @@ import (
// materializing that container image from source. Revisions are created by
// updates to a Configuration.
//
// See also: https://knative.dev/serving/blob/master/docs/spec/overview.md#revision
// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#revision
type Revision struct {
metav1.TypeMeta `json:",inline"`
// +optional
@ -72,7 +72,7 @@ type RevisionTemplateSpec struct {
}
// DeprecatedRevisionServingStateType is an enumeration of the levels of serving readiness of the Revision.
// See also: https://knative.dev/serving/blob/master/docs/spec/errors.md#error-conditions-and-reporting
// See also: https://github.com/knative/serving/blob/master/docs/spec/errors.md#error-conditions-and-reporting
type DeprecatedRevisionServingStateType string
const (
@ -87,7 +87,7 @@ const (
// anymore. It should not have any Istio routes or Kubernetes resources.
// A Revision may be brought out of retirement, but it may take longer than
// it would from a "Reserve" state.
// Note: currently not set anywhere. See https://knative.dev/serving/issues/1203
// Note: currently not set anywhere. See https://github.com/knative/serving/issues/1203
DeprecatedRevisionServingStateRetired DeprecatedRevisionServingStateType = "Retired"
)
@ -118,7 +118,7 @@ type RevisionSpec struct {
// This property will be dropped in future Knative releases and should
// not be used - use metadata.generation
//
// Tracking issue: https://knative.dev/serving/issues/643
// Tracking issue: https://github.com/knative/serving/issues/643
//
// +optional
DeprecatedGeneration int64 `json:"generation,omitempty"`
@ -153,7 +153,7 @@ type RevisionSpec struct {
// this Container, including: name and lifecycle.
// See also the runtime contract for more information about the execution
// environment:
// https://knative.dev/serving/blob/master/docs/runtime-contract.md
// https://github.com/knative/serving/blob/master/docs/runtime-contract.md
// +optional
DeprecatedContainer *corev1.Container `json:"container,omitempty"`
}

View File

@ -35,7 +35,7 @@ import (
// referencing the Configuration responsible for creating them; in these cases
// the Route is additionally responsible for monitoring the Configuration for
// "latest ready" revision changes, and smoothly rolling out latest revisions.
// See also: https://knative.dev/serving/blob/master/docs/spec/overview.md#route
// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#route
type Route struct {
metav1.TypeMeta `json:",inline"`
// +optional
@ -83,7 +83,7 @@ type RouteSpec struct {
// This property will be dropped in future Knative releases and should
// not be used - use metadata.generation
//
// Tracking issue: https://knative.dev/serving/issues/643
// Tracking issue: https://github.com/knative/serving/issues/643
//
// +optional
DeprecatedGeneration int64 `json:"generation,omitempty"`

View File

@ -38,7 +38,7 @@ import (
// The Service's controller will track the statuses of its owned Configuration
// and Route, reflecting their statuses and conditions as its own.
//
// See also: https://knative.dev/serving/blob/master/docs/spec/overview.md#service
// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#service
type Service struct {
metav1.TypeMeta `json:",inline"`
// +optional
@ -73,7 +73,7 @@ type ServiceSpec struct {
// This property will be dropped in future Knative releases and should
// not be used - use metadata.generation
//
// Tracking issue: https://knative.dev/serving/issues/643
// Tracking issue: https://github.com/knative/serving/issues/643
//
// +optional
DeprecatedGeneration int64 `json:"generation,omitempty"`

View File

@ -1,7 +1,7 @@
// +build !ignore_autogenerated
/*
Copyright 2019 The Knative Authors
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.

View File

@ -30,7 +30,7 @@ import (
// Users create new Revisions by updating the Configuration's spec.
// The "latest created" revision's name is available under status, as is the
// "latest ready" revision's name.
// See also: https://knative.dev/serving/blob/master/docs/spec/overview.md#configuration
// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#configuration
type Configuration struct {
metav1.TypeMeta `json:",inline"`
// +optional

View File

@ -30,7 +30,7 @@ import (
// references a container image. Revisions are created by updates to a
// Configuration.
//
// See also: https://knative.dev/serving/blob/master/docs/spec/overview.md#revision
// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#revision
type Revision struct {
metav1.TypeMeta `json:",inline"`
// +optional

View File

@ -32,7 +32,7 @@ import (
// referencing the Configuration responsible for creating them; in these cases
// the Route is additionally responsible for monitoring the Configuration for
// "latest ready revision" changes, and smoothly rolling out latest revisions.
// See also: https://knative.dev/serving/blob/master/docs/spec/overview.md#route
// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#route
type Route struct {
metav1.TypeMeta `json:",inline"`
// +optional

View File

@ -38,7 +38,7 @@ import (
// The Service's controller will track the statuses of its owned Configuration
// and Route, reflecting their statuses and conditions as its own.
//
// See also: https://knative.dev/serving/blob/master/docs/spec/overview.md#service
// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#service
type Service struct {
metav1.TypeMeta `json:",inline"`
// +optional

View File

@ -1,7 +1,7 @@
// +build !ignore_autogenerated
/*
Copyright 2019 The Knative Authors
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.

View File

@ -1,5 +1,5 @@
/*
Copyright 2019 The Knative Authors
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.

View File

@ -1,5 +1,5 @@
/*
Copyright 2019 The Knative Authors
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.

View File

@ -1,5 +1,5 @@
/*
Copyright 2019 The Knative Authors
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.

View File

@ -1,5 +1,5 @@
/*
Copyright 2019 The Knative Authors
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.

View File

@ -1,5 +1,5 @@
/*
Copyright 2019 The Knative Authors
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.

View File

@ -1,5 +1,5 @@
/*
Copyright 2019 The Knative Authors
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.

View File

@ -1,5 +1,5 @@
/*
Copyright 2019 The Knative Authors
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.

View File

@ -1,5 +1,5 @@
/*
Copyright 2019 The Knative Authors
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.

View File

@ -1,5 +1,5 @@
/*
Copyright 2019 The Knative Authors
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.

View File

@ -1,5 +1,5 @@
/*
Copyright 2019 The Knative Authors
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.

View File

@ -1,5 +1,5 @@
/*
Copyright 2019 The Knative Authors
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.

View File

@ -1,5 +1,5 @@
/*
Copyright 2019 The Knative Authors
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.

View File

@ -1,5 +1,5 @@
/*
Copyright 2019 The Knative Authors
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.

View File

@ -1,5 +1,5 @@
/*
Copyright 2019 The Knative Authors
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.

View File

@ -1,5 +1,5 @@
/*
Copyright 2019 The Knative Authors
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.

View File

@ -18,7 +18,7 @@ package gc
import (
"context"
"errors"
"fmt"
"strconv"
"time"
@ -56,7 +56,7 @@ func NewConfigFromConfigMapFunc(ctx context.Context) func(configMap *corev1.Conf
}{{
key: "stale-revision-create-delay",
field: &c.StaleRevisionCreateDelay,
defaultValue: 24 * time.Hour,
defaultValue: 48 * time.Hour,
}, {
key: "stale-revision-timeout",
field: &c.StaleRevisionTimeout,
@ -76,17 +76,17 @@ func NewConfigFromConfigMapFunc(ctx context.Context) func(configMap *corev1.Conf
}
if raw, ok := configMap.Data["stale-revision-minimum-generations"]; !ok {
c.StaleRevisionMinimumGenerations = 1
} else if val, err := strconv.ParseInt(raw, 10, 64); err != nil {
c.StaleRevisionMinimumGenerations = 20
} else if val, err := strconv.ParseInt(raw, 10 /*base*/, 64 /*bit count*/); err != nil {
return nil, err
} else if val < 0 {
return nil, errors.New("stale-revision-minimum-generations must be zero or greater")
return nil, fmt.Errorf("stale-revision-minimum-generations must be non-negative, was: %d", val)
} else {
c.StaleRevisionMinimumGenerations = val
}
if c.StaleRevisionTimeout-c.StaleRevisionLastpinnedDebounce < minRevisionTimeout {
logger.Errorf("Got revision timeout of %v, minimum supported value is %v", c.StaleRevisionTimeout, minRevisionTimeout+c.StaleRevisionLastpinnedDebounce)
logger.Warnf("Got revision timeout of %v, minimum supported value is %v", c.StaleRevisionTimeout, minRevisionTimeout+c.StaleRevisionLastpinnedDebounce)
c.StaleRevisionTimeout = minRevisionTimeout + c.StaleRevisionLastpinnedDebounce
return &c, nil
}

View File

@ -1,7 +1,7 @@
// +build !ignore_autogenerated
/*
Copyright 2019 The Knative Authors
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.

View File

@ -0,0 +1,55 @@
/*
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
https://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 network
import (
"net/http/httputil"
"sync"
)
// bufferPool implements the BufferPool interface to be used in
// httputil.ReverseProxy. It stores pointers to to slices to
// further avoid allocations, see https://staticcheck.io/docs/checks#SA6002.
type bufferPool struct {
pool *sync.Pool
}
// NewBufferPool creates a new BytePool. This is only safe to use in the context
// of a httputil.ReverseProxy, as the buffers returned via Put are not cleaned
// explicitly.
func NewBufferPool() httputil.BufferPool {
return &bufferPool{
pool: &sync.Pool{},
}
}
// Get gets a []byte from the bufferPool, or creates a new one if none are
// available in the pool.
func (b *bufferPool) Get() []byte {
buf := b.pool.Get()
if buf == nil {
// Use the default buffer size as defined in the ReverseProxy itself.
return make([]byte, 32*1024)
}
return *buf.(*[]byte)
}
// Put returns the given Buffer to the bufferPool.
func (b *bufferPool) Put(buffer []byte) {
b.pool.Put(&buffer)
}

View File

@ -1,43 +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 network
import (
"io/ioutil"
"net/http"
"go.uber.org/zap"
)
// ErrorHandler sets up a handler suitable for use with the ErrorHandler field on
// httputil's reverse proxy.
func ErrorHandler(logger *zap.SugaredLogger) func(http.ResponseWriter, *http.Request, error) {
return func(w http.ResponseWriter, req *http.Request, err error) {
ss := readSockStat(logger)
logger.Errorw("error reverse proxying request; sockstat: "+ss, zap.Error(err))
http.Error(w, err.Error(), http.StatusBadGateway)
}
}
func readSockStat(logger *zap.SugaredLogger) string {
b, err := ioutil.ReadFile("/proc/net/sockstat")
if err != nil {
logger.Errorw("Unable to read sockstat", zap.Error(err))
return ""
}
return string(b)
}

View File

@ -1,54 +0,0 @@
/*
Copyright 2018 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 network
import (
"crypto/tls"
"net"
"net/http"
"time"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
)
// NewServer returns a new HTTP Server with HTTP2 handler.
func NewServer(addr string, h http.Handler) *http.Server {
h1s := &http.Server{
Addr: addr,
Handler: h2c.NewHandler(h, &http2.Server{}),
}
return h1s
}
// NewH2CTransport constructs a new H2C transport.
// That transport will reroute all HTTPS traffic to HTTP. This is
// to explicitly allow h2c (http2 without TLS) transport.
// See https://github.com/golang/go/issues/14141 for more details.
func NewH2CTransport() http.RoundTripper {
return &http2.Transport{
AllowHTTP: true,
DialTLS: func(netw, addr string, cfg *tls.Config) (net.Conn, error) {
d := &net.Dialer{
Timeout: DefaultConnTimeout,
KeepAlive: 5 * time.Second,
DualStack: true,
}
return d.Dial(netw, addr)
},
}
}

View File

@ -26,7 +26,6 @@ import (
"net/url"
"strings"
"text/template"
"time"
corev1 "k8s.io/api/core/v1"
)
@ -97,19 +96,6 @@ const (
// user-agent. So we augment the probes with this header.
KubeletProbeHeaderName = "K-Kubelet-Probe"
// DefaultConnTimeout specifies a short default connection timeout
// to avoid hitting the issue fixed in
// https://github.com/kubernetes/kubernetes/pull/72534 but only
// avalailable after Kubernetes 1.14.
//
// Our connections are usually between pods in the same cluster
// like activator <-> queue-proxy, or even between containers
// within the same pod queue-proxy <-> user-container, so a
// smaller connect timeout would be justifiable.
//
// We should consider exposing this as a configuration.
DefaultConnTimeout = 200 * time.Millisecond
// DefaultDomainTemplate is the default golang template to use when
// constructing the Knative Route's Domain(host)
DefaultDomainTemplate = "{{.Name}}.{{.Namespace}}.{{.Domain}}"
@ -398,3 +384,23 @@ func RewriteHostOut(r *http.Request) {
r.Header.Del(OriginalHostHeader)
}
}
// NameForPortNumber finds the name for a given port as defined by a Service.
func NameForPortNumber(svc *corev1.Service, portNumber int32) (string, error) {
for _, port := range svc.Spec.Ports {
if port.Port == portNumber {
return port.Name, nil
}
}
return "", fmt.Errorf("no port with number %d found", portNumber)
}
// PortNumberForName resolves a given name to a portNumber as defined by an EndpointSubset.
func PortNumberForName(sub corev1.EndpointSubset, portName string) (int32, error) {
for _, subPort := range sub.Ports {
if subPort.Name == portName {
return subPort.Port, nil
}
}
return 0, fmt.Errorf("no port for name %q found", portName)
}

View File

@ -1,120 +0,0 @@
/*
Copyright 2018 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 network
import (
"context"
"errors"
"net"
"net/http"
"time"
"k8s.io/apimachinery/pkg/util/wait"
)
// RoundTripperFunc implementation roundtrips a request.
type RoundTripperFunc func(*http.Request) (*http.Response, error)
// RoundTrip implements http.RoundTripper.
func (rt RoundTripperFunc) RoundTrip(r *http.Request) (*http.Response, error) {
return rt(r)
}
func newAutoTransport(v1 http.RoundTripper, v2 http.RoundTripper) http.RoundTripper {
return RoundTripperFunc(func(r *http.Request) (*http.Response, error) {
t := v1
if r.ProtoMajor == 2 {
t = v2
}
return t.RoundTrip(r)
})
}
const sleepTO = 30 * time.Millisecond
var backOffTemplate = wait.Backoff{
Duration: 50 * time.Millisecond,
Factor: 1.4,
Jitter: 0.1, // At most 10% jitter.
Steps: 15,
}
var errDialTimeout = errors.New("timed out dialing")
// dialWithBackOff executes `net.Dialer.DialContext()` with exponentially increasing
// dial timeouts. In addition it sleeps with random jitter between tries.
func dialWithBackOff(ctx context.Context, network, address string) (net.Conn, error) {
return dialBackOffHelper(ctx, network, address, backOffTemplate, sleepTO)
}
func dialBackOffHelper(ctx context.Context, network, address string, bo wait.Backoff, sleep time.Duration) (net.Conn, error) {
dialer := &net.Dialer{
Timeout: bo.Duration, // Initial duration.
KeepAlive: 5 * time.Second,
DualStack: true,
}
for {
c, err := dialer.DialContext(ctx, network, address)
if err != nil {
if err, ok := err.(net.Error); ok && err.Timeout() {
if bo.Steps < 1 {
break
}
dialer.Timeout = bo.Step()
time.Sleep(wait.Jitter(sleep, 1.0)) // Sleep with jitter.
continue
}
return nil, err
}
return c, nil
}
return nil, errDialTimeout
}
func newHTTPTransport(connTimeout time.Duration, disableKeepAlives bool) http.RoundTripper {
return &http.Transport{
// Those match net/http/transport.go
Proxy: http.ProxyFromEnvironment,
MaxIdleConns: 1000,
MaxIdleConnsPerHost: 100,
IdleConnTimeout: 5 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
DisableKeepAlives: disableKeepAlives,
// This is bespoke.
DialContext: dialWithBackOff,
}
}
// NewProberTransport creates a RoundTripper that is useful for probing,
// since it will not cache connections.
func NewProberTransport() http.RoundTripper {
return newAutoTransport(
newHTTPTransport(DefaultConnTimeout, true /*disable keep-alives*/),
NewH2CTransport())
}
// NewAutoTransport creates a RoundTripper that can use appropriate transport
// based on the request's HTTP version.
func NewAutoTransport() http.RoundTripper {
return newAutoTransport(
newHTTPTransport(DefaultConnTimeout, false /*disable keep-alives*/),
NewH2CTransport())
}
// AutoTransport uses h2c for HTTP2 requests and falls back to `http.DefaultTransport` for all others
var AutoTransport = NewAutoTransport()

View File

@ -1,7 +1,7 @@
// +build !ignore_autogenerated
/*
Copyright 2019 The Knative Authors
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.

View File

@ -1,7 +1,7 @@
// +build !ignore_autogenerated
/*
Copyright 2019 The Knative Authors
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.

4
vendor/modules.txt vendored
View File

@ -649,7 +649,7 @@ knative.dev/eventing/pkg/legacyclient/clientset/versioned/scheme
knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1
knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/fake
knative.dev/eventing/pkg/logging
# knative.dev/pkg v0.0.0-20200113182502-b8dc5fbc6d2f
# knative.dev/pkg v0.0.0-20200120180006-96d3b8c24c34
knative.dev/pkg/apis
knative.dev/pkg/apis/duck
knative.dev/pkg/apis/duck/v1
@ -668,7 +668,7 @@ knative.dev/pkg/network
knative.dev/pkg/profiling
knative.dev/pkg/ptr
knative.dev/pkg/tracker
# knative.dev/serving v0.11.0
# knative.dev/serving v0.12.0
knative.dev/serving/pkg/apis/autoscaling
knative.dev/serving/pkg/apis/autoscaling/v1alpha1
knative.dev/serving/pkg/apis/config