diff --git a/pkg/reconciler/apiserversource/apiserversource.go b/pkg/reconciler/apiserversource/apiserversource.go index ef00a49e333..3dfc32eeb27 100644 --- a/pkg/reconciler/apiserversource/apiserversource.go +++ b/pkg/reconciler/apiserversource/apiserversource.go @@ -141,13 +141,6 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, source *v1.ApiServerSour return nil } -func (r *Reconciler) FinalizeKind(ctx context.Context, source *v1.ApiServerSource) pkgreconciler.Event { - logging.FromContext(ctx).Info("Deleting source") - // Allow for eventtypes to be cleaned up - source.Status.CloudEventAttributes = []duckv1.CloudEventAttributes{} - return nil -} - func (r *Reconciler) namespacesFromSelector(src *v1.ApiServerSource) ([]string, error) { if src.Spec.NamespaceSelector == nil { return []string{src.Namespace}, nil diff --git a/pkg/reconciler/apiserversource/apiserversource_test.go b/pkg/reconciler/apiserversource/apiserversource_test.go index 691ff7ab227..dfc7d73ba15 100644 --- a/pkg/reconciler/apiserversource/apiserversource_test.go +++ b/pkg/reconciler/apiserversource/apiserversource_test.go @@ -144,12 +144,8 @@ func TestReconcile(t *testing.T) { }, WantErr: true, WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), Eventf(corev1.EventTypeWarning, "InternalError", `insufficient permissions: User system:serviceaccount:testnamespace:default cannot get, list, watch resource "namespaces" in API group "" in Namespace "testnamespace"`), }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, WithReactors: []clientgotesting.ReactionFunc{subjectAccessReviewCreateReactor(false)}, SkipNamespaceValidation: true, // SubjectAccessReview objects are cluster-scoped. }, { @@ -199,12 +195,6 @@ func TestReconcile(t *testing.T) { makeSubjectAccessReview("namespaces", "list", "default"), makeSubjectAccessReview("namespaces", "watch", "default"), }, - WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), - }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, WithReactors: []clientgotesting.ReactionFunc{subjectAccessReviewCreateReactor(true)}, SkipNamespaceValidation: true, // SubjectAccessReview objects are cluster-scoped. }, { @@ -266,12 +256,8 @@ func TestReconcile(t *testing.T) { Object: makeAvailableReceiveAdapterWithNamespaces(t, []string{"test-a", "test-b"}, false), }}, WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), Eventf(corev1.EventTypeNormal, "ApiServerSourceDeploymentUpdated", `Deployment "apiserversource-test-apiserver-source-1234" updated`), }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, WithReactors: []clientgotesting.ReactionFunc{subjectAccessReviewCreateReactor(true)}, SkipNamespaceValidation: true, // SubjectAccessReview objects are cluster-scoped. }, { @@ -336,12 +322,8 @@ func TestReconcile(t *testing.T) { Object: makeAvailableReceiveAdapterWithNamespaces(t, []string{"test-a", "test-b", "test-c"}, true), }}, WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), Eventf(corev1.EventTypeNormal, "ApiServerSourceDeploymentUpdated", `Deployment "apiserversource-test-apiserver-source-1234" updated`), }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, WithReactors: []clientgotesting.ReactionFunc{subjectAccessReviewCreateReactor(true)}, SkipNamespaceValidation: true, // SubjectAccessReview objects are cluster-scoped. }, { @@ -393,12 +375,6 @@ func TestReconcile(t *testing.T) { makeSubjectAccessReview("namespaces", "list", "default"), makeSubjectAccessReview("namespaces", "watch", "default"), }, - WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), - }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, WithReactors: []clientgotesting.ReactionFunc{subjectAccessReviewCreateReactor(true)}, SkipNamespaceValidation: true, // SubjectAccessReview objects are cluster-scoped. }, { @@ -448,12 +424,6 @@ func TestReconcile(t *testing.T) { makeSubjectAccessReview("namespaces", "list", "default"), makeSubjectAccessReview("namespaces", "watch", "default"), }, - WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), - }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, WithReactors: []clientgotesting.ReactionFunc{subjectAccessReviewCreateReactor(true)}, SkipNamespaceValidation: true, // SubjectAccessReview objects are cluster-scoped. }, { @@ -473,13 +443,9 @@ func TestReconcile(t *testing.T) { }, Key: testNS + "/" + sourceName, WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), Eventf(corev1.EventTypeWarning, "SinkNotFound", `Sink not found: {"ref":{"kind":"Channel","namespace":"testnamespace","name":"testsink","apiVersion":"messaging.knative.dev/v1"}}`), }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: rttestingv1.NewApiServerSource(sourceName, testNS, rttestingv1.WithApiServerSourceSpec(sourcesv1.ApiServerSourceSpec{ @@ -521,15 +487,11 @@ func TestReconcile(t *testing.T) { Key: testNS + "/" + sourceName, WantErr: true, WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), Eventf(corev1.EventTypeNormal, apiserversourceDeploymentCreated, "Deployment created, error:inducing failure for create deployments"), Eventf(corev1.EventTypeWarning, "InternalError", "inducing failure for create deployments"), }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: rttestingv1.NewApiServerSource(sourceName, testNS, rttestingv1.WithApiServerSourceSpec(sourcesv1.ApiServerSourceSpec{ @@ -618,12 +580,6 @@ func TestReconcile(t *testing.T) { makeSubjectAccessReview("namespaces", "list", "default"), makeSubjectAccessReview("namespaces", "watch", "default"), }, - WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), - }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, WithReactors: []clientgotesting.ReactionFunc{subjectAccessReviewCreateReactor(true)}, SkipNamespaceValidation: true, // SubjectAccessReview objects are cluster-scoped. }, { @@ -648,12 +604,8 @@ func TestReconcile(t *testing.T) { }, Key: testNS + "/" + sourceName, WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), Eventf(corev1.EventTypeNormal, "ApiServerSourceDeploymentUpdated", `Deployment "apiserversource-test-apiserver-source-1234" updated`), }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: rttestingv1.NewApiServerSource(sourceName, testNS, rttestingv1.WithApiServerSourceSpec(sourcesv1.ApiServerSourceSpec{ @@ -710,12 +662,8 @@ func TestReconcile(t *testing.T) { }, Key: testNS + "/" + sourceName, WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), Eventf(corev1.EventTypeNormal, "ApiServerSourceDeploymentUpdated", `Deployment "apiserversource-test-apiserver-source-1234" updated`), }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: rttestingv1.NewApiServerSource(sourceName, testNS, rttestingv1.WithApiServerSourceSpec(sourcesv1.ApiServerSourceSpec{ @@ -772,12 +720,8 @@ func TestReconcile(t *testing.T) { }, Key: testNS + "/" + sourceName, WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), Eventf(corev1.EventTypeNormal, "ApiServerSourceDeploymentUpdated", `Deployment "apiserversource-test-apiserver-source-1234" updated`), }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: rttestingv1.NewApiServerSource(sourceName, testNS, rttestingv1.WithApiServerSourceSpec(sourcesv1.ApiServerSourceSpec{ @@ -851,12 +795,6 @@ func TestReconcile(t *testing.T) { rttestingv1.WithApiServerSourceStatusNamespaces([]string{testNS}), ), }}, - WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), - }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, WantCreates: []runtime.Object{ makeSubjectAccessReview("namespaces", "get", "default"), makeSubjectAccessReview("namespaces", "list", "default"), @@ -1083,12 +1021,3 @@ func subjectAccessReviewCreateReactor(allowed bool) clientgotesting.ReactionFunc return false, nil, nil } } - -func patchFinalizers(name, namespace string) clientgotesting.PatchActionImpl { - action := clientgotesting.PatchActionImpl{} - action.Name = name - action.Namespace = namespace - patch := `{"metadata":{"finalizers":["apiserversources.sources.knative.dev"],"resourceVersion":""}}` - action.Patch = []byte(patch) - return action -} diff --git a/pkg/reconciler/pingsource/pingsource.go b/pkg/reconciler/pingsource/pingsource.go index ea1afae131e..9dc73e529a2 100644 --- a/pkg/reconciler/pingsource/pingsource.go +++ b/pkg/reconciler/pingsource/pingsource.go @@ -135,13 +135,6 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, source *sourcesv1.PingSo return nil } -func (r *Reconciler) FinalizeKind(ctx context.Context, source *sourcesv1.PingSource) pkgreconciler.Event { - logging.FromContext(ctx).Info("Deleting source") - // Allow for eventtypes to be cleaned up - source.Status.CloudEventAttributes = []duckv1.CloudEventAttributes{} - return nil -} - func (r *Reconciler) reconcileReceiveAdapter(ctx context.Context, source *sourcesv1.PingSource) (*appsv1.Deployment, error) { args := resources.Args{ ConfigEnvVars: r.configAcc.ToEnvVars(), diff --git a/pkg/reconciler/pingsource/pingsource_test.go b/pkg/reconciler/pingsource/pingsource_test.go index d2c099983f6..ab8aaaeda68 100644 --- a/pkg/reconciler/pingsource/pingsource_test.go +++ b/pkg/reconciler/pingsource/pingsource_test.go @@ -144,13 +144,9 @@ func TestAllCases(t *testing.T) { ), }}, WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), Eventf(corev1.EventTypeWarning, "SinkNotFound", `Sink not found: {"ref":{"kind":"Channel","namespace":"testnamespace","name":"testsink","apiVersion":"messaging.knative.dev/v1"}}`), }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, }, { Name: "sink ref has no namespace", Objects: []runtime.Object{ @@ -187,13 +183,9 @@ func TestAllCases(t *testing.T) { ), }}, WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), Eventf(corev1.EventTypeWarning, "SinkNotFound", `Sink not found: {"ref":{"kind":"Channel","namespace":"testnamespace","name":"testsink","apiVersion":"messaging.knative.dev/v1"}}`), }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, }, { Name: "error creating deployment", Objects: []runtime.Object{ @@ -216,12 +208,8 @@ func TestAllCases(t *testing.T) { }, Key: testNS + "/" + sourceName, WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), Eventf(corev1.EventTypeWarning, "InternalError", "deployments.apps \"pingsource-mt-adapter\" not found"), }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, WantErr: true, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: rtv1.NewPingSource(sourceName, testNS, @@ -283,12 +271,6 @@ func TestAllCases(t *testing.T) { rtv1.WithPingSourceStatusObservedGeneration(generation), ), }}, - WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), - }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, }, { Name: "Propagate CA certs", Objects: []runtime.Object{ @@ -339,12 +321,6 @@ func TestAllCases(t *testing.T) { rtv1.WithPingSourceStatusObservedGeneration(generation), ), }}, - WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), - }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, }, { Name: "deployment update due to env", Objects: []runtime.Object{ @@ -368,12 +344,8 @@ func TestAllCases(t *testing.T) { }, Key: testNS + "/" + sourceName, WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), Eventf(corev1.EventTypeNormal, pingSourceDeploymentUpdated, `PingSource adapter deployment updated`), }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: rtv1.NewPingSource(sourceName, testNS, rtv1.WithPingSourceSpec(sourcesv1.PingSourceSpec{ @@ -439,12 +411,6 @@ func TestAllCases(t *testing.T) { rtv1.WithPingSourceStatusObservedGeneration(generation), ), }}, - WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), - }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, }, { Name: "valid with dataBase64", Objects: []runtime.Object{ @@ -487,12 +453,6 @@ func TestAllCases(t *testing.T) { rtv1.WithPingSourceStatusObservedGeneration(generation), ), }}, - WantEvents: []string{ - Eventf(corev1.EventTypeNormal, "FinalizerUpdate", "Updated %q finalizers", sourceName), - }, - WantPatches: []clientgotesting.PatchActionImpl{ - patchFinalizers(sourceName, testNS), - }, }, } @@ -552,12 +512,3 @@ func makeAvailableMTAdapterWithDifferentEnv() *appsv1.Deployment { WithDeploymentAvailable()(ma) return ma } - -func patchFinalizers(name, namespace string) clientgotesting.PatchActionImpl { - action := clientgotesting.PatchActionImpl{} - action.Name = name - action.Namespace = namespace - patch := `{"metadata":{"finalizers":["pingsources.sources.knative.dev"],"resourceVersion":""}}` - action.Patch = []byte(patch) - return action -} diff --git a/pkg/reconciler/source/duck/duck.go b/pkg/reconciler/source/duck/duck.go index 7ca55ec48c0..932647d3bfa 100644 --- a/pkg/reconciler/source/duck/duck.go +++ b/pkg/reconciler/source/duck/duck.go @@ -41,10 +41,6 @@ import ( "knative.dev/eventing/pkg/reconciler/source/duck/resources" ) -const ( - defaultNamespace = "default" -) - type Reconciler struct { // eventingClientSet allows us to configure Eventing objects eventingClientSet clientset.Interface @@ -215,9 +211,6 @@ func (r *Reconciler) makeEventTypes(ctx context.Context, src *duckv1.Source) []v CeSchema: schemaURL, Description: description, }) - if eventType.Spec.Reference.Namespace == "" { - eventType.Spec.Reference.Namespace = defaultNamespace - } eventTypes = append(eventTypes, *eventType) } return eventTypes diff --git a/pkg/reconciler/source/duck/duck_test.go b/pkg/reconciler/source/duck/duck_test.go index 1bd6dc44458..2b8f58ef144 100644 --- a/pkg/reconciler/source/duck/duck_test.go +++ b/pkg/reconciler/source/duck/duck_test.go @@ -345,9 +345,6 @@ func makeEventType(ceType, ceSource string) *v1beta2.EventType { func makeEventTypeWithReference(ceType, ceSource string, ref *duckv1.KReference) *v1beta2.EventType { ceSourceURL, _ := apis.ParseURL(ceSource) - if ref.Namespace == "" { - ref.Namespace = "default" - } return &v1beta2.EventType{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("%x", md5.Sum([]byte(ceType+ceSource+sourceUID))), diff --git a/test/rekt/features/apiserversource/data_plane.go b/test/rekt/features/apiserversource/data_plane.go index 1f26d436b5b..eeb361058ed 100644 --- a/test/rekt/features/apiserversource/data_plane.go +++ b/test/rekt/features/apiserversource/data_plane.go @@ -309,7 +309,7 @@ func SendsEventsWithEventTypes() *feature.Feature { }) f.Requirement("ApiServerSource goes ready", apiserversource.IsReady(source)) - expectedCeTypes := sets.New(sources.ApiServerSourceEventResourceModeTypes...) + expectedCeTypes := sets.New(sources.ApiServerSourceEventReferenceModeTypes...) f.Stable("ApiServerSource as event source"). Must("delivers events on broker with URI",