diff --git a/go.mod b/go.mod index 4ed412bc18..f5727059cc 100644 --- a/go.mod +++ b/go.mod @@ -38,10 +38,10 @@ require ( require ( github.com/google/gofuzz v1.2.0 github.com/kedacore/keda/v2 v2.8.1 - knative.dev/eventing v0.37.0 + knative.dev/eventing v0.37.2 knative.dev/hack v0.0.0-20230417170854-f591fea109b3 knative.dev/pkg v0.0.0-20230418073056-dfad48eaa5d0 - knative.dev/reconciler-test v0.0.0-20230420091239-6c21623d2555 + knative.dev/reconciler-test v0.0.0-20230728072509-ca174046aede sigs.k8s.io/controller-runtime v0.12.3 ) diff --git a/go.sum b/go.sum index 8bfcc0216b..ceb4117d3f 100644 --- a/go.sum +++ b/go.sum @@ -1524,14 +1524,14 @@ k8s.io/utils v0.0.0-20200912215256-4140de9c8800/go.mod h1:jPW/WVKK9YHAvNhRxK0md/ k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2 h1:GfD9OzL11kvZN5iArC6oTS7RTj7oJOIfnislxYlqTj8= k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -knative.dev/eventing v0.37.0 h1:OtX8B9nvUSTNcbbpoNFDyeGaGU/5+aetj94i6oATpQU= -knative.dev/eventing v0.37.0/go.mod h1:62baPXiw5GPpPyV3f0GF64X7tOjc5x9cg64RAh1gjs4= +knative.dev/eventing v0.37.2 h1:izwz+ikc8S/eBlxnUX5qrWVRio7R3OJJtJnlZ3tw2OM= +knative.dev/eventing v0.37.2/go.mod h1:gLS1T97U6RCbDcDmQoDIyptJ+JntPoDnX9bhtwAG6bY= knative.dev/hack v0.0.0-20230417170854-f591fea109b3 h1:+W4WBOq83tfGXKhtv8OB/uJeYqze3zh69GKiz1ucuqk= knative.dev/hack v0.0.0-20230417170854-f591fea109b3/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q= knative.dev/pkg v0.0.0-20230418073056-dfad48eaa5d0 h1:EFQcoUo8I4bc+U3y6tR1B3ONYZSHWUdAfI7Vh7dae8g= knative.dev/pkg v0.0.0-20230418073056-dfad48eaa5d0/go.mod h1:2qWPP9Gjh9Q7ETti+WRHnBnGCSCq+6q7m3p/nmUQviE= -knative.dev/reconciler-test v0.0.0-20230420091239-6c21623d2555 h1:DpYnNF7NiSKgPIh64nwSCAsr+6a48R9DhK9nE8X/+ps= -knative.dev/reconciler-test v0.0.0-20230420091239-6c21623d2555/go.mod h1:vZihHUKPh+sMzzx2lHgkM2tKr+f/lZqMJ9O7Jw0DaYs= +knative.dev/reconciler-test v0.0.0-20230728072509-ca174046aede h1:m+oZ4iW4V2ILrTkkq1wxQYfyiiM5SopYedw8R1lm/iU= +knative.dev/reconciler-test v0.0.0-20230728072509-ca174046aede/go.mod h1:By7fsbkjKWbTmxwAs9lL1itxZI1otbhiEsAZmprEtvI= pgregory.net/rapid v0.3.3 h1:jCjBsY4ln4Atz78QoBWxUEvAHaFyNDQg9+WU62aCn1U= pgregory.net/rapid v0.3.3/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/vendor/knative.dev/eventing/pkg/utils/secret.go b/vendor/knative.dev/eventing/pkg/utils/secret.go index b8063edd9c..f3cadedf5f 100644 --- a/vendor/knative.dev/eventing/pkg/utils/secret.go +++ b/vendor/knative.dev/eventing/pkg/utils/secret.go @@ -34,6 +34,17 @@ import ( // It'll either return a pointer to the new Secret or and error indicating // why it couldn't do it. func CopySecret(corev1Input clientcorev1.CoreV1Interface, srcNS string, srcSecretName string, tgtNS string, svcAccount string) (*corev1.Secret, error) { + return CopySecretWithName(corev1Input, + srcNS, + srcSecretName, + tgtNS, + srcSecretName, /* Use same target name as source by default */ + svcAccount) +} + +// CopySecretWithName will copy a secret from one namespace into another. +// Allows for specifying target secret name. +func CopySecretWithName(corev1Input clientcorev1.CoreV1Interface, srcNS, srcSecretName, tgtNS, tgtSecretName, svcAccount string) (*corev1.Secret, error) { tgtNamespaceSvcAcct := corev1Input.ServiceAccounts(tgtNS) srcSecrets := corev1Input.Secrets(srcNS) tgtNamespaceSecrets := corev1Input.Secrets(tgtNS) @@ -54,7 +65,7 @@ func CopySecret(corev1Input clientcorev1.CoreV1Interface, srcNS string, srcSecre context.Background(), &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ - Name: srcSecretName, + Name: tgtSecretName, }, Data: srcSecret.Data, Type: srcSecret.Type, @@ -72,14 +83,14 @@ func CopySecret(corev1Input clientcorev1.CoreV1Interface, srcNS string, srcSecre } for _, secret := range tgtSvcAccount.ImagePullSecrets { - if secret.Name == srcSecretName { + if secret.Name == tgtSecretName { return newSecret, nil } } // Prevent overwriting existing imagePullSecrets - patch := `[{"op":"add","path":"/imagePullSecrets/-","value":{"name":"` + srcSecretName + `"}}]` + patch := `[{"op":"add","path":"/imagePullSecrets/-","value":{"name":"` + tgtSecretName + `"}}]` if len(tgtSvcAccount.ImagePullSecrets) == 0 { - patch = `[{"op":"add","path":"/imagePullSecrets","value":[{"name":"` + srcSecretName + `"}]}]` + patch = `[{"op":"add","path":"/imagePullSecrets","value":[{"name":"` + tgtSecretName + `"}]}]` } _, err = tgtNamespaceSvcAcct.Patch(context.Background(), svcAccount, types.JSONPatchType, []byte(patch), metav1.PatchOptions{}) diff --git a/vendor/knative.dev/eventing/test/rekt/features/channel/features.go b/vendor/knative.dev/eventing/test/rekt/features/channel/features.go index 1a6b6bf19f..a20da29960 100644 --- a/vendor/knative.dev/eventing/test/rekt/features/channel/features.go +++ b/vendor/knative.dev/eventing/test/rekt/features/channel/features.go @@ -27,11 +27,12 @@ import ( "github.com/google/uuid" duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/reconciler-test/pkg/eventshub" - "knative.dev/reconciler-test/pkg/eventshub/assert" "knative.dev/reconciler-test/pkg/feature" "knative.dev/reconciler-test/pkg/manifest" "knative.dev/reconciler-test/pkg/resources/service" + "knative.dev/reconciler-test/pkg/eventshub/assert" + eventasssert "knative.dev/reconciler-test/pkg/eventshub/assert" "knative.dev/eventing/test/rekt/resources/channel" @@ -88,7 +89,7 @@ func ChannelChain(length int, createSubscriberFn func(ref *duckv1.KReference, ur func DeadLetterSink(createSubscriberFn func(ref *duckv1.KReference, uri string) manifest.CfgFn) *feature.Feature { f := feature.NewFeature() sink := feature.MakeRandomK8sName("sink") - failer := feature.MakeK8sNamePrefix("failer") + failer := feature.MakeRandomK8sName("failer") cs := feature.MakeRandomK8sName("containersource") name := feature.MakeRandomK8sName("channel") sub := feature.MakeRandomK8sName("subscription") @@ -118,7 +119,7 @@ func DeadLetterSink(createSubscriberFn func(ref *duckv1.KReference, uri string) func DeadLetterSinkGenericChannel(createSubscriberFn func(ref *duckv1.KReference, uri string) manifest.CfgFn) *feature.Feature { f := feature.NewFeature() sink := feature.MakeRandomK8sName("sink") - failer := feature.MakeK8sNamePrefix("failer") + failer := feature.MakeRandomK8sName("failer") cs := feature.MakeRandomK8sName("containersource") name := feature.MakeRandomK8sName("channel") sub := feature.MakeRandomK8sName("subscription") diff --git a/vendor/knative.dev/reconciler-test/pkg/environment/magic.go b/vendor/knative.dev/reconciler-test/pkg/environment/magic.go index af1e5ffd31..8be20535a2 100644 --- a/vendor/knative.dev/reconciler-test/pkg/environment/magic.go +++ b/vendor/knative.dev/reconciler-test/pkg/environment/magic.go @@ -128,6 +128,11 @@ func (mr *MagicEnvironment) Finish() { var result milestone.Result = unknownResult{} if mr.managedT != nil { result = mr.managedT + if !result.Failed() { + if err := feature.DeleteResources(mr.c, mr.managedT, mr.References()); err != nil { + mr.managedT.Fatal(err) + } + } } if mr.milestones != nil { mr.milestones.Finished(result) diff --git a/vendor/knative.dev/reconciler-test/pkg/eventshub/102-service.yaml b/vendor/knative.dev/reconciler-test/pkg/eventshub/102-service.yaml index c3d58ba093..b0400e7e94 100644 --- a/vendor/knative.dev/reconciler-test/pkg/eventshub/102-service.yaml +++ b/vendor/knative.dev/reconciler-test/pkg/eventshub/102-service.yaml @@ -22,5 +22,6 @@ spec: app: eventshub-{{ .name }} ports: - protocol: TCP + name: http port: 80 targetPort: 8080 diff --git a/vendor/knative.dev/reconciler-test/pkg/feature/feature.go b/vendor/knative.dev/reconciler-test/pkg/feature/feature.go index bfd26b75b7..db86f85af5 100644 --- a/vendor/knative.dev/reconciler-test/pkg/feature/feature.go +++ b/vendor/knative.dev/reconciler-test/pkg/feature/feature.go @@ -195,17 +195,21 @@ func (f *Feature) References() []corev1.ObjectReference { // DeleteResources delete all known resources to the Feature registered // via `Reference`. // -// It doesn't fail when a referenced resource couldn't be deleted. -// Use References to get the undeleted resources. -// // Expected to be used as a StepFn. func (f *Feature) DeleteResources(ctx context.Context, t T) { + if err := DeleteResources(ctx, t, f.References()); err != nil { + t.Fatal(err) + } +} + +func DeleteResources(ctx context.Context, t T, refs []corev1.ObjectReference) error { dc := dynamicclient.Get(ctx) - for _, ref := range f.References() { + + for _, ref := range refs { gv, err := schema.ParseGroupVersion(ref.APIVersion) if err != nil { - t.Fatalf("Could not parse GroupVersion for %+v", ref.APIVersion) + return fmt.Errorf("could not parse GroupVersion for %+v", ref.APIVersion) } resource := apis.KindToResource(gv.WithKind(ref.Kind)) @@ -223,15 +227,11 @@ func (f *Feature) DeleteResources(ctx context.Context, t T) { } } - // refFailedDeletion keeps the failed to delete resources. - var refFailedDeletion []corev1.ObjectReference - err := wait.Poll(time.Second, 4*time.Minute, func() (bool, error) { - refFailedDeletion = nil // Reset failed deletion. - for _, ref := range f.References() { + for _, ref := range refs { gv, err := schema.ParseGroupVersion(ref.APIVersion) if err != nil { - t.Fatalf("Could not parse GroupVersion for %+v", ref.APIVersion) + return false, fmt.Errorf("could not parse GroupVersion for %+v", ref.APIVersion) } resource := apis.KindToResource(gv.WithKind(ref.Kind)) @@ -244,7 +244,7 @@ func (f *Feature) DeleteResources(ctx context.Context, t T) { continue } if err != nil { - refFailedDeletion = append(refFailedDeletion, ref) + LogReferences(ref)(ctx, t) return false, fmt.Errorf("failed to get resource %+v %s/%s: %w", resource, ref.Namespace, ref.Name, err) } @@ -255,14 +255,10 @@ func (f *Feature) DeleteResources(ctx context.Context, t T) { return true, nil }) if err != nil { - LogReferences(refFailedDeletion...)(ctx, t) - t.Fatalf("failed to wait for resources to be deleted: %v", err) + return fmt.Errorf("failed to wait for resources to be deleted: %v", err) } - f.refsMu.Lock() - defer f.refsMu.Unlock() - - f.refs = refFailedDeletion + return nil } var ( diff --git a/vendor/knative.dev/reconciler-test/pkg/milestone/emitter_tracing.go b/vendor/knative.dev/reconciler-test/pkg/milestone/emitter_tracing.go index 2c07b853bb..7680102cd8 100644 --- a/vendor/knative.dev/reconciler-test/pkg/milestone/emitter_tracing.go +++ b/vendor/knative.dev/reconciler-test/pkg/milestone/emitter_tracing.go @@ -21,6 +21,7 @@ import ( "encoding/json" "fmt" "io/ioutil" + "log" "net/http" "os" "path/filepath" @@ -29,8 +30,8 @@ import ( kubeclient "knative.dev/pkg/client/injection/kube/client" "knative.dev/pkg/logging" "knative.dev/pkg/test/helpers" - "knative.dev/pkg/test/prow" "knative.dev/pkg/test/zipkin" + "knative.dev/reconciler-test/pkg/feature" ) @@ -111,7 +112,7 @@ func (e tracingEmitter) getTracesForNamespace(ns string) ([]byte, error) { } func (e tracingEmitter) exportTrace(trace []byte, fileName string) error { - tracesDir := filepath.Join(prow.GetLocalArtifactsDir(), "traces") + tracesDir := filepath.Join(getLocalArtifactsDir(), "traces") if err := helpers.CreateDir(tracesDir); err != nil { return fmt.Errorf("error creating directory %q: %w", tracesDir, err) } @@ -129,6 +130,17 @@ func (e tracingEmitter) exportTrace(trace []byte, fileName string) error { return nil } +// getLocalArtifactsDir gets the artifacts directory where prow looks for artifacts. +// By default, it will look at the env var ARTIFACTS. +func getLocalArtifactsDir() string { + dir := os.Getenv("ARTIFACTS") + if dir == "" { + dir = "artifacts" + log.Printf("Env variable ARTIFACTS not set. Using %s instead.", dir) + } + return dir +} + // findTrace fetches tracing endpoint and retrieves Zipkin traces matching the annotation query. func (e tracingEmitter) findTrace(annotationQuery string) ([]byte, error) { trace := []byte("{}") diff --git a/vendor/modules.txt b/vendor/modules.txt index a852aec5c7..304ebecb9d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1231,7 +1231,7 @@ k8s.io/utils/net k8s.io/utils/pointer k8s.io/utils/strings/slices k8s.io/utils/trace -# knative.dev/eventing v0.37.0 +# knative.dev/eventing v0.37.2 ## explicit; go 1.19 knative.dev/eventing/cmd/event_display knative.dev/eventing/cmd/heartbeats @@ -1494,7 +1494,7 @@ knative.dev/pkg/webhook/json knative.dev/pkg/webhook/resourcesemantics knative.dev/pkg/webhook/resourcesemantics/defaulting knative.dev/pkg/webhook/resourcesemantics/validation -# knative.dev/reconciler-test v0.0.0-20230420091239-6c21623d2555 +# knative.dev/reconciler-test v0.0.0-20230728072509-ca174046aede ## explicit; go 1.18 knative.dev/reconciler-test/cmd/eventshub knative.dev/reconciler-test/pkg/environment