From b4224fc56b3634097e2aaeba940bd93431d5e1a3 Mon Sep 17 00:00:00 2001 From: Scott Nichols Date: Wed, 19 Aug 2020 10:40:54 -0700 Subject: [PATCH 1/2] unpin knative deps for post-0.17 release --- go.mod | 4 +- go.sum | 11 +- hack/update-deps.sh | 8 +- .../configmappropagation/reconciler.go | 8 +- .../eventing/v1/broker/reconciler.go | 8 +- .../eventing/v1/trigger/reconciler.go | 8 +- .../eventing/v1beta1/broker/reconciler.go | 8 +- .../eventing/v1beta1/eventtype/reconciler.go | 8 +- .../eventing/v1beta1/trigger/reconciler.go | 8 +- .../flows/v1/parallel/reconciler.go | 8 +- .../flows/v1/sequence/reconciler.go | 8 +- .../flows/v1beta1/parallel/reconciler.go | 8 +- .../flows/v1beta1/sequence/reconciler.go | 8 +- .../messaging/v1/channel/reconciler.go | 8 +- .../v1/inmemorychannel/reconciler.go | 8 +- .../messaging/v1/subscription/reconciler.go | 8 +- .../messaging/v1beta1/channel/reconciler.go | 8 +- .../v1beta1/inmemorychannel/reconciler.go | 8 +- .../v1beta1/subscription/reconciler.go | 8 +- .../v1alpha2/apiserversource/reconciler.go | 8 +- .../v1alpha2/containersource/reconciler.go | 8 +- .../sources/v1alpha2/pingsource/reconciler.go | 8 +- .../v1beta1/apiserversource/reconciler.go | 8 +- .../v1beta1/containersource/reconciler.go | 8 +- .../sources/v1beta1/pingsource/reconciler.go | 8 +- .../pkg/apis/duck/v1beta1/destination.go | 3 +- .../generators/reconciler_reconciler.go | 8 +- .../knative.dev/pkg/controller/controller.go | 6 +- vendor/knative.dev/pkg/hack/update-deps.sh | 2 +- vendor/knative.dev/pkg/hash/bucketer.go | 5 + vendor/knative.dev/pkg/kmp/diff.go | 4 +- vendor/knative.dev/pkg/kmp/reporters.go | 69 ++-- vendor/knative.dev/pkg/test/logging/error.go | 5 +- .../knative.dev/pkg/test/logging/tlogger.go | 27 +- .../defaulting/defaulting.go | 4 +- .../resourcesemantics/defaulting/user_info.go | 4 +- .../knative.dev/test-infra/scripts/README.md | 27 +- .../test-infra/scripts/e2e-tests.sh | 319 ++---------------- .../test-infra/scripts/infra-library.sh | 242 +++++++++++++ .../knative.dev/test-infra/scripts/library.sh | 16 + .../test-infra/scripts/presubmit-tests.sh | 9 - vendor/modules.txt | 4 +- 42 files changed, 513 insertions(+), 440 deletions(-) create mode 100644 vendor/knative.dev/test-infra/scripts/infra-library.sh diff --git a/go.mod b/go.mod index 4d125c2fd9d..79abb272e5e 100644 --- a/go.mod +++ b/go.mod @@ -39,8 +39,8 @@ require ( k8s.io/apiserver v0.17.6 k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible k8s.io/utils v0.0.0-20200603063816-c1c6865ac451 - knative.dev/pkg v0.0.0-20200812224206-44c860147a87 - knative.dev/test-infra v0.0.0-20200813220834-388e55a496cf + knative.dev/pkg v0.0.0-20200819000613-c30ec2ffd4ec + knative.dev/test-infra v0.0.0-20200818223413-ab8738ebf9f4 sigs.k8s.io/yaml v1.2.0 ) diff --git a/go.sum b/go.sum index 4f024dd92e6..04bb4c2c4c2 100644 --- a/go.sum +++ b/go.sum @@ -1848,17 +1848,16 @@ knative.dev/pkg v0.0.0-20200505191044-3da93ebb24c2/go.mod h1:Q6sL35DdGs8hIQZKdaC knative.dev/pkg v0.0.0-20200515002500-16d7b963416f/go.mod h1:tMOHGbxtRz8zYFGEGpV/bpoTEM1o89MwYFC4YJXl3GY= knative.dev/pkg v0.0.0-20200528142800-1c6815d7e4c9/go.mod h1:QgNZTxnwpB/oSpNcfnLVlw+WpEwwyKAvJlvR3hgeltA= knative.dev/pkg v0.0.0-20200711004937-22502028e31a/go.mod h1:AqAJV6rYi8IGikDjJ/9ZQd9qKdkXVlesVnVjwx62YB8= -knative.dev/pkg v0.0.0-20200812224206-44c860147a87 h1:argvd9DHJr2YeeV2pl1ogXPB3raIWnOqJivfBK/qsiM= -knative.dev/pkg v0.0.0-20200812224206-44c860147a87/go.mod h1:udIbxBS/SJCL4sqnCG8HZArez9HjWmeqJCaVJP/h32I= +knative.dev/pkg v0.0.0-20200819000613-c30ec2ffd4ec h1:Y0bxwqPQZjlWtZ2SY4OgTNBmAkU1fLuvROVuy9A1U3A= +knative.dev/pkg v0.0.0-20200819000613-c30ec2ffd4ec/go.mod h1:UQNXXn3xdykWbTkhXYUZnev2H3s82+gNrgxYDJ5jIRE= knative.dev/test-infra v0.0.0-20200407185800-1b88cb3b45a5/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ= knative.dev/test-infra v0.0.0-20200505052144-5ea2f705bb55/go.mod h1:WqF1Azka+FxPZ20keR2zCNtiQA1MP9ZB4BH4HuI+SIU= knative.dev/test-infra v0.0.0-20200513011557-d03429a76034/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE= knative.dev/test-infra v0.0.0-20200519015156-82551620b0a9/go.mod h1:A5b2OAXTOeHT3hHhVQm3dmtbuWvIDP7qzgtqxA3/2pE= knative.dev/test-infra v0.0.0-20200707183444-aed09e56ddc7/go.mod h1:RjYAhXnZqeHw9+B0zsbqSPlae0lCvjekO/nw5ZMpLCs= -knative.dev/test-infra v0.0.0-20200811030605-72f8c9f3e933 h1:1nfmLI9iQ87ygMeKGLREhH+2KYa6XX/e6enu0PsasHY= -knative.dev/test-infra v0.0.0-20200811030605-72f8c9f3e933/go.mod h1:Pmg2c7Z7q7BGFUV/GOpU5BlrD3ePJft4MPqx8AYBplc= -knative.dev/test-infra v0.0.0-20200813220834-388e55a496cf h1:GrIpJgHa/iWE1Gk2WKGXSEv1Uw7qPepjCELY+Jjzewo= -knative.dev/test-infra v0.0.0-20200813220834-388e55a496cf/go.mod h1:Pmg2c7Z7q7BGFUV/GOpU5BlrD3ePJft4MPqx8AYBplc= +knative.dev/test-infra v0.0.0-20200817225313-c0ea00ce480c/go.mod h1:Pmg2c7Z7q7BGFUV/GOpU5BlrD3ePJft4MPqx8AYBplc= +knative.dev/test-infra v0.0.0-20200818223413-ab8738ebf9f4 h1:bWIXvv+RePI8trmA46AEB0SB7lKC5jIMn/NDv3mok+M= +knative.dev/test-infra v0.0.0-20200818223413-ab8738ebf9f4/go.mod h1:Pmg2c7Z7q7BGFUV/GOpU5BlrD3ePJft4MPqx8AYBplc= 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/hack/update-deps.sh b/hack/update-deps.sh index 03109ea503b..37fdce8489a 100755 --- a/hack/update-deps.sh +++ b/hack/update-deps.sh @@ -26,14 +26,14 @@ export GO111MODULE=on # This controls the release branch we track. VERSION="master" -cd "${ROOT_DIR}" - # The list of dependencies that we track at HEAD and periodically # float forward in this repository. FLOATING_DEPS=( - "knative.dev/test-infra@release-0.17" - "knative.dev/pkg@release-0.17" + "knative.dev/test-infra@${VERSION}" + "knative.dev/pkg@${VERSION}" ) + +cd "${ROOT_DIR}" # Parse flags to determine any we should pass to dep. GO_GET=0 diff --git a/pkg/client/injection/reconciler/configs/v1alpha1/configmappropagation/reconciler.go b/pkg/client/injection/reconciler/configs/v1alpha1/configmappropagation/reconciler.go index bf772ea5616..99fa72af549 100644 --- a/pkg/client/injection/reconciler/configs/v1alpha1/configmappropagation/reconciler.go +++ b/pkg/client/injection/reconciler/configs/v1alpha1/configmappropagation/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/eventing/v1/broker/reconciler.go b/pkg/client/injection/reconciler/eventing/v1/broker/reconciler.go index b3376b6bf37..d90a8e962c3 100644 --- a/pkg/client/injection/reconciler/eventing/v1/broker/reconciler.go +++ b/pkg/client/injection/reconciler/eventing/v1/broker/reconciler.go @@ -246,13 +246,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/eventing/v1/trigger/reconciler.go b/pkg/client/injection/reconciler/eventing/v1/trigger/reconciler.go index 4876c754912..3fddeff1f41 100644 --- a/pkg/client/injection/reconciler/eventing/v1/trigger/reconciler.go +++ b/pkg/client/injection/reconciler/eventing/v1/trigger/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/eventing/v1beta1/broker/reconciler.go b/pkg/client/injection/reconciler/eventing/v1beta1/broker/reconciler.go index 79bd7fdebb9..2cdb70537d0 100644 --- a/pkg/client/injection/reconciler/eventing/v1beta1/broker/reconciler.go +++ b/pkg/client/injection/reconciler/eventing/v1beta1/broker/reconciler.go @@ -246,13 +246,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/eventing/v1beta1/eventtype/reconciler.go b/pkg/client/injection/reconciler/eventing/v1beta1/eventtype/reconciler.go index c46d569e872..6e89fcaff2b 100644 --- a/pkg/client/injection/reconciler/eventing/v1beta1/eventtype/reconciler.go +++ b/pkg/client/injection/reconciler/eventing/v1beta1/eventtype/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/eventing/v1beta1/trigger/reconciler.go b/pkg/client/injection/reconciler/eventing/v1beta1/trigger/reconciler.go index 6d24e80a8ab..239347cfcbb 100644 --- a/pkg/client/injection/reconciler/eventing/v1beta1/trigger/reconciler.go +++ b/pkg/client/injection/reconciler/eventing/v1beta1/trigger/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/flows/v1/parallel/reconciler.go b/pkg/client/injection/reconciler/flows/v1/parallel/reconciler.go index c3f18722d20..9e813a84b9e 100644 --- a/pkg/client/injection/reconciler/flows/v1/parallel/reconciler.go +++ b/pkg/client/injection/reconciler/flows/v1/parallel/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/flows/v1/sequence/reconciler.go b/pkg/client/injection/reconciler/flows/v1/sequence/reconciler.go index 167548e0837..cb03fe35c32 100644 --- a/pkg/client/injection/reconciler/flows/v1/sequence/reconciler.go +++ b/pkg/client/injection/reconciler/flows/v1/sequence/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/flows/v1beta1/parallel/reconciler.go b/pkg/client/injection/reconciler/flows/v1beta1/parallel/reconciler.go index 5e03c7bfd7e..851e5c0d8c5 100644 --- a/pkg/client/injection/reconciler/flows/v1beta1/parallel/reconciler.go +++ b/pkg/client/injection/reconciler/flows/v1beta1/parallel/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/flows/v1beta1/sequence/reconciler.go b/pkg/client/injection/reconciler/flows/v1beta1/sequence/reconciler.go index 9820db6d81d..e6c7184ff30 100644 --- a/pkg/client/injection/reconciler/flows/v1beta1/sequence/reconciler.go +++ b/pkg/client/injection/reconciler/flows/v1beta1/sequence/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/messaging/v1/channel/reconciler.go b/pkg/client/injection/reconciler/messaging/v1/channel/reconciler.go index 827209d4696..4836bd8ee87 100644 --- a/pkg/client/injection/reconciler/messaging/v1/channel/reconciler.go +++ b/pkg/client/injection/reconciler/messaging/v1/channel/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/messaging/v1/inmemorychannel/reconciler.go b/pkg/client/injection/reconciler/messaging/v1/inmemorychannel/reconciler.go index ca4de63af23..b74b3569a5d 100644 --- a/pkg/client/injection/reconciler/messaging/v1/inmemorychannel/reconciler.go +++ b/pkg/client/injection/reconciler/messaging/v1/inmemorychannel/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/messaging/v1/subscription/reconciler.go b/pkg/client/injection/reconciler/messaging/v1/subscription/reconciler.go index 4601cf99f68..bc0a6517b57 100644 --- a/pkg/client/injection/reconciler/messaging/v1/subscription/reconciler.go +++ b/pkg/client/injection/reconciler/messaging/v1/subscription/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/messaging/v1beta1/channel/reconciler.go b/pkg/client/injection/reconciler/messaging/v1beta1/channel/reconciler.go index f4f53465110..53ce706431c 100644 --- a/pkg/client/injection/reconciler/messaging/v1beta1/channel/reconciler.go +++ b/pkg/client/injection/reconciler/messaging/v1beta1/channel/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/messaging/v1beta1/inmemorychannel/reconciler.go b/pkg/client/injection/reconciler/messaging/v1beta1/inmemorychannel/reconciler.go index 2354e6d4d6e..7fe8f4b1db2 100644 --- a/pkg/client/injection/reconciler/messaging/v1beta1/inmemorychannel/reconciler.go +++ b/pkg/client/injection/reconciler/messaging/v1beta1/inmemorychannel/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/messaging/v1beta1/subscription/reconciler.go b/pkg/client/injection/reconciler/messaging/v1beta1/subscription/reconciler.go index c00b1bcdf99..f7918ad190b 100644 --- a/pkg/client/injection/reconciler/messaging/v1beta1/subscription/reconciler.go +++ b/pkg/client/injection/reconciler/messaging/v1beta1/subscription/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/sources/v1alpha2/apiserversource/reconciler.go b/pkg/client/injection/reconciler/sources/v1alpha2/apiserversource/reconciler.go index 6de1516f803..3c21f46f5a4 100644 --- a/pkg/client/injection/reconciler/sources/v1alpha2/apiserversource/reconciler.go +++ b/pkg/client/injection/reconciler/sources/v1alpha2/apiserversource/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/sources/v1alpha2/containersource/reconciler.go b/pkg/client/injection/reconciler/sources/v1alpha2/containersource/reconciler.go index d4d791e1134..5b6f47ba671 100644 --- a/pkg/client/injection/reconciler/sources/v1alpha2/containersource/reconciler.go +++ b/pkg/client/injection/reconciler/sources/v1alpha2/containersource/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/sources/v1alpha2/pingsource/reconciler.go b/pkg/client/injection/reconciler/sources/v1alpha2/pingsource/reconciler.go index 5143874e4fd..33d9563ae58 100644 --- a/pkg/client/injection/reconciler/sources/v1alpha2/pingsource/reconciler.go +++ b/pkg/client/injection/reconciler/sources/v1alpha2/pingsource/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/sources/v1beta1/apiserversource/reconciler.go b/pkg/client/injection/reconciler/sources/v1beta1/apiserversource/reconciler.go index 536299064f4..1b5d7fe2d90 100644 --- a/pkg/client/injection/reconciler/sources/v1beta1/apiserversource/reconciler.go +++ b/pkg/client/injection/reconciler/sources/v1beta1/apiserversource/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/sources/v1beta1/containersource/reconciler.go b/pkg/client/injection/reconciler/sources/v1beta1/containersource/reconciler.go index 10831a691e3..bf3b01c6ba4 100644 --- a/pkg/client/injection/reconciler/sources/v1beta1/containersource/reconciler.go +++ b/pkg/client/injection/reconciler/sources/v1beta1/containersource/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/pkg/client/injection/reconciler/sources/v1beta1/pingsource/reconciler.go b/pkg/client/injection/reconciler/sources/v1beta1/pingsource/reconciler.go index 09db95abc13..0c100fbe9b6 100644 --- a/pkg/client/injection/reconciler/sources/v1beta1/pingsource/reconciler.go +++ b/pkg/client/injection/reconciler/sources/v1beta1/pingsource/reconciler.go @@ -235,13 +235,17 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { return fmt.Errorf("failed to set finalizers: %w", err) } - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } // Reconcile this copy of the resource and then write back any status // updates regardless of whether the reconciliation errored out. reconcileEvent = do(ctx, resource) - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } case reconciler.DoFinalizeKind: // For finalizing reconcilers, if this resource being marked for deletion diff --git a/vendor/knative.dev/pkg/apis/duck/v1beta1/destination.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/destination.go index 9c247b0305b..fe0f5d171d0 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1beta1/destination.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/destination.go @@ -107,9 +107,8 @@ func ValidateDestination(dest Destination, allowDeprecatedFields bool) *apis.Fie if ref != nil && dest.URI == nil { if dest.Ref != nil { return validateDestinationRef(*ref).ViaField("ref") - } else { - return validateDestinationRef(*ref) } + return validateDestinationRef(*ref) } return nil } 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 ac8138188d2..bf580614647 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 @@ -421,7 +421,9 @@ func (r *reconcilerImpl) Reconcile(ctx {{.contextContext|raw}}, key string) erro return {{.fmtErrorf|raw}}("failed to set finalizers: %w", err) } {{if .isKRShaped}} - reconciler.PreProcessReconcile(ctx, resource) + if !r.skipStatusUpdates { + reconciler.PreProcessReconcile(ctx, resource) + } {{end}} // Reconcile this copy of the resource and then write back any status @@ -429,7 +431,9 @@ func (r *reconcilerImpl) Reconcile(ctx {{.contextContext|raw}}, key string) erro reconcileEvent = do(ctx, resource) {{if .isKRShaped}} - reconciler.PostProcessReconcile(ctx, resource, original) + if !r.skipStatusUpdates { + reconciler.PostProcessReconcile(ctx, resource, original) + } {{end}} case {{.doFinalizeKind|raw}}: diff --git a/vendor/knative.dev/pkg/controller/controller.go b/vendor/knative.dev/pkg/controller/controller.go index b88b4a20e06..895b05d014b 100644 --- a/vendor/knative.dev/pkg/controller/controller.go +++ b/vendor/knative.dev/pkg/controller/controller.go @@ -262,7 +262,7 @@ func (c *Impl) EnqueueAfter(obj interface{}, after time.Duration) { // and enqueues that key in the slow lane. func (c *Impl) EnqueueSlowKey(key types.NamespacedName) { c.workQueue.SlowLane().Add(key) - c.logger.With(zap.Object(logkey.Key, logging.NamespacedName(key))). + c.logger.With(zap.String(logkey.Key, key.String())). Debugf("Adding to the slow queue %s (depth(total/slow): %d/%d)", safeKey(key), c.workQueue.Len(), c.workQueue.SlowLane().Len()) } @@ -390,7 +390,7 @@ func (c *Impl) EnqueueNamespaceOf(obj interface{}) { // EnqueueKey takes a namespace/name string and puts it onto the work queue. func (c *Impl) EnqueueKey(key types.NamespacedName) { c.workQueue.Add(key) - c.logger.With(zap.Object(logkey.Key, logging.NamespacedName(key))). + c.logger.With(zap.String(logkey.Key, key.String())). Debugf("Adding to queue %s (depth: %d)", safeKey(key), c.workQueue.Len()) } @@ -406,7 +406,7 @@ func (c *Impl) MaybeEnqueueBucketKey(bkt reconciler.Bucket, key types.Namespaced // the work queue after given delay. func (c *Impl) EnqueueKeyAfter(key types.NamespacedName, delay time.Duration) { c.workQueue.AddAfter(key, delay) - c.logger.With(zap.Object(logkey.Key, logging.NamespacedName(key))). + c.logger.With(zap.String(logkey.Key, key.String())). Debugf("Adding to queue %s (delay: %v, depth: %d)", safeKey(key), delay, c.workQueue.Len()) } diff --git a/vendor/knative.dev/pkg/hack/update-deps.sh b/vendor/knative.dev/pkg/hack/update-deps.sh index b7e31052b8c..a39fc858fe4 100644 --- a/vendor/knative.dev/pkg/hack/update-deps.sh +++ b/vendor/knative.dev/pkg/hack/update-deps.sh @@ -26,7 +26,7 @@ cd ${ROOT_DIR} # The list of dependencies that we track at HEAD and periodically # float forward in this repository. FLOATING_DEPS=( - "knative.dev/test-infra@release-0.17" + "knative.dev/test-infra@master" ) # Parse flags to determine any we should pass to dep. diff --git a/vendor/knative.dev/pkg/hash/bucketer.go b/vendor/knative.dev/pkg/hash/bucketer.go index d0c1460a892..41d26d97cc3 100644 --- a/vendor/knative.dev/pkg/hash/bucketer.go +++ b/vendor/knative.dev/pkg/hash/bucketer.go @@ -111,6 +111,11 @@ func (bs *BucketSet) Owner(key string) string { return ret } +// HasBucket returns true if this BucketSet has the given bucket name. +func (bs *BucketSet) HasBucket(bkt string) bool { + return bs.buckets.Has(bkt) +} + // BucketList returns the bucket names of this BucketSet in random order. func (bs *BucketSet) BucketList() []string { bs.mu.RLock() diff --git a/vendor/knative.dev/pkg/kmp/diff.go b/vendor/knative.dev/pkg/kmp/diff.go index 09c041446b3..791c9d1d48d 100644 --- a/vendor/knative.dev/pkg/kmp/diff.go +++ b/vendor/knative.dev/pkg/kmp/diff.go @@ -73,7 +73,7 @@ func SafeEqual(x, y interface{}, opts ...cmp.Option) (equal bool, err error) { // CompareSetFields returns a list of field names that differ between // x and y. Uses SafeEqual for comparison. func CompareSetFields(x, y interface{}, opts ...cmp.Option) ([]string, error) { - r := new(FieldListReporter) + r := new(fieldListReporter) opts = append(opts, cmp.Reporter(r)) _, err := SafeEqual(x, y, opts...) return r.Fields(), err @@ -82,7 +82,7 @@ func CompareSetFields(x, y interface{}, opts ...cmp.Option) ([]string, error) { // ShortDiff returns a zero-context, unified human-readable diff. // Uses SafeEqual for comparison. func ShortDiff(prev, cur interface{}, opts ...cmp.Option) (string, error) { - r := new(ShortDiffReporter) + r := new(shortDiffReporter) opts = append(opts, cmp.Reporter(r)) var err error if _, err = SafeEqual(prev, cur, opts...); err != nil { diff --git a/vendor/knative.dev/pkg/kmp/reporters.go b/vendor/knative.dev/pkg/kmp/reporters.go index 5586f90bc6a..6f8ba01458d 100644 --- a/vendor/knative.dev/pkg/kmp/reporters.go +++ b/vendor/knative.dev/pkg/kmp/reporters.go @@ -25,42 +25,41 @@ import ( "github.com/google/go-cmp/cmp" ) -// FieldListReporter implements the cmp.Reporter interface. It keeps +// fieldListReporter implements the cmp.Reporter interface. It keeps // track of the field names that differ between two structs and reports // them through the Fields() function. -type FieldListReporter struct { +type fieldListReporter struct { path cmp.Path fieldNames []string } // PushStep implements the cmp.Reporter. -func (r *FieldListReporter) PushStep(ps cmp.PathStep) { +func (r *fieldListReporter) PushStep(ps cmp.PathStep) { r.path = append(r.path, ps) } // fieldName returns a readable name for the field. If the field has JSON annotations it // returns the JSON key. If the field does not have JSON annotations or the JSON annotation // marks the field as ignored it returns the field's go name -func (r *FieldListReporter) fieldName() string { +func (r *fieldListReporter) fieldName() string { if len(r.path) < 2 { return r.path.Index(0).String() - } else { - fieldName := strings.TrimPrefix(r.path.Index(1).String(), ".") - // Prefer JSON name to fieldName if it exists - structField, exists := r.path.Index(0).Type().FieldByName(fieldName) - if exists { - tag := structField.Tag.Get("json") - if tag != "" && tag != "-" { - return strings.SplitN(tag, ",", 2)[0] - } - + } + fieldName := strings.TrimPrefix(r.path.Index(1).String(), ".") + // Prefer JSON name to fieldName if it exists + structField, exists := r.path.Index(0).Type().FieldByName(fieldName) + if exists { + tag := structField.Tag.Get("json") + if tag != "" && tag != "-" { + return strings.SplitN(tag, ",", 2)[0] } - return fieldName } + + return fieldName } // Report implements the cmp.Reporter. -func (r *FieldListReporter) Report(rs cmp.Result) { +func (r *fieldListReporter) Report(rs cmp.Result) { if rs.Equal() { return } @@ -75,72 +74,70 @@ func (r *FieldListReporter) Report(rs cmp.Result) { } // PopStep implements cmp.Reporter. -func (r *FieldListReporter) PopStep() { +func (r *fieldListReporter) PopStep() { r.path = r.path[:len(r.path)-1] } // Fields returns the field names that differed between the two // objects after calling cmp.Equal with the FieldListReporter. Field names // are returned in alphabetical order. -func (r *FieldListReporter) Fields() []string { +func (r *fieldListReporter) Fields() []string { sort.Strings(r.fieldNames) return r.fieldNames } -// ShortDiffReporter implements the cmp.Reporter interface. It reports +// shortDiffReporter implements the cmp.Reporter interface. It reports // on fields which have diffing values in a short zero-context, unified diff // format. -type ShortDiffReporter struct { +type shortDiffReporter struct { path cmp.Path diffs []string err error } // PushStep implements the cmp.Reporter. -func (r *ShortDiffReporter) PushStep(ps cmp.PathStep) { +func (r *shortDiffReporter) PushStep(ps cmp.PathStep) { r.path = append(r.path, ps) } // Report implements the cmp.Reporter. -func (r *ShortDiffReporter) Report(rs cmp.Result) { +func (r *shortDiffReporter) Report(rs cmp.Result) { if rs.Equal() { return } cur := r.path.Last() vx, vy := cur.Values() t := cur.Type() - var diff string // Prefix struct values with the types to add clarity in output if !vx.IsValid() && !vy.IsValid() { r.err = fmt.Errorf("unable to diff %+v and %+v on path %#v", vx, vy, r.path) - } else { - diff = fmt.Sprintf("%#v:\n", r.path) - if vx.IsValid() { - diff += r.diffString("-", t, vx) - } - if vy.IsValid() { - diff += r.diffString("+", t, vy) - } + return + } + diff := fmt.Sprintf("%#v:\n", r.path) + if vx.IsValid() { + diff += r.diffString("-", t, vx) + } + if vy.IsValid() { + diff += r.diffString("+", t, vy) } r.diffs = append(r.diffs, diff) } -func (r *ShortDiffReporter) diffString(diffType string, t reflect.Type, v reflect.Value) string { +func (r *shortDiffReporter) diffString(diffType string, t reflect.Type, v reflect.Value) string { if t.Kind() == reflect.Struct { return fmt.Sprintf("\t%s: %+v: \"%+v\"\n", diffType, t, v) - } else { - return fmt.Sprintf("\t%s: \"%+v\"\n", diffType, v) } + return fmt.Sprintf("\t%s: \"%+v\"\n", diffType, v) } // PopStep implements the cmp.Reporter. -func (r *ShortDiffReporter) PopStep() { +func (r *shortDiffReporter) PopStep() { r.path = r.path[:len(r.path)-1] } // Diff returns the generated short diff for this object. // cmp.Equal should be called before this method. -func (r *ShortDiffReporter) Diff() (string, error) { +func (r *shortDiffReporter) Diff() (string, error) { if r.err != nil { return "", r.err } diff --git a/vendor/knative.dev/pkg/test/logging/error.go b/vendor/knative.dev/pkg/test/logging/error.go index d3caea91cfd..e349160757e 100644 --- a/vendor/knative.dev/pkg/test/logging/error.go +++ b/vendor/knative.dev/pkg/test/logging/error.go @@ -50,15 +50,14 @@ func keysAndValuesToSpewedMap(args ...interface{}) map[string]string { return m } -// Implement `error` interface +// Error implements `error` interface func (e structuredError) Error() string { // TODO(coryrc): accept zap.Field entries? if e.print { // %v for fmt.Sprintf does print keys sorted return fmt.Sprintf("Error: %s\nContext:\n%v", e.msg, keysAndValuesToSpewedMap(e.keysAndValues...)) - } else { - return e.msg } + return e.msg } // GetValues gives you the structured key values in a plist diff --git a/vendor/knative.dev/pkg/test/logging/tlogger.go b/vendor/knative.dev/pkg/test/logging/tlogger.go index e89e2294a83..c497d738430 100644 --- a/vendor/knative.dev/pkg/test/logging/tlogger.go +++ b/vendor/knative.dev/pkg/test/logging/tlogger.go @@ -163,22 +163,21 @@ func (o *TLogger) interfacesToFields(things ...interface{}) []interface{} { func (o *TLogger) errorWithRuntimeCheck(stringThenKeysAndValues ...interface{}) (error, string, []interface{}) { if len(stringThenKeysAndValues) == 0 { return nil, "", nil - } else { - s, isString := stringThenKeysAndValues[0].(string) - e, isError := stringThenKeysAndValues[0].(error) - if isString { - // Desired case (hopefully) - remainder := stringThenKeysAndValues[1:] - if !validateKeysAndValues(remainder...) { - remainder = o.interfacesToFields(remainder...) - } - return nil, s, remainder - } else if isError && len(stringThenKeysAndValues) == 1 { - return e, "", nil - } else { - return nil, "unstructured error", o.interfacesToFields(stringThenKeysAndValues...) + } + s, isString := stringThenKeysAndValues[0].(string) + if isString { + // Desired case (hopefully) + remainder := stringThenKeysAndValues[1:] + if !validateKeysAndValues(remainder...) { + remainder = o.interfacesToFields(remainder...) } + return nil, s, remainder + } + e, isError := stringThenKeysAndValues[0].(error) + if isError && len(stringThenKeysAndValues) == 1 { + return e, "", nil } + return nil, "unstructured error", o.interfacesToFields(stringThenKeysAndValues...) } // Cleanup registers a cleanup callback. diff --git a/vendor/knative.dev/pkg/webhook/resourcesemantics/defaulting/defaulting.go b/vendor/knative.dev/pkg/webhook/resourcesemantics/defaulting/defaulting.go index faebc5f6e9a..9c82de1375c 100644 --- a/vendor/knative.dev/pkg/webhook/resourcesemantics/defaulting/defaulting.go +++ b/vendor/knative.dev/pkg/webhook/resourcesemantics/defaulting/defaulting.go @@ -279,7 +279,7 @@ func (ac *reconciler) mutate(ctx context.Context, req *admissionv1.AdmissionRequ s, ok := oldObj.(apis.HasSpec) if ok { - SetUserInfoAnnotations(s, ctx, req.Resource.Group) + setUserInfoAnnotations(ctx, s, req.Resource.Group) } if req.SubResource == "" { @@ -323,7 +323,7 @@ func (ac *reconciler) setUserInfoAnnotations(ctx context.Context, patches duck.J b, a := new.DeepCopyObject().(apis.HasSpec), nh - SetUserInfoAnnotations(nh, ctx, groupName) + setUserInfoAnnotations(ctx, nh, groupName) patch, err := duck.CreatePatch(b, a) if err != nil { diff --git a/vendor/knative.dev/pkg/webhook/resourcesemantics/defaulting/user_info.go b/vendor/knative.dev/pkg/webhook/resourcesemantics/defaulting/user_info.go index a1243b8e8ab..36c1cfbd215 100644 --- a/vendor/knative.dev/pkg/webhook/resourcesemantics/defaulting/user_info.go +++ b/vendor/knative.dev/pkg/webhook/resourcesemantics/defaulting/user_info.go @@ -24,8 +24,8 @@ import ( "knative.dev/pkg/apis" ) -// SetUserInfoAnnotations sets creator and updater annotations on a resource. -func SetUserInfoAnnotations(resource apis.HasSpec, ctx context.Context, groupName string) { +// setUserInfoAnnotations sets creator and updater annotations on a resource. +func setUserInfoAnnotations(ctx context.Context, resource apis.HasSpec, groupName string) { if ui := apis.GetUserInfo(ctx); ui != nil { objectMetaAccessor, ok := resource.(metav1.ObjectMetaAccessor) if !ok { diff --git a/vendor/knative.dev/test-infra/scripts/README.md b/vendor/knative.dev/test-infra/scripts/README.md index 32e17ac1fff..01361fd4a1b 100644 --- a/vendor/knative.dev/test-infra/scripts/README.md +++ b/vendor/knative.dev/test-infra/scripts/README.md @@ -113,30 +113,31 @@ This is a helper script for Knative E2E test scripts. To use it: 1. [optional] Customize the test cluster. Set the following environment variables if the default values don't fit your needs: - - `E2E_CLUSTER_REGION`: Cluster region, defaults to `us-central1`. - - `E2E_CLUSTER_BACKUP_REGIONS`: Space-separated list of regions to retry test + - `E2E_GCP_PROJECT_ID`: GCP project ID for creating the clusters, defaults to none. + - `E2E_GKE_CLUSTER_REGION`: Cluster region, defaults to `us-central1`. + - `E2E_GKE_CLUSTER_BACKUP_REGIONS`: Space-separated list of regions to retry test cluster creation in case of stockout. Defaults to `us-west1 us-east1`. - - `E2E_CLUSTER_ZONE`: Cluster zone (e.g., `a`), defaults to none (i.e. use a + - `E2E_GKE_CLUSTER_ZONE`: Cluster zone (e.g., `a`), defaults to none (i.e. use a regional cluster). - - `E2E_CLUSTER_BACKUP_ZONES`: Space-separated list of zones to retry test + - `E2E_GKE_CLUSTER_BACKUP_ZONES`: Space-separated list of zones to retry test cluster creation in case of stockout. If defined, - `E2E_CLUSTER_BACKUP_REGIONS` will be ignored thus it defaults to none. - - `E2E_CLUSTER_MACHINE`: Cluster node machine type, defaults to + `E2E_GKE_CLUSTER_BACKUP_REGIONS` will be ignored thus it defaults to none. + - `E2E_GKE_CLUSTER_MACHINE`: Cluster node machine type, defaults to `e2-standard-4}`. - `E2E_MIN_CLUSTER_NODES`: Minimum number of nodes in the cluster when autoscaling, defaults to 1. - `E2E_MAX_CLUSTER_NODES`: Maximum number of nodes in the cluster when autoscaling, defaults to 3. + - `E2E_GKE_SCOPES`: Scopes for the GKE node instances, defaults to `cloud-platform`. + - `E2E_CLUSTER_VERSION`: Version for the cluster, defaults to `latest`. 1. Source the script. 1. [optional] Write the `knative_setup()` function, which will set up your - system under test (e.g., Knative Serving). This function won't be called if - you use the `--skip-knative-setup` flag. + system under test (e.g., Knative Serving). 1. [optional] Write the `knative_teardown()` function, which will tear down your - system under test (e.g., Knative Serving). This function won't be called if - you use the `--skip-knative-setup` flag. + system under test (e.g., Knative Serving). 1. [optional] Write the `test_setup()` function, which will set up the test resources. @@ -171,7 +172,7 @@ This is a helper script for Knative E2E test scripts. To use it: **Notes:** 1. Calling your script without arguments will create a new cluster in the GCP - project `$PROJECT_ID` and run the tests against it. + project `$E2E_GCP_PROJECT_ID` and run the tests against it. 1. Calling your script with `--run-tests` and the variable `KO_DOCKER_REPO` set will immediately start the tests against the cluster currently configured for @@ -183,10 +184,6 @@ This is a helper script for Knative E2E test scripts. To use it: 1. By default Istio is installed on the cluster via Addon, use `--skip-istio-addon` if you choose not to have it preinstalled. -1. You can force running the tests against a specific GKE cluster version by - using the `--cluster-version` flag and passing a full version as the flag - value. - ### Sample end-to-end test script This script will test that the latest Knative Serving nightly release works. It diff --git a/vendor/knative.dev/test-infra/scripts/e2e-tests.sh b/vendor/knative.dev/test-infra/scripts/e2e-tests.sh index a788b6827bd..590adb1f31e 100644 --- a/vendor/knative.dev/test-infra/scripts/e2e-tests.sh +++ b/vendor/knative.dev/test-infra/scripts/e2e-tests.sh @@ -17,50 +17,9 @@ # This is a helper script for Knative E2E test scripts. # See README.md for instructions on how to use it. -source $(dirname "${BASH_SOURCE[0]}")/library.sh +source $(dirname "${BASH_SOURCE[0]}")/infra-library.sh -# Build a resource name based on $E2E_BASE_NAME, a suffix and $BUILD_NUMBER. -# Restricts the name length to 40 chars (the limit for resource names in GCP). -# Name will have the form $E2E_BASE_NAME-$BUILD_NUMBER. -# Parameters: $1 - name suffix -function build_resource_name() { - local prefix=${E2E_BASE_NAME}-$1 - local suffix=${BUILD_NUMBER} - # Restrict suffix length to 20 chars - if [[ -n "${suffix}" ]]; then - suffix=${suffix:${#suffix}<20?0:-20} - fi - local name="${prefix:0:20}${suffix}" - # Ensure name doesn't end with "-" - echo "${name%-}" -} - -# Test cluster parameters - -# Configurable parameters -# export E2E_CLUSTER_REGION and E2E_CLUSTER_ZONE as they're used in the cluster setup subprocess -export E2E_CLUSTER_REGION=${E2E_CLUSTER_REGION:-us-central1} -# By default we use regional clusters. -export E2E_CLUSTER_ZONE=${E2E_CLUSTER_ZONE:-} - -# Default backup regions in case of stockouts; by default we don't fall back to a different zone in the same region -readonly E2E_CLUSTER_BACKUP_REGIONS=${E2E_CLUSTER_BACKUP_REGIONS:-us-west1 us-east1} -readonly E2E_CLUSTER_BACKUP_ZONES=${E2E_CLUSTER_BACKUP_ZONES:-} - -readonly E2E_GKE_ENVIRONMENT=${E2E_GKE_ENVIRONMENT:-prod} -readonly E2E_GKE_COMMAND_GROUP=${E2E_GKE_COMMAND_GROUP:-beta} - -# Each knative repository may have a different cluster size requirement here, -# so we allow calling code to set these parameters. If they are not set we -# use some sane defaults. -readonly E2E_MIN_CLUSTER_NODES=${E2E_MIN_CLUSTER_NODES:-1} -readonly E2E_MAX_CLUSTER_NODES=${E2E_MAX_CLUSTER_NODES:-3} -readonly E2E_CLUSTER_MACHINE=${E2E_CLUSTER_MACHINE:-e2-standard-4} - -readonly E2E_BASE_NAME="k${REPO_NAME}" -readonly E2E_CLUSTER_NAME=$(build_resource_name e2e-cls) -readonly E2E_NETWORK_NAME=$(build_resource_name e2e-net) -readonly TEST_RESULT_FILE=/tmp/${E2E_BASE_NAME}-e2e-result +readonly TEST_RESULT_FILE=/tmp/${REPO_NAME}-e2e-result # Flag whether test is using a boskos GCP project IS_BOSKOS=0 @@ -71,7 +30,7 @@ function teardown_test_resources() { (( IS_BOSKOS )) && return header "Tearing down test environment" function_exists test_teardown && test_teardown - (( ! SKIP_KNATIVE_SETUP )) && function_exists knative_teardown && knative_teardown + function_exists knative_teardown && knative_teardown } # Run the given E2E tests. Assume tests are tagged e2e, unless `-tags=XXX` is passed. @@ -86,203 +45,6 @@ function go_test_e2e() { report_go_test -race -count=1 "${go_test_args[@]}" } -# Dumps the k8s api server metrics. Spins up a proxy, waits a little bit and -# dumps the metrics to ${ARTIFACTS}/k8s.metrics.txt -function dump_metrics() { - header ">> Starting kube proxy" - kubectl proxy --port=8080 & - local proxy_pid=$! - sleep 5 - header ">> Grabbing k8s metrics" - curl -s http://localhost:8080/metrics > "${ARTIFACTS}"/k8s.metrics.txt - # Clean up proxy so it doesn't interfere with job shutting down - kill $proxy_pid || true -} - -# Dump info about the test cluster. If dump_extra_cluster_info() is defined, calls it too. -# This is intended to be called when a test fails to provide debugging information. -function dump_cluster_state() { - echo "***************************************" - echo "*** E2E TEST FAILED ***" - echo "*** Start of information dump ***" - echo "***************************************" - - local output - output="${ARTIFACTS}/k8s.dump-$(basename "${E2E_SCRIPT}").txt" - echo ">>> The dump is located at ${output}" - - for crd in $(kubectl api-resources --verbs=list -o name | sort); do - local count - count="$(kubectl get "$crd" --all-namespaces --no-headers 2>/dev/null | wc -l)" - echo ">>> ${crd} (${count} objects)" - if [[ "${count}" -gt "0" ]]; then - { - echo ">>> ${crd} (${count} objects)" - - echo ">>> Listing" - kubectl get "${crd}" --all-namespaces - - echo ">>> Details" - if [[ "${crd}" == "secrets" ]]; then - echo "Secrets are ignored for security reasons" - elif [[ "${crd}" == "events" ]]; then - echo "events are ignored as making a lot of noise" - else - kubectl get "${crd}" --all-namespaces -o yaml - fi - } >> "${output}" - fi - done - - if function_exists dump_extra_cluster_state; then - echo ">>> Extra dump" >> "${output}" - dump_extra_cluster_state >> "${output}" - fi - echo "***************************************" - echo "*** E2E TEST FAILED ***" - echo "*** End of information dump ***" - echo "***************************************" -} - -# On a Prow job, save some metadata about the test for Testgrid. -function save_metadata() { - (( ! IS_PROW )) && return - local geo_key="Region" - local geo_value="${E2E_CLUSTER_REGION}" - if [[ -n "${E2E_CLUSTER_ZONE}" ]]; then - geo_key="Zone" - geo_value="${E2E_CLUSTER_REGION}-${E2E_CLUSTER_ZONE}" - fi - local cluster_version - cluster_version="$(gcloud container clusters list --project="${E2E_PROJECT_ID}" --format='value(currentMasterVersion)')" - run_kntest metadata set --key="E2E:${geo_key}" --value="${geo_value}" - run_kntest metadata set --key="E2E:Machine" --value="${E2E_CLUSTER_MACHINE}" - run_kntest metadata set --key="E2E:Version" --value="${cluster_version}" - run_kntest metadata set --key="E2E:MinNodes" --value="${E2E_MIN_CLUSTER_NODES}" - run_kntest metadata set --key="E2E:MaxNodes" --value="${E2E_MAX_CLUSTER_NODES}" -} - -# Create a test cluster with kubetest and call the current script again. -function create_test_cluster() { - # Fail fast during setup. - set -o errexit - set -o pipefail - - if function_exists cluster_setup; then - cluster_setup || fail_test "cluster setup failed" - fi - - echo "Cluster will have a minimum of ${E2E_MIN_CLUSTER_NODES} and a maximum of ${E2E_MAX_CLUSTER_NODES} nodes." - local CLUSTER_CREATION_ARGS=( - "gke" - "--create-command=${E2E_GKE_COMMAND_GROUP} container clusters create --quiet --enable-autoscaling - --min-nodes=${E2E_MIN_CLUSTER_NODES} --max-nodes=${E2E_MAX_CLUSTER_NODES} - --cluster-version=${E2E_CLUSTER_VERSION} - --scopes=cloud-platform --enable-basic-auth --no-issue-client-certificate - --no-enable-ip-alias --no-enable-autoupgrade - ${GKE_ADDONS} ${EXTRA_CLUSTER_CREATION_FLAGS[@]}" - "--environment=${E2E_GKE_ENVIRONMENT}" - "--cluster-name=${E2E_CLUSTER_NAME}" - "--num-nodes=${E2E_MIN_CLUSTER_NODES}" - "--machine-type=${E2E_CLUSTER_MACHINE}" - "--network=${E2E_NETWORK_NAME}" - --up - ) - if (( ! IS_BOSKOS )); then - CLUSTER_CREATION_ARGS+=("--gcp-project=${GCP_PROJECT}") - fi - # SSH keys are not used, but kubetest checks for their existence. - # Touch them so if they don't exist, empty files are create to satisfy the check. - mkdir -p "$HOME"/.ssh - touch "$HOME"/.ssh/google_compute_engine.pub - touch "$HOME"/.ssh/google_compute_engine - - local gcloud_project="${GCP_PROJECT}" - [[ -z "${gcloud_project}" ]] && gcloud_project="$(gcloud config get-value project)" - echo "gcloud project is ${gcloud_project}" - echo "gcloud user is $(gcloud config get-value core/account)" - (( IS_BOSKOS )) && echo "Using boskos for the test cluster" - [[ -n "${GCP_PROJECT}" ]] && echo "GCP project for test cluster is ${GCP_PROJECT}" - echo "Test script is ${E2E_SCRIPT}" - # Set arguments for this script again - local test_cmd_args="--run-tests" - (( SKIP_KNATIVE_SETUP )) && test_cmd_args+=" --skip-knative-setup" - [[ -n "${GCP_PROJECT}" ]] && test_cmd_args+=" --project ${GCP_PROJECT}" - [[ -n "${E2E_SCRIPT_CUSTOM_FLAGS[*]}" ]] && test_cmd_args+=" ${E2E_SCRIPT_CUSTOM_FLAGS[*]}" - local extra_flags=() - if (( IS_BOSKOS )); then - # Add arbitrary duration, wait for Boskos projects acquisition before error out - extra_flags+=("--boskos-acquire-timeout-seconds=1200") - elif (( ! SKIP_TEARDOWNS )); then - # Only let kubetest2 tear down the cluster if not using Boskos and teardowns are not expected to be skipped, - # it's done by Janitor if using Boskos - extra_flags+=("--down") - fi - - # Create cluster and run the tests - create_test_cluster_with_retries "${E2E_SCRIPT} ${test_cmd_args}" \ - "${CLUSTER_CREATION_ARGS[@]}" "${extra_flags[@]}" "${EXTRA_KUBETEST2_FLAGS[@]}" - local result="$?" - # Ignore any errors below, this is a best-effort cleanup and shouldn't affect the test result. - set +o errexit - function_exists cluster_teardown && cluster_teardown - echo "Artifacts were written to ${ARTIFACTS}" - echo "Test result code is ${result}" - exit "${result}" -} - -# Retry backup regions/zones if cluster creations failed due to stockout. -# Parameters: $1 - test command to run by the kubetest2 tester -# $2..$n - any other kubetest2 flags other than geo and cluster version flag. -function create_test_cluster_with_retries() { - local tester_command - IFS=' ' read -r -a tester_command <<< "$1" - local kubetest2_flags=( "${@:2}" ) - local cluster_creation_log=/tmp/${E2E_BASE_NAME}-cluster_creation-log - # zone_not_provided is a placeholder for e2e_cluster_zone to make for loop below work - local zone_not_provided="zone_not_provided" - - local e2e_cluster_regions=(${E2E_CLUSTER_REGION}) - local e2e_cluster_zones=(${E2E_CLUSTER_ZONE}) - - if [[ -n "${E2E_CLUSTER_BACKUP_ZONES}" ]]; then - e2e_cluster_zones+=(${E2E_CLUSTER_BACKUP_ZONES}) - elif [[ -n "${E2E_CLUSTER_BACKUP_REGIONS}" ]]; then - e2e_cluster_regions+=(${E2E_CLUSTER_BACKUP_REGIONS}) - e2e_cluster_zones=(${zone_not_provided}) - else - echo "No backup region/zone set, cluster creation will fail in case of stockout" - fi - - for e2e_cluster_region in "${e2e_cluster_regions[@]}"; do - for e2e_cluster_zone in "${e2e_cluster_zones[@]}"; do - E2E_CLUSTER_REGION=${e2e_cluster_region} - E2E_CLUSTER_ZONE=${e2e_cluster_zone} - [[ "${E2E_CLUSTER_ZONE}" == "${zone_not_provided}" ]] && E2E_CLUSTER_ZONE="" - local cluster_creation_zone="${E2E_CLUSTER_REGION}" - [[ -n "${E2E_CLUSTER_ZONE}" ]] && cluster_creation_zone="${E2E_CLUSTER_REGION}-${E2E_CLUSTER_ZONE}" - - header "Creating test cluster ${E2E_CLUSTER_VERSION} in ${cluster_creation_zone}" - if run_go_tool k8s-sigs.io/kubetest2 \ - kubetest2 "${kubetest2_flags[@]}" --region="${cluster_creation_zone}" \ - --test=exec -- "${tester_command[@]}" 2>&1 \ - | tee "${cluster_creation_log}"; then - return 0 - fi - # Retry if cluster creation failed because of: - # - stockout (https://github.com/knative/test-infra/issues/592) - # - latest GKE not available in this region/zone yet (https://github.com/knative/test-infra/issues/694) - [[ -z "$(grep -Fo 'does not have enough resources available to fulfill' "${cluster_creation_log}")" \ - && -z "$(grep -Fo 'ResponseError: code=400, message=No valid versions with the prefix' "${cluster_creation_log}")" \ - && -z "$(grep -Po 'ResponseError: code=400, message=Master version "[0-9a-z\-\.]+" is unsupported' "${cluster_creation_log}")" \ - && -z "$(grep -Po 'only \d+ nodes out of \d+ have registered; this is likely due to Nodes failing to start correctly' "${cluster_creation_log}")" ]] \ - && return 1 - done - done - echo "No more region/zones to try, quitting" - return 1 -} - # Setup the test cluster for running the tests. function setup_test_cluster() { # Fail fast during setup. @@ -296,14 +58,11 @@ function setup_test_cluster() { # Set the actual project the test cluster resides in # It will be a project assigned by Boskos if test is running on Prow, - # otherwise will be ${GCP_PROJECT} set up by user. + # otherwise will be ${E2E_GCP_PROJECT_ID} set up by user. E2E_PROJECT_ID="$(gcloud config get-value project)" export E2E_PROJECT_ID readonly E2E_PROJECT_ID - # Save some metadata about cluster creation for using in prow and testgrid - save_metadata - local k8s_user k8s_user=$(gcloud config get-value core/account) local k8s_cluster @@ -315,9 +74,9 @@ function setup_test_cluster() { # If cluster admin role isn't set, this is a brand new cluster # Setup the admin role and also KO_DOCKER_REPO if it is a GKE cluster if [[ -z "$(kubectl get clusterrolebinding cluster-admin-binding 2> /dev/null)" && "${k8s_cluster}" =~ ^gke_.* ]]; then - acquire_cluster_admin_role "${k8s_user}" "${E2E_CLUSTER_NAME}" "${E2E_CLUSTER_REGION}" "${E2E_CLUSTER_ZONE}" + acquire_cluster_admin_role "${k8s_user}" "${E2E_CLUSTER_NAME}" "${E2E_GKE_CLUSTER_REGION}" "${E2E_GKE_CLUSTER_ZONE}" # Incorporate an element of randomness to ensure that each run properly publishes images. - export KO_DOCKER_REPO=gcr.io/${E2E_PROJECT_ID}/${E2E_BASE_NAME}-e2e-img/${RANDOM} + export KO_DOCKER_REPO=gcr.io/${E2E_PROJECT_ID}/${REPO_NAME}-e2e-img/${RANDOM} fi # Safety checks @@ -327,8 +86,6 @@ function setup_test_cluster() { # Use default namespace for all subsequent kubectl commands in this context kubectl config set-context "${k8s_cluster}" --namespace=default - echo "- gcloud project is ${E2E_PROJECT_ID}" - echo "- gcloud user is ${k8s_user}" echo "- Cluster is ${k8s_cluster}" echo "- Docker is ${KO_DOCKER_REPO}" @@ -341,9 +98,10 @@ function setup_test_cluster() { set +o errexit set +o pipefail - if (( ! SKIP_KNATIVE_SETUP )) && function_exists knative_setup; then - # Wait for Istio installation to complete, if necessary, before calling knative_setup. - (( ! SKIP_ISTIO_ADDON )) && (wait_until_batch_job_complete istio-system || return 1) + # Wait for Istio installation to complete, if necessary, before calling knative_setup. + # TODO(chizhg): is it really needed? + (( ! SKIP_ISTIO_ADDON )) && (wait_until_batch_job_complete istio-system || return 1) + if function_exists knative_setup; then knative_setup || fail_test "Knative setup failed" fi if function_exists test_setup; then @@ -369,34 +127,30 @@ function fail_test() { exit 1 } -RUN_TESTS=0 -SKIP_KNATIVE_SETUP=0 -SKIP_ISTIO_ADDON=0 SKIP_TEARDOWNS=0 -GCP_PROJECT="" -E2E_SCRIPT="" -E2E_CLUSTER_VERSION="latest" -GKE_ADDONS="" -EXTRA_CLUSTER_CREATION_FLAGS=() -EXTRA_KUBETEST2_FLAGS=() -E2E_SCRIPT_CUSTOM_FLAGS=() +SKIP_ISTIO_ADDON=0 # Parse flags and initialize the test cluster. function initialize() { - E2E_SCRIPT="$(get_canonical_path "$0")" + local run_tests=0 + local extra_kubetest2_flags=() + local extra_cluster_creation_flags=() + local e2e_script + e2e_script="$(get_canonical_path "$0")" + local e2e_script_command=( "${e2e_script}" "--run-tests" ) cd "${REPO_ROOT_DIR}" while [[ $# -ne 0 ]]; do local parameter=$1 # Try parsing flag as a custom one. if function_exists parse_flags; then - parse_flags $@ + parse_flags "$@" local skip=$? if [[ ${skip} -ne 0 ]]; then # Skip parsed flag (and possibly argument) and continue # Also save it to it's passed through to the test script for ((i=1;i<=skip;i++)); do - E2E_SCRIPT_CUSTOM_FLAGS+=("$1") + e2e_script_command+=("$1") shift done continue @@ -404,52 +158,35 @@ function initialize() { fi # Try parsing flag as a standard one. case ${parameter} in - --run-tests) RUN_TESTS=1 ;; - --skip-knative-setup) SKIP_KNATIVE_SETUP=1 ;; + --run-tests) run_tests=1 ;; --skip-teardowns) SKIP_TEARDOWNS=1 ;; + # TODO(chizhg): remove this flag once the addons is defined as an env var. --skip-istio-addon) SKIP_ISTIO_ADDON=1 ;; *) [[ $# -ge 2 ]] || abort "missing parameter after $1" shift case ${parameter} in - --gcp-project) GCP_PROJECT=$1 ;; - --cluster-version) E2E_CLUSTER_VERSION=$1 ;; - --cluster-creation-flag) EXTRA_CLUSTER_CREATION_FLAGS+=("$1") ;; - --kubetest2-flag) EXTRA_KUBETEST2_FLAGS+=("$1") ;; + --kubetest2-flag) extra_kubetest2_flags+=("$1") ;; + --cluster-creation-flag) extra_cluster_creation_flags+=("$1") ;; *) abort "unknown option ${parameter}" ;; esac esac shift done - # Use PROJECT_ID if set, unless --gcp-project was used. - if [[ -n "${PROJECT_ID:-}" && -z "${GCP_PROJECT}" ]]; then - echo "\$PROJECT_ID is set to '${PROJECT_ID}', using it to run the tests" - GCP_PROJECT="${PROJECT_ID}" - fi - if (( ! IS_PROW )) && (( ! RUN_TESTS )) && [[ -z "${GCP_PROJECT}" ]]; then - abort "set \$PROJECT_ID or use --gcp-project to select the GCP project where the tests are run" - fi - - (( IS_PROW )) && [[ -z "${GCP_PROJECT}" ]] && IS_BOSKOS=1 + (( IS_PROW )) && [[ -z "${GCP_PROJECT_ID:-}" ]] && IS_BOSKOS=1 if (( SKIP_ISTIO_ADDON )); then - GKE_ADDONS="--addons=NodeLocalDNS" + extra_cluster_creation_flags+=("--addons=NodeLocalDNS") else - GKE_ADDONS="--addons=Istio,NodeLocalDNS" + extra_cluster_creation_flags+=("--addons=Istio,NodeLocalDNS") fi - readonly RUN_TESTS - readonly GCP_PROJECT readonly IS_BOSKOS - readonly EXTRA_CLUSTER_CREATION_FLAGS - readonly EXTRA_KUBETEST2_FLAGS - readonly SKIP_KNATIVE_SETUP readonly SKIP_TEARDOWNS - readonly GKE_ADDONS - if (( ! RUN_TESTS )); then - create_test_cluster + if (( ! run_tests )); then + create_gke_test_cluster extra_kubetest2_flags extra_cluster_creation_flags e2e_script_command else setup_test_cluster fi diff --git a/vendor/knative.dev/test-infra/scripts/infra-library.sh b/vendor/knative.dev/test-infra/scripts/infra-library.sh new file mode 100644 index 00000000000..bb702d3ca26 --- /dev/null +++ b/vendor/knative.dev/test-infra/scripts/infra-library.sh @@ -0,0 +1,242 @@ +#!/usr/bin/env bash + +# Copyright 2020 The Knative Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This is a collection of functions for infra related setups, mainly +# cluster provisioning. It doesn't do anything when called from command line. + +source $(dirname "${BASH_SOURCE[0]}")/library.sh + +# Test cluster parameters + +# Configurable parameters +export E2E_GCP_PROJECT_ID=${E2E_GCP_PROJECT_ID:-} +# export E2E_GKE_CLUSTER_REGION and E2E_GKE_CLUSTER_ZONE as they're used in the cluster setup subprocess +export E2E_GKE_CLUSTER_REGION=${E2E_GKE_CLUSTER_REGION:-us-central1} +# By default we use regional clusters. +export E2E_GKE_CLUSTER_ZONE=${E2E_GKE_CLUSTER_ZONE:-} + +# Default backup regions in case of stockouts; by default we don't fall back to a different zone in the same region +readonly E2E_GKE_CLUSTER_BACKUP_REGIONS=${E2E_GKE_CLUSTER_BACKUP_REGIONS:-us-west1 us-east1} +readonly E2E_GKE_CLUSTER_BACKUP_ZONES=${E2E_GKE_CLUSTER_BACKUP_ZONES:-} + +readonly E2E_GKE_ENVIRONMENT=${E2E_GKE_ENVIRONMENT:-prod} +readonly E2E_GKE_COMMAND_GROUP=${E2E_GKE_COMMAND_GROUP:-beta} +readonly E2E_GKE_CLUSTER_MACHINE=${E2E_GKE_CLUSTER_MACHINE:-e2-standard-4} +readonly E2E_GKE_SCOPES=${E2E_GKE_SCOPES:-cloud-platform} + +# Each knative repository may have a different cluster size requirement here, +# so we allow calling code to set these parameters. If they are not set we +# use some sane defaults. +readonly E2E_MIN_CLUSTER_NODES=${E2E_MIN_CLUSTER_NODES:-1} +readonly E2E_MAX_CLUSTER_NODES=${E2E_MAX_CLUSTER_NODES:-3} +readonly E2E_CLUSTER_VERSION=${E2E_CLUSTER_VERSION:-latest} + +readonly E2E_CLUSTER_NAME=$(build_resource_name e2e-cls) +readonly E2E_GKE_NETWORK_NAME=$(build_resource_name e2e-net) + +# Dumps the k8s api server metrics. Spins up a proxy, waits a little bit and +# dumps the metrics to ${ARTIFACTS}/k8s.metrics.txt +function dump_metrics() { + header ">> Starting kube proxy" + kubectl proxy --port=8080 & + local proxy_pid=$! + sleep 5 + header ">> Grabbing k8s metrics" + curl -s http://localhost:8080/metrics > "${ARTIFACTS}"/k8s.metrics.txt + # Clean up proxy so it doesn't interfere with job shutting down + kill $proxy_pid || true +} + +# Dump info about the test cluster. If dump_extra_cluster_info() is defined, calls it too. +# This is intended to be called when a test fails to provide debugging information. +function dump_cluster_state() { + echo "***************************************" + echo "*** E2E TEST FAILED ***" + echo "*** Start of information dump ***" + echo "***************************************" + + local output + output="${ARTIFACTS}/k8s.dump-$(basename "${E2E_SCRIPT}").txt" + echo ">>> The dump is located at ${output}" + + for crd in $(kubectl api-resources --verbs=list -o name | sort); do + local count + count="$(kubectl get "$crd" --all-namespaces --no-headers 2>/dev/null | wc -l)" + echo ">>> ${crd} (${count} objects)" + if [[ "${count}" -gt "0" ]]; then + { + echo ">>> ${crd} (${count} objects)" + + echo ">>> Listing" + kubectl get "${crd}" --all-namespaces + + echo ">>> Details" + if [[ "${crd}" == "secrets" ]]; then + echo "Secrets are ignored for security reasons" + elif [[ "${crd}" == "events" ]]; then + echo "events are ignored as making a lot of noise" + else + kubectl get "${crd}" --all-namespaces -o yaml + fi + } >> "${output}" + fi + done + + if function_exists dump_extra_cluster_state; then + echo ">>> Extra dump" >> "${output}" + dump_extra_cluster_state >> "${output}" + fi + echo "***************************************" + echo "*** E2E TEST FAILED ***" + echo "*** End of information dump ***" + echo "***************************************" +} + +# On a Prow job, save some metadata about the test for Testgrid. +function save_metadata() { + (( ! IS_PROW )) && return + local geo_key="Region" + local geo_value="${E2E_GKE_CLUSTER_REGION}" + if [[ -n "${E2E_GKE_CLUSTER_ZONE}" ]]; then + geo_key="Zone" + geo_value="${E2E_GKE_CLUSTER_REGION}-${E2E_GKE_CLUSTER_ZONE}" + fi + local cluster_version + cluster_version="$(kubectl version --short=true)" + run_kntest metadata set --key="E2E:${geo_key}" --value="${geo_value}" + run_kntest metadata set --key="E2E:Machine" --value="${E2E_GKE_CLUSTER_MACHINE}" + run_kntest metadata set --key="E2E:Version" --value="${cluster_version}" + run_kntest metadata set --key="E2E:MinNodes" --value="${E2E_MIN_CLUSTER_NODES}" + run_kntest metadata set --key="E2E:MaxNodes" --value="${E2E_MAX_CLUSTER_NODES}" +} + +# Create a GKE test cluster with kubetest2 and call the current script again. +# Parameters: $1 - extra kubetest2 flags +# $2 - extra cluster creation flags +# $3 - test command to run by the kubetest2 tester +function create_gke_test_cluster() { + # Fail fast during setup. + set -o errexit + set -o pipefail + local -n _extra_kubetest2_flags=$1 + local -n _extra_cluster_creation_flags=$2 + local -n _tester_command=$3 + + if function_exists cluster_setup; then + cluster_setup || fail_test "cluster setup failed" + fi + + echo "Cluster will have a minimum of ${E2E_MIN_CLUSTER_NODES} and a maximum of ${E2E_MAX_CLUSTER_NODES} nodes." + local _kubetest2_flags=( + "gke" + "--create-command=${E2E_GKE_COMMAND_GROUP} container clusters create --quiet --enable-autoscaling + --min-nodes=${E2E_MIN_CLUSTER_NODES} --max-nodes=${E2E_MAX_CLUSTER_NODES} + --cluster-version=${E2E_CLUSTER_VERSION} + --scopes=${E2E_GKE_SCOPES} --enable-basic-auth --no-issue-client-certificate + --no-enable-ip-alias --no-enable-autoupgrade + ${_extra_cluster_creation_flags[@]}" + "--environment=${E2E_GKE_ENVIRONMENT}" + "--cluster-name=${E2E_CLUSTER_NAME}" + "--num-nodes=${E2E_MIN_CLUSTER_NODES}" + "--machine-type=${E2E_GKE_CLUSTER_MACHINE}" + "--network=${E2E_GKE_NETWORK_NAME}" + "--ignore-gcp-ssh-key=true" + --up + ) + _kubetest2_flags+=( "${_extra_kubetest2_flags[@]}" ) + if (( ! IS_BOSKOS )); then + local gcloud_project="${E2E_GCP_PROJECT_ID}" + [[ -z "${gcloud_project}" ]] && gcloud_project="$(gcloud config get-value project)" + _kubetest2_flags+=("--project=${gcloud_project}") + echo "gcloud project is ${gcloud_project}" + else + echo "Using boskos for the test cluster" + fi + + if (( IS_BOSKOS )); then + # Add arbitrary duration, wait for Boskos projects acquisition before error out + _kubetest2_flags+=("--boskos-acquire-timeout-seconds=1200") + elif (( ! SKIP_TEARDOWNS )); then + # Only let kubetest2 tear down the cluster if not using Boskos and teardowns are not expected to be skipped, + # it's done by Janitor if using Boskos + _kubetest2_flags+=("--down") + fi + + # Create cluster and run the tests + create_gke_test_cluster_with_retries _kubetest2_flags _tester_command + local result="$?" + # Ignore any errors below, this is a best-effort cleanup and shouldn't affect the test result. + set +o errexit + set +o pipefail + function_exists cluster_teardown && cluster_teardown + echo "Artifacts were written to ${ARTIFACTS}" + echo "Test result code is ${result}" + exit "${result}" +} + +# TODO(chizhg): move this to kubetest2 gke deployer. +# Retry backup regions/zones if cluster creations failed due to stockout. +# Parameters: $1 - kubetest2 flags other than geo flag +# $2 - test command to run by the kubetest2 tester +function create_gke_test_cluster_with_retries() { + local -n kubetest2_flags=$1 + local -n tester_command=$2 + local cluster_creation_log=/tmp/${REPO_NAME}-cluster_creation-log + # zone_not_provided is a placeholder for e2e_cluster_zone to make for loop below work + local zone_not_provided="zone_not_provided" + + local e2e_cluster_regions=("${E2E_GKE_CLUSTER_REGION}") + local e2e_cluster_zones=("${E2E_GKE_CLUSTER_ZONE}") + + if [[ -n "${E2E_GKE_CLUSTER_BACKUP_ZONES}" ]]; then + e2e_cluster_zones+=("${E2E_GKE_CLUSTER_BACKUP_ZONES}") + elif [[ -n "${E2E_GKE_CLUSTER_BACKUP_REGIONS}" ]]; then + e2e_cluster_regions+=("${E2E_GKE_CLUSTER_BACKUP_REGIONS}") + e2e_cluster_zones=("${zone_not_provided}") + else + echo "No backup region/zone set, cluster creation will fail in case of stockout" + fi + + for e2e_cluster_region in "${e2e_cluster_regions[@]}"; do + for e2e_cluster_zone in "${e2e_cluster_zones[@]}"; do + E2E_GKE_CLUSTER_REGION=${e2e_cluster_region} + E2E_GKE_CLUSTER_ZONE=${e2e_cluster_zone} + [[ "${E2E_GKE_CLUSTER_ZONE}" == "${zone_not_provided}" ]] && E2E_GKE_CLUSTER_ZONE="" + local cluster_creation_zone="${E2E_GKE_CLUSTER_REGION}" + [[ -n "${E2E_GKE_CLUSTER_ZONE}" ]] && cluster_creation_zone="${E2E_GKE_CLUSTER_REGION}-${E2E_GKE_CLUSTER_ZONE}" + + header "Creating test cluster ${E2E_CLUSTER_VERSION} in ${cluster_creation_zone}" + if run_go_tool k8s-sigs.io/kubetest2 \ + kubetest2 "${kubetest2_flags[@]}" --region="${cluster_creation_zone}" \ + --test=exec -- "${tester_command[@]}" 2>&1 \ + | tee "${cluster_creation_log}"; then + # Save some metadata about cluster creation for using in prow and testgrid + save_metadata + return 0 + fi + # Retry if cluster creation failed because of: + # - stockout (https://github.com/knative/test-infra/issues/592) + # - latest GKE not available in this region/zone yet (https://github.com/knative/test-infra/issues/694) + [[ -z "$(grep -Fo 'does not have enough resources available to fulfill' "${cluster_creation_log}")" \ + && -z "$(grep -Fo 'ResponseError: code=400, message=No valid versions with the prefix' "${cluster_creation_log}")" \ + && -z "$(grep -Po 'ResponseError: code=400, message=Master version "[0-9a-z\-\.]+" is unsupported' "${cluster_creation_log}")" \ + && -z "$(grep -Po 'only \d+ nodes out of \d+ have registered; this is likely due to Nodes failing to start correctly' "${cluster_creation_log}")" ]] \ + && return 1 + done + done + echo "No more region/zones to try, quitting" + return 1 +} diff --git a/vendor/knative.dev/test-infra/scripts/library.sh b/vendor/knative.dev/test-infra/scripts/library.sh index 1267f79865b..82cc1bdf577 100644 --- a/vendor/knative.dev/test-infra/scripts/library.sh +++ b/vendor/knative.dev/test-infra/scripts/library.sh @@ -65,6 +65,22 @@ function abort() { exit 1 } +# Build a resource name based on $REPO_NAME, a suffix and $BUILD_NUMBER. +# Restricts the name length to 40 chars (the limit for resource names in GCP). +# Name will have the form $REPO_NAME-$BUILD_NUMBER. +# Parameters: $1 - name suffix +function build_resource_name() { + local prefix=${REPO_NAME}-$1 + local suffix=${BUILD_NUMBER} + # Restrict suffix length to 20 chars + if [[ -n "${suffix}" ]]; then + suffix=${suffix:${#suffix}<20?0:-20} + fi + local name="${prefix:0:20}${suffix}" + # Ensure name doesn't end with "-" + echo "${name%-}" +} + # Display a box banner. # Parameters: $1 - character to use for the box. # $2 - banner message. diff --git a/vendor/knative.dev/test-infra/scripts/presubmit-tests.sh b/vendor/knative.dev/test-infra/scripts/presubmit-tests.sh index a76f890c0bb..8545bcb48e4 100644 --- a/vendor/knative.dev/test-infra/scripts/presubmit-tests.sh +++ b/vendor/knative.dev/test-infra/scripts/presubmit-tests.sh @@ -322,15 +322,6 @@ function main() { echo ">> docker version" docker version fi - # node/pod names are important for debugging purposes, but they are missing - # after migrating from bootstrap to podutil. - # Report it here with the same logic as in bootstrap until it is fixed. - # (https://github.com/kubernetes/test-infra/blob/09bd4c6709dc64308406443f8996f90cf3b40ed1/jenkins/bootstrap.py#L588) - # TODO(chaodaiG): follow up on https://github.com/kubernetes/test-infra/blob/0fabd2ea816daa8c15d410c77a0c93c0550b283f/prow/initupload/run.go#L49 - echo ">> node name" - curl -H "Metadata-Flavor: Google" 'http://169.254.169.254/computeMetadata/v1/instance/name' 2> /dev/null - echo ">> pod name" - echo "${HOSTNAME}" fi [[ -z $1 ]] && set -- "--all-tests" diff --git a/vendor/modules.txt b/vendor/modules.txt index dcfacff1f58..63ab0ac7e85 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1028,7 +1028,7 @@ k8s.io/utils/buffer k8s.io/utils/integer k8s.io/utils/pointer k8s.io/utils/trace -# knative.dev/pkg v0.0.0-20200812224206-44c860147a87 +# knative.dev/pkg v0.0.0-20200819000613-c30ec2ffd4ec ## explicit knative.dev/pkg/apiextensions/storageversion knative.dev/pkg/apiextensions/storageversion/cmd/migrate @@ -1153,7 +1153,7 @@ knative.dev/pkg/webhook/resourcesemantics knative.dev/pkg/webhook/resourcesemantics/conversion knative.dev/pkg/webhook/resourcesemantics/defaulting knative.dev/pkg/webhook/resourcesemantics/validation -# knative.dev/test-infra v0.0.0-20200813220834-388e55a496cf +# knative.dev/test-infra v0.0.0-20200818223413-ab8738ebf9f4 ## explicit knative.dev/test-infra/scripts # sigs.k8s.io/yaml v1.2.0 From e743469c2f2550381d22f81981aa14ca24f6f6c4 Mon Sep 17 00:00:00 2001 From: Scott Nichols Date: Wed, 19 Aug 2020 11:49:55 -0700 Subject: [PATCH 2/2] remove the post install jobs for 0.18 until we know we need them. --- hack/release.sh | 19 +++++++------------ hack/update-deps.sh | 2 +- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/hack/release.sh b/hack/release.sh index ba9cbea7bed..a2461f77681 100755 --- a/hack/release.sh +++ b/hack/release.sh @@ -24,9 +24,7 @@ readonly EVENTING_CRDS_YAML="eventing-crds.yaml" readonly SUGAR_CONTROLLER_YAML="eventing-sugar-controller.yaml" readonly MT_CHANNEL_BROKER_YAML="mt-channel-broker.yaml" readonly IN_MEMORY_CHANNEL="in-memory-channel.yaml" -readonly PRE_INSTALL_V_0_16="eventing-pre-install-jobs.yaml" -readonly POST_INSTALL_V_0_16="eventing-post-install-jobs.yaml" -readonly POST_INSTALL_V_0_17="eventing-post-install-jobs.yaml" +readonly POST_INSTALL="eventing-post-install-jobs.yaml" declare -A RELEASES RELEASES=( @@ -61,16 +59,13 @@ function build_release() { # Create in memory channel yaml ko resolve ${KO_FLAGS} -f config/channels/in-memory-channel/ | "${LABEL_YAML_CMD[@]}" > "${IN_MEMORY_CHANNEL}" - # Create v0.16.0 pre-install job yaml. Upgrades Broker storage version from v1alpha1 to v1beta1. - ko resolve ${KO_FLAGS} -f config/pre-install/v0.16.0/ | "${LABEL_YAML_CMD[@]}" > "${PRE_INSTALL_V_0_16}" + local all_yamls=(${EVENTING_CORE_YAML} ${EVENTING_CRDS_YAML} ${SUGAR_CONTROLLER_YAML} ${MT_CHANNEL_BROKER_YAML} ${IN_MEMORY_CHANNEL}) - # Create v0.16.0 post-install job yaml. Cleans up old broker resources from deleted namespaced brokers. - ko resolve ${KO_FLAGS} -f config/post-install/v0.16.0/ | "${LABEL_YAML_CMD[@]}" > "${POST_INSTALL_V_0_16}" - - # Create v0.17.0 post-install job yaml. Cleans up pingsources with finalizers - ko resolve ${KO_FLAGS} -f config/post-install/v0.17.0/ | "${LABEL_YAML_CMD[@]}" > "${POST_INSTALL_V_0_17}" - - local all_yamls=(${EVENTING_CORE_YAML} ${EVENTING_CRDS_YAML} ${SUGAR_CONTROLLER_YAML} ${MT_CHANNEL_BROKER_YAML} ${IN_MEMORY_CHANNEL} ${PRE_INSTALL_V_0_16} ${POST_INSTALL_V_0_16} ${POST_INSTALL_V_0_17}) + # # Template for POST_INSTALL usage: + # # Create vX.Y.Z post-install job yaml. + # ko resolve ${KO_FLAGS} -f config/post-install/vX.Y.Z/ | "${LABEL_YAML_CMD[@]}" > "${POST_INSTALL}" + # # If used, add ${POST_INSTALL} to all_yamls, + # all_yamls+=(${POST_INSTALL}) # Assemble the release for yaml in "${!RELEASES[@]}"; do diff --git a/hack/update-deps.sh b/hack/update-deps.sh index 37fdce8489a..36c095776a9 100755 --- a/hack/update-deps.sh +++ b/hack/update-deps.sh @@ -32,7 +32,7 @@ FLOATING_DEPS=( "knative.dev/test-infra@${VERSION}" "knative.dev/pkg@${VERSION}" ) - + cd "${ROOT_DIR}" # Parse flags to determine any we should pass to dep.