upgrade to latest dependencies (#1188)

bumping knative.dev/eventing a414aee...1c94ef8:
  > 1c94ef8 Add event reply header to spec (# 4560)
  > 056bc25 Add Open Telemetry Spec attributes to IMC Dispatcher span (# 4659)
  > 6d76c44 try using hack wait for pods (# 4741)
  > d74dc25 Format markdown (# 4740)
  > 1897543 [# 4717] Update e2e broker defaults webhook test (# 4720)
  > c5b9eeb Unify usage of YAML libraries (# 4667)
  > 2e96fd0 Now the config-imc-event-dispatcher values are injected to the dispatcher through envs (# 4543)
  > 05a3a27 note that these only pertain to this repo (# 4733)
  > 21d91e4 Format markdown (# 4734)
  > 47d9937 Update spec.md with v1 API (# 4594)
  > 343dec3 Use the v1 api package... (# 4727)
  > ff5109d re-submit # 4707 (# 4730)
  > b1882d6 [# 4721] Update e2e broker default webhook test (# 4722)
  > 7d12333 Disabling servicelinks in all the components (# 4714)
bumping knative.dev/networking ecb89ce...07a8160:
  > 07a8160 upgrade to latest dependencies (# 331)
  > 4c4c237 Add config to disable auto-creation of domain claims (# 330)
  > 3a89509 As per discussion with @mattmoor keep drainer in pkg (# 329)
  > c30dc94 Use symlink for testdata version of config-network.yaml (# 328)
bumping knative.dev/hack 4ed1ecb...4422dca:
  > 4422dca Set GOBIN in codegen-library.sh (# 44)
  > d946d25 Revert "Add hermetic go mod aware handling to run_go_tool (# 38)" (# 39)
  > ea9c9a0 Add hermetic go mod aware handling to run_go_tool (# 38)
bumping knative.dev/serving 560a4f6...84421cd:
  > 84421cd Shutdown processor to avoid log races (# 10544)
  > e402e8e Remove the old constant since the new one has been since August 2020 (# 10559)
  > 89cbb09 Nits in the code formatting (# 10558)
  > c06ee54 Move the functions that have only single use to the private package (# 10541)
  > cf06222 Remove activator/util package (# 10557)
  > 95c699b Update net-certmanager nightly (# 10551)
  > bcbaa8e Update net-contour nightly (# 10553)
  > c865fa5 Un-export WithRevID, RevIDFrom, WithRevision, RevisionFrom (# 10549)
  > 824e336 Cut down queue-probe test time from 3s to .5s (# 10548)
  > 725cbe9 Fix wrong file permission (# 10543)
  > e07174d Use explicit revID parameter in Throttler (# 10545)
  > 454fd7c Allow disabling of automatic DomainClaim creation (# 10537)
  > 1f95e13 Remove comment about recreation of the autoscaler pod in config-logging (# 10542)
  > 0f2d350 swap dates with tcnghia (# 10529)
  > 156f8a4 upgrade to latest dependencies (# 10538)
  > c886a22 Simplify and optimise proxy header pruning (# 10535)
  > 7602d81 Remove backwards compatibility check in KPA (# 10534)
  > d28e461 Sanitize probe header value written by user before response (# 10533)
  > e2c6836 Ensure step size is validated and add tests (# 10532)
  > ca1ac91 Update net-istio nightly (# 10524)
  > 3ec271c Improve performance a bit by using binary search (# 10531)
  > 8f213d9 Report first and second revision metrics separately and deleted old rev. (# 10518)
  > 457be78 Update net-contour nightly (# 10523)
  > a295b6d Update net-certmanager nightly (# 10522)
bumping knative.dev/pkg 51c72e2...f0ea5e6:
  > f0ea5e6 Use special error type to designate skips. (# 1988)
  > acbf2af Harden logstream against non-object events (# 1984)
  > 93874f0 Drainer supports customized kubelet probe check (# 1977)

Signed-off-by: Knative Automation <automation@knative.team>
This commit is contained in:
knative-automation 2021-01-14 22:55:20 -08:00 committed by GitHub
parent 8ca5db3a37
commit 2cb77f6c56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 184 additions and 125 deletions

10
go.mod
View File

@ -22,11 +22,11 @@ require (
k8s.io/cli-runtime v0.18.12
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
k8s.io/code-generator v0.18.12
knative.dev/eventing v0.20.0
knative.dev/hack v0.0.0-20201214230143-4ed1ecb8db24
knative.dev/networking v0.0.0-20210107024535-ecb89ced52d9
knative.dev/pkg v0.0.0-20210107022335-51c72e24c179
knative.dev/serving v0.20.0
knative.dev/eventing v0.20.1-0.20210115015220-1c94ef83b6b5
knative.dev/hack v0.0.0-20210114150620-4422dcadb3c8
knative.dev/networking v0.0.0-20210113172032-07a8160d1971
knative.dev/pkg v0.0.0-20210114223020-f0ea5e6b9c4e
knative.dev/serving v0.20.1-0.20210115004319-84421cde1553
sigs.k8s.io/yaml v1.2.0
)

21
go.sum
View File

@ -1256,18 +1256,25 @@ k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451 h1:v8ud2Up6QK1lNOKFgiIVrZdMg7MpmSnvtrOieolJKoE=
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
knative.dev/caching v0.0.0-20210107021736-1ee47505018d/go.mod h1:N3jOlbf/CWZsEcfEpthv5b+LB9e+TqiDTVLH/Ti+vWE=
knative.dev/eventing v0.20.0 h1:CtW8JYds0gvaiCWvoeX6zHbm8Jbfwu3hieyCTNudNnk=
knative.dev/eventing v0.20.0/go.mod h1:7KjOHRQTPqsH0y1NbQLnboZeWJWVTztQVd/0lFCmz7A=
knative.dev/eventing v0.20.1-0.20210115015220-1c94ef83b6b5 h1:Gb18mayz8CukHpC6SFXUVDbd2YVdgrkUbJ50zdNX140=
knative.dev/eventing v0.20.1-0.20210115015220-1c94ef83b6b5/go.mod h1:HdS7UgtDbKQuCuEwgS3+jxtHvpm+PPp/eEsjaQwfWl8=
knative.dev/hack v0.0.0-20201214230143-4ed1ecb8db24 h1:kIztWfvnIFV8Lhlea02K3YO2mIzcDyQNzrBLn0Oq9sA=
knative.dev/hack v0.0.0-20201214230143-4ed1ecb8db24/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
knative.dev/networking v0.0.0-20210107024535-ecb89ced52d9 h1:7SXik2ulHr7URICeDYHPVdnyuT72RW9GouJ97XRkWbo=
knative.dev/networking v0.0.0-20210107024535-ecb89ced52d9/go.mod h1:N123KICErXy+bPo1oBszM6TVYGG0Za2wMmnEqX4MlFg=
knative.dev/hack v0.0.0-20210112093330-d946d2557383/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
knative.dev/hack v0.0.0-20210114150620-4422dcadb3c8 h1:N/Kt6C5zZzTtFcTntRThB+vEJ7WcLKaZ5Q2Jm7b23vw=
knative.dev/hack v0.0.0-20210114150620-4422dcadb3c8/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
knative.dev/networking v0.0.0-20210112144630-4c4c2378e90e/go.mod h1:N123KICErXy+bPo1oBszM6TVYGG0Za2wMmnEqX4MlFg=
knative.dev/networking v0.0.0-20210113172032-07a8160d1971 h1:Iig2pviCKuZYoIH+wgeUoJz1U4gQ18LXX7JpwRO5AYo=
knative.dev/networking v0.0.0-20210113172032-07a8160d1971/go.mod h1:lAll0+JcN2iKex0P9hOXZ4siOdryW+HIuK4KBRM+ca4=
knative.dev/pkg v0.0.0-20201224024804-27db5ac24cfb/go.mod h1:hckgW978SdzPA2H5EDvRPY8xsnPuDZLJLbPf8Jte7Q0=
knative.dev/pkg v0.0.0-20210107022335-51c72e24c179 h1:lkrgrv69iUk2qhOG9symy15kJUaJZmMybSloi7C3gIw=
knative.dev/pkg v0.0.0-20210107022335-51c72e24c179/go.mod h1:hckgW978SdzPA2H5EDvRPY8xsnPuDZLJLbPf8Jte7Q0=
knative.dev/reconciler-test v0.0.0-20210108100436-db4d65735605/go.mod h1:rmQpZseeqDpg6/ToFzIeV5hTRkOJujaXBCK7iYL7M4E=
knative.dev/serving v0.20.0 h1:bxnmLCrwXDESqM4J1d8uKdl1XUQOq1DnHEVl6Ottnwo=
knative.dev/serving v0.20.0/go.mod h1:357cOGGPTY1aNqbDeyr35/LvYn1yc0WCe0EQLTNN8Mc=
knative.dev/pkg v0.0.0-20210112143930-acbf2af596cf/go.mod h1:hckgW978SdzPA2H5EDvRPY8xsnPuDZLJLbPf8Jte7Q0=
knative.dev/pkg v0.0.0-20210114223020-f0ea5e6b9c4e h1:3k5tzvlM9VGZFiXRj8UKc3CUpMGpqBlEbIY0Dp3F3NU=
knative.dev/pkg v0.0.0-20210114223020-f0ea5e6b9c4e/go.mod h1:hckgW978SdzPA2H5EDvRPY8xsnPuDZLJLbPf8Jte7Q0=
knative.dev/reconciler-test v0.0.0-20210111135237-9b251467ccb6/go.mod h1:rmQpZseeqDpg6/ToFzIeV5hTRkOJujaXBCK7iYL7M4E=
knative.dev/serving v0.20.1-0.20210115004319-84421cde1553 h1:YkSm62v8bmAdeXgHNxLVMsjEcWrokQ3OuPCKmjONUxQ=
knative.dev/serving v0.20.1-0.20210115004319-84421cde1553/go.mod h1:m24eWeQ394GFbz3WnacOiQXFx/mSTBSgpQf+9/c4YMs=
pgregory.net/rapid v0.3.3/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=

View File

@ -23,7 +23,7 @@ import (
eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1"
"github.com/ghodss/yaml"
"sigs.k8s.io/yaml"
corev1 "k8s.io/api/core/v1"

View File

@ -26,6 +26,7 @@ else
fi
export GOPATH=$(go_mod_gopath_hack)
export GOBIN=${GOPATH}/bin # Set GOBIN explicitly as deepcopy-gen is installed by go install.
export MODULE_NAME=$(go_mod_module_name)
export CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)}
export KNATIVE_CODEGEN_PKG=${KNATIVE_CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 ./vendor/knative.dev/pkg 2>/dev/null || echo ../pkg)}

View File

@ -116,6 +116,10 @@ const (
// constructing the Knative Route's tag names.
DefaultTagTemplate = "{{.Tag}}-{{.Name}}"
// AutocreateClusterDomainClaimsKey is the key for the
// AutocreateClusterDomainClaims property.
AutocreateClusterDomainClaimsKey = "autocreateClusterDomainClaims"
// AutoTLSKey is the name of the configuration entry
// that specifies enabling auto-TLS or not.
AutoTLSKey = "autoTLS"
@ -235,6 +239,13 @@ type Config struct {
// RolloutDurationSecs specifies the default duration for the rollout.
RolloutDurationSecs int
// AutocreateClusterDomainClaims specifies whether cluster-wide DomainClaims
// should be automatically created (and deleted) as needed when a
// DomainMapping is reconciled. If this is false, the
// cluster administrator is responsible for pre-creating ClusterDomainClaims
// and delegating them to namespaces via their spec.Namespace field.
AutocreateClusterDomainClaims bool
}
// HTTPProtocol indicates a type of HTTP endpoint behavior
@ -260,6 +271,7 @@ func defaultConfig() *Config {
TagTemplate: DefaultTagTemplate,
AutoTLS: false,
HTTPProtocol: HTTPEnabled,
AutocreateClusterDomainClaims: true,
}
}
@ -280,6 +292,7 @@ func NewConfigFromMap(data map[string]string) (*Config, error) {
cm.AsString(DomainTemplateKey, &nc.DomainTemplate),
cm.AsString(TagTemplateKey, &nc.TagTemplate),
cm.AsInt(RolloutDurationKey, &nc.RolloutDurationSecs),
cm.AsBool(AutocreateClusterDomainClaimsKey, &nc.AutocreateClusterDomainClaims),
); err != nil {
return nil, err
}

View File

@ -89,6 +89,10 @@ func (g *reconcilerReconcilerGenerator) GenerateType(c *generator.Context, t *ty
Package: "knative.dev/pkg/controller",
Name: "WithEventRecorder",
}),
"controllerNewSkipKey": c.Universe.Type(types.Name{
Package: "knative.dev/pkg/controller",
Name: "NewSkipKey",
}),
"corev1EventSource": c.Universe.Function(types.Name{
Package: "k8s.io/api/core/v1",
Name: "EventSource",
@ -375,7 +379,7 @@ func (r *reconcilerImpl) Reconcile(ctx {{.contextContext|raw}}, key string) erro
// If we are not the leader, and we don't implement either ReadOnly
// observer interfaces, then take a fast-path out.
if s.isNotLeaderNorObserver() {
return nil
return {{.controllerNewSkipKey|raw}}(key)
}
// If configStore is set, attach the frozen configuration to the context.

View File

@ -521,21 +521,24 @@ func (c *Impl) processNextWorkItem() bool {
// Run Reconcile, passing it the namespace/name string of the
// resource to be synced.
if err = c.Reconciler.Reconcile(ctx, keyStr); err != nil {
c.handleErr(err, key)
logger.Info("Reconcile failed. Time taken: ", time.Since(startTime))
c.handleErr(err, key, startTime)
return true
}
// Finally, if no error occurs we Forget this item so it does not
// have any delay when another change happens.
c.workQueue.Forget(key)
logger.Info("Reconcile succeeded. Time taken: ", time.Since(startTime))
logger.Info("Reconcile succeeded. Time taken: ", zap.Duration("duration", time.Since(startTime)))
return true
}
func (c *Impl) handleErr(err error, key types.NamespacedName) {
c.logger.Errorw("Reconcile error", zap.Error(err))
func (c *Impl) handleErr(err error, key types.NamespacedName, startTime time.Time) {
if IsSkipKey(err) {
c.workQueue.Forget(key)
return
}
c.logger.Errorw("Reconcile error", zap.Duration("duration", time.Since(startTime)), zap.Error(err))
// Re-queue the key if it's a transient error.
// We want to check that the queue is shutting down here
@ -570,6 +573,38 @@ func (c *Impl) FilteredGlobalResync(f func(interface{}) bool, si cache.SharedInf
}
}
// NewSkipKey returns a new instance of skipKeyError.
// Users can return this type of error to indicate that the key was skipped.
func NewSkipKey(key string) error {
return skipKeyError{key: key}
}
// permanentError is an error that is considered not transient.
// We should not re-queue keys when it returns with thus error in reconcile.
type skipKeyError struct {
key string
}
var _ error = skipKeyError{}
// Error implements the Error() interface of error.
func (err skipKeyError) Error() string {
return fmt.Sprintf("skipped key: %q", err.key)
}
// IsSkipKey returns true if the given error is a skipKeyError.
func IsSkipKey(err error) bool {
return errors.Is(err, skipKeyError{})
}
// Is implements the Is() interface of error. It returns whether the target
// error can be treated as equivalent to a permanentError.
func (skipKeyError) Is(target error) bool {
//nolint: errorlint // This check is actually fine.
_, ok := target.(skipKeyError)
return ok
}
// NewPermanentError returns a new instance of permanentError.
// Users can wrap an error as permanentError with this in reconcile
// when they do not expect the key to get re-queued.

View File

@ -18,12 +18,9 @@ package serving
import (
"context"
"fmt"
"strconv"
"strings"
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/validation"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
@ -75,38 +72,6 @@ func ValidateHasNoAutoscalingAnnotation(annotations map[string]string) (errs *ap
return errs
}
// ValidateQueueSidecarAnnotation validates QueueSideCarResourcePercentageAnnotation
func ValidateQueueSidecarAnnotation(annotations map[string]string) *apis.FieldError {
if len(annotations) == 0 {
return nil
}
v, ok := annotations[QueueSideCarResourcePercentageAnnotation]
if !ok {
return nil
}
value, err := strconv.ParseFloat(v, 64)
if err != nil {
return apis.ErrInvalidValue(v, apis.CurrentField).ViaKey(QueueSideCarResourcePercentageAnnotation)
}
if value < 0.1 || value > 100 {
return apis.ErrOutOfBoundsValue(value, 0.1, 100.0, apis.CurrentField).ViaKey(QueueSideCarResourcePercentageAnnotation)
}
return nil
}
// ValidateTimeoutSeconds validates timeout by comparing MaxRevisionTimeoutSeconds
func ValidateTimeoutSeconds(ctx context.Context, timeoutSeconds int64) *apis.FieldError {
if timeoutSeconds != 0 {
cfg := config.FromContextOrDefaults(ctx)
if timeoutSeconds > cfg.Defaults.MaxRevisionTimeoutSeconds || timeoutSeconds < 0 {
return apis.ErrOutOfBoundsValue(timeoutSeconds, 0,
cfg.Defaults.MaxRevisionTimeoutSeconds,
"timeoutSeconds")
}
}
return nil
}
// ValidateContainerConcurrency function validates the ContainerConcurrency field
// TODO(#5007): Move this to autoscaling.
func ValidateContainerConcurrency(ctx context.Context, containerConcurrency *int64) *apis.FieldError {
@ -126,12 +91,12 @@ func ValidateContainerConcurrency(ctx context.Context, containerConcurrency *int
return nil
}
// ValidateClusterVisibilityLabel function validates the visibility label on a Route
func ValidateClusterVisibilityLabel(label, key string) (errs *apis.FieldError) {
// validateClusterVisibilityLabel function validates the visibility label on a Route
func validateClusterVisibilityLabel(label, key string) (errs *apis.FieldError) {
if label != VisibilityClusterLocal {
errs = apis.ErrInvalidValue(label, key)
}
return
return errs
}
// SetUserInfo sets creator and updater annotations
@ -158,38 +123,3 @@ func SetUserInfo(ctx context.Context, oldSpec, newSpec, resource interface{}) {
}
}
}
// ValidateRevisionName validates name and generateName for the revisionTemplate
func ValidateRevisionName(ctx context.Context, name, generateName string) *apis.FieldError {
if generateName != "" {
if msgs := validation.NameIsDNS1035Label(generateName, true); len(msgs) > 0 {
return apis.ErrInvalidValue(
fmt.Sprint("not a DNS 1035 label prefix: ", msgs),
"metadata.generateName")
}
}
if name != "" {
if msgs := validation.NameIsDNS1035Label(name, false); len(msgs) > 0 {
return apis.ErrInvalidValue(
fmt.Sprint("not a DNS 1035 label: ", msgs),
"metadata.name")
}
om := apis.ParentMeta(ctx)
prefix := om.Name + "-"
if om.Name != "" {
// Even if there is GenerateName, allow the use
// of Name post-creation.
} else if om.GenerateName != "" {
// We disallow bringing your own name when the parent
// resource uses generateName (at creation).
return apis.ErrDisallowedFields("metadata.name")
}
if !strings.HasPrefix(name, prefix) {
return apis.ErrInvalidValue(
fmt.Sprintf("%q must have prefix %q", name, prefix),
"metadata.name")
}
}
return nil
}

View File

@ -100,10 +100,6 @@ const (
// It has to be in [0.1,100]
QueueSideCarResourcePercentageAnnotation = "queue.sidecar." + GroupName + "/resourcePercentage"
// VisibilityLabelKeyObsolete is the obsolete VisibilityLabelKey.
// This will move over to VisibilityLabelKey in networking repo..
VisibilityLabelKeyObsolete = "serving.knative.dev/visibility"
// VisibilityClusterLocal is the label value for VisibilityLabelKey
// that will result to the Route/KService getting a cluster local
// domain suffix.

View File

@ -65,7 +65,7 @@ func (cs *ConfigurationSpec) Validate(ctx context.Context) *apis.FieldError {
func (c *Configuration) validateLabels() (errs *apis.FieldError) {
for key, val := range c.GetLabels() {
switch key {
case serving.RouteLabelKey, serving.VisibilityLabelKeyObsolete:
case serving.RouteLabelKey:
// Known valid labels.
case serving.ServiceLabelKey:
errs = errs.Also(verifyLabelOwnerRef(val, serving.ServiceLabelKey, "Service", c.GetOwnerReferences()))

View File

@ -18,12 +18,15 @@ package v1
import (
"context"
"fmt"
"strconv"
"strings"
"k8s.io/apimachinery/pkg/api/validation"
"knative.dev/pkg/apis"
"knative.dev/pkg/kmp"
"knative.dev/serving/pkg/apis/autoscaling"
apisconfig "knative.dev/serving/pkg/apis/config"
"knative.dev/serving/pkg/apis/config"
"knative.dev/serving/pkg/apis/serving"
)
@ -58,13 +61,13 @@ func (r *Revision) Validate(ctx context.Context) *apis.FieldError {
// Validate implements apis.Validatable
func (rts *RevisionTemplateSpec) Validate(ctx context.Context) *apis.FieldError {
errs := rts.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")
errs = errs.Also(autoscaling.ValidateAnnotations(ctx, apisconfig.FromContextOrDefaults(ctx).Autoscaler,
errs = errs.Also(autoscaling.ValidateAnnotations(ctx, config.FromContextOrDefaults(ctx).Autoscaler,
rts.GetAnnotations()).ViaField("metadata.annotations"))
// If the RevisionTemplateSpec has a name specified, then check that
// it follows the requirements on the name.
errs = errs.Also(serving.ValidateRevisionName(ctx, rts.Name, rts.GenerateName))
errs = errs.Also(serving.ValidateQueueSidecarAnnotation(rts.Annotations).ViaField("metadata.annotations"))
errs = errs.Also(validateRevisionName(ctx, rts.Name, rts.GenerateName))
errs = errs.Also(validateQueueSidecarAnnotation(rts.Annotations).ViaField("metadata.annotations"))
return errs
}
@ -103,7 +106,7 @@ func (rs *RevisionSpec) Validate(ctx context.Context) *apis.FieldError {
errs := serving.ValidatePodSpec(ctx, rs.PodSpec)
if rs.TimeoutSeconds != nil {
errs = errs.Also(serving.ValidateTimeoutSeconds(ctx, *rs.TimeoutSeconds))
errs = errs.Also(validateTimeoutSeconds(ctx, *rs.TimeoutSeconds))
}
if rs.ContainerConcurrency != nil {
@ -137,3 +140,72 @@ func (r *Revision) ValidateLabels() (errs *apis.FieldError) {
}
return
}
// validateRevisionName validates name and generateName for the revisionTemplate
func validateRevisionName(ctx context.Context, name, generateName string) *apis.FieldError {
if generateName != "" {
if msgs := validation.NameIsDNS1035Label(generateName, true); len(msgs) > 0 {
return apis.ErrInvalidValue(
fmt.Sprint("not a DNS 1035 label prefix: ", msgs),
"metadata.generateName")
}
}
if name != "" {
if msgs := validation.NameIsDNS1035Label(name, false); len(msgs) > 0 {
return apis.ErrInvalidValue(
fmt.Sprint("not a DNS 1035 label: ", msgs),
"metadata.name")
}
om := apis.ParentMeta(ctx)
prefix := om.Name + "-"
if om.Name != "" {
// Even if there is GenerateName, allow the use
// of Name post-creation.
} else if om.GenerateName != "" {
// We disallow bringing your own name when the parent
// resource uses generateName (at creation).
return apis.ErrDisallowedFields("metadata.name")
}
if !strings.HasPrefix(name, prefix) {
return apis.ErrInvalidValue(
fmt.Sprintf("%q must have prefix %q", name, prefix),
"metadata.name")
}
}
return nil
}
// validateTimeoutSeconds validates timeout by comparing MaxRevisionTimeoutSeconds
func validateTimeoutSeconds(ctx context.Context, timeoutSeconds int64) *apis.FieldError {
if timeoutSeconds != 0 {
cfg := config.FromContextOrDefaults(ctx)
if timeoutSeconds > cfg.Defaults.MaxRevisionTimeoutSeconds || timeoutSeconds < 0 {
return apis.ErrOutOfBoundsValue(timeoutSeconds, 0,
cfg.Defaults.MaxRevisionTimeoutSeconds,
"timeoutSeconds")
}
}
return nil
}
// validateQueueSidecarAnnotation validates QueueSideCarResourcePercentageAnnotation
func validateQueueSidecarAnnotation(annotations map[string]string) *apis.FieldError {
if len(annotations) == 0 {
return nil
}
v, ok := annotations[serving.QueueSideCarResourcePercentageAnnotation]
if !ok {
return nil
}
value, err := strconv.ParseFloat(v, 64)
if err != nil {
return apis.ErrInvalidValue(v, apis.CurrentField).
ViaKey(serving.QueueSideCarResourcePercentageAnnotation)
}
if value < 0.1 || value > 100 {
return apis.ErrOutOfBoundsValue(value, 0.1, 100.0, apis.CurrentField).
ViaKey(serving.QueueSideCarResourcePercentageAnnotation)
}
return nil
}

View File

@ -202,7 +202,7 @@ func validateClusterVisibilityLabel(label string) (errs *apis.FieldError) {
func (r *Route) validateLabels() (errs *apis.FieldError) {
for key, val := range r.GetLabels() {
switch key {
case serving.VisibilityLabelKeyObsolete, network.VisibilityLabelKey:
case network.VisibilityLabelKey:
errs = errs.Also(validateClusterVisibilityLabel(val))
case serving.ServiceLabelKey:
errs = errs.Also(verifyLabelOwnerRef(val, serving.ServiceLabelKey, "Service", r.GetOwnerReferences()))

View File

@ -43,11 +43,13 @@ func (s *Service) Validate(ctx context.Context) (errs *apis.FieldError) {
if apis.IsInUpdate(ctx) {
original := apis.GetBaseline(ctx).(*Service)
errs = errs.Also(apis.ValidateCreatorAndModifier(original.Spec, s.Spec, original.GetAnnotations(),
errs = errs.Also(
apis.ValidateCreatorAndModifier(
original.Spec, s.Spec, original.GetAnnotations(),
s.GetAnnotations(), serving.GroupName).ViaField("metadata.annotations"))
err := s.Spec.ConfigurationSpec.Template.VerifyNameChange(ctx,
&original.Spec.ConfigurationSpec.Template)
errs = errs.Also(err.ViaField("spec.template"))
errs = errs.Also(
s.Spec.ConfigurationSpec.Template.VerifyNameChange(ctx,
&original.Spec.ConfigurationSpec.Template).ViaField("spec.template"))
}
return errs
}
@ -64,7 +66,7 @@ func (ss *ServiceSpec) Validate(ctx context.Context) *apis.FieldError {
func (s *Service) validateLabels() (errs *apis.FieldError) {
for key, val := range s.GetLabels() {
switch {
case key == network.VisibilityLabelKey || key == serving.VisibilityLabelKeyObsolete:
case key == network.VisibilityLabelKey:
errs = errs.Also(validateClusterVisibilityLabel(val))
case strings.HasPrefix(key, serving.GroupNamePrefix):
errs = errs.Also(apis.ErrInvalidKeyName(key, apis.CurrentField))

View File

@ -99,11 +99,11 @@ func (c *Domain) LookupDomainForLabels(labels map[string]string) string {
specificity := -1
// If we see VisibilityLabelKey sets with VisibilityClusterLocal, that
// will take precedence and the route will get a Cluster's Domain Name.
if labels[netpkg.VisibilityLabelKey] == serving.VisibilityClusterLocal ||
labels[serving.VisibilityLabelKeyObsolete] == serving.VisibilityClusterLocal {
if labels[netpkg.VisibilityLabelKey] == serving.VisibilityClusterLocal {
return "svc." + network.GetClusterDomainName()
}
for k, selector := range c.Domains {
// Ignore if selector doesn't match, or decrease the specificity.
if !selector.Matches(labels) || selector.specificity() < specificity {
continue

View File

@ -86,8 +86,7 @@ func DomainNameFromTemplate(ctx context.Context, r metav1.ObjectMeta, name strin
var templ *template.Template
// If the route is "cluster local" then don't use the user-defined
// domain template, use the default one
if rLabels[network.VisibilityLabelKey] == serving.VisibilityClusterLocal ||
rLabels[serving.VisibilityLabelKeyObsolete] == serving.VisibilityClusterLocal {
if rLabels[network.VisibilityLabelKey] == serving.VisibilityClusterLocal {
templ = template.Must(template.New("domain-template").Parse(
network.DefaultDomainTemplate))
} else {

View File

@ -24,7 +24,7 @@ import (
// IsObjectLocalVisibility returns whether an ObjectMeta is of cluster-local visibility
func IsObjectLocalVisibility(meta *metav1.ObjectMeta) bool {
return meta.Labels[network.VisibilityLabelKey] != "" || meta.Labels[serving.VisibilityLabelKeyObsolete] != ""
return meta.Labels[network.VisibilityLabelKey] != ""
}
// SetVisibility sets the visibility on an ObjectMeta

10
vendor/modules.txt vendored
View File

@ -756,7 +756,7 @@ k8s.io/kube-openapi/pkg/util/sets
k8s.io/utils/buffer
k8s.io/utils/integer
k8s.io/utils/trace
# knative.dev/eventing v0.20.0
# knative.dev/eventing v0.20.1-0.20210115015220-1c94ef83b6b5
## explicit
knative.dev/eventing/pkg/apis/config
knative.dev/eventing/pkg/apis/configs
@ -786,15 +786,15 @@ knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1beta1/fake
knative.dev/eventing/pkg/client/clientset/versioned/typed/messaging/v1beta1
knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2
knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake
# knative.dev/hack v0.0.0-20201214230143-4ed1ecb8db24
# knative.dev/hack v0.0.0-20210114150620-4422dcadb3c8
## explicit
knative.dev/hack
# knative.dev/networking v0.0.0-20210107024535-ecb89ced52d9
# knative.dev/networking v0.0.0-20210113172032-07a8160d1971
## explicit
knative.dev/networking/pkg
knative.dev/networking/pkg/apis/networking
knative.dev/networking/pkg/apis/networking/v1alpha1
# knative.dev/pkg v0.0.0-20210107022335-51c72e24c179
# knative.dev/pkg v0.0.0-20210114223020-f0ea5e6b9c4e
## explicit
knative.dev/pkg/apis
knative.dev/pkg/apis/duck
@ -838,7 +838,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.20.0
# knative.dev/serving v0.20.1-0.20210115004319-84421cde1553
## explicit
knative.dev/serving/pkg/apis/autoscaling
knative.dev/serving/pkg/apis/autoscaling/v1alpha1