Repository: knative-sandbox/eventing-kafka
Pull request #990 (2021-11-15 12:18:24)

[release-0.26] [Channel] Set defaults of spec.delivery
This is a cherry-pick of https://github.com/knative-sandbox/eventing-kafka/pull/895

**Release Note**

<!--
🗒️ If this change has user-visible impact, write a release note in the block
below. Include the string "action required" if additional action is required of
users switching to the new release, for example in case of a breaking change.

Write as if you are speaking to users, not other Knative contributors. If this
change has no user-visible impact, no release-note is needed.
-->

```release-note
The field `spec.delivery.deadLetterSink.ref.namespace` for KafkaChannel if not specified is defaulted to `metadata.namespace`.
```

knative-prow-robot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative-sandbox/eventing-kafka/pull/990#" title="Author self-approved">pierDipi</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **dprotaso** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @dprotaso` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative-sandbox%2Feventing-kafka).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/knative-sandbox/eventing-kafka/blob/release-0.26/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["dprotaso"]} -->
pierDipi: /assign @matzew 
codecov[bot]: # [Codecov](https://codecov.io/gh/knative-sandbox/eventing-kafka/pull/990?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox) Report
> :exclamation: No coverage uploaded for pull request base (`release-0.26@40770a4`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox#section-missing-base-commit).
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/knative-sandbox/eventing-kafka/pull/990/graphs/tree.svg?width=650&height=150&src=pr&token=W765CT93QC&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox)](https://codecov.io/gh/knative-sandbox/eventing-kafka/pull/990?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox)

```diff
@@               Coverage Diff               @@
##             release-0.26     #990   +/-   ##
===============================================
  Coverage                ?   74.12%           
===============================================
  Files                   ?      152           
  Lines                   ?     6960           
  Branches                ?        0           
===============================================
  Hits                    ?     5159           
  Misses                  ?     1508           
  Partials                ?      293           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/knative-sandbox/eventing-kafka/pull/990?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/knative-sandbox/eventing-kafka/pull/990?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox). Last update [40770a4...70824c0](https://codecov.io/gh/knative-sandbox/eventing-kafka/pull/990?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox).

knative-prow-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative-sandbox/eventing-kafka/pull/990#pullrequestreview-807179404" title="Approved">matzew</a>*, *<a href="https://github.com/knative-sandbox/eventing-kafka/pull/990#" title="Author self-approved">pierDipi</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative-sandbox%2Feventing-kafka).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/knative-sandbox/eventing-kafka/blob/release-0.26/OWNERS)~~ [matzew]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/.gitignore b/.gitignore
index 38cca5ec8..e112dc085 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
 *.iml
 .idea/
 .run/
+.vscode/
 
 # System Files
 .DS_Store
diff --git a/config/channel/consolidated/roles/channelable-manipulator-clusterrole.yaml b/config/channel/consolidated/roles/channelable-manipulator-clusterrole.yaml
index a927bf79f..fa4e72094 100644
--- a/config/channel/consolidated/roles/channelable-manipulator-clusterrole.yaml
+++ b/config/channel/consolidated/roles/channelable-manipulator-clusterrole.yaml
@@ -33,3 +33,5 @@ rules:
       - watch
       - update
       - patch
+      - delete
+
diff --git a/config/channel/distributed/100-channelable-manipulator-clusterrole.yaml b/config/channel/distributed/100-channelable-manipulator-clusterrole.yaml
index 5f0246a26..5fbffd8eb 100644
--- a/config/channel/distributed/100-channelable-manipulator-clusterrole.yaml
+++ b/config/channel/distributed/100-channelable-manipulator-clusterrole.yaml
@@ -32,3 +32,4 @@ rules:
   - watch
   - update
   - patch
+  - delete
diff --git a/go.mod b/go.mod
index fac78eca4..5c6bfbcc7 100644
--- a/go.mod
+++ b/go.mod
@@ -34,7 +34,7 @@ require (
 	k8s.io/client-go v0.21.4
 	k8s.io/utils v0.0.0-20201110183641-67b214c5f920
 	knative.dev/control-protocol v0.0.0-20210916135140-1d339f445c6e
-	knative.dev/eventing v0.26.0
+	knative.dev/eventing v0.26.2-0.20211115113755-3709c3ddbbf5
 	knative.dev/hack v0.0.0-20210806075220-815cd312d65c
 	knative.dev/pkg v0.0.0-20210919202233-5ae482141474
 	knative.dev/reconciler-test v0.0.0-20210915181908-49fac7555086
diff --git a/go.sum b/go.sum
index 725612240..bcb9491f2 100644
--- a/go.sum
+++ b/go.sum
@@ -1190,8 +1190,8 @@ k8s.io/utils v0.0.0-20201110183641-67b214c5f920 h1:CbnUZsM497iRC5QMVkHwyl8s2tB3g
 k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
 knative.dev/control-protocol v0.0.0-20210916135140-1d339f445c6e h1:xmXtgWZL0XWp5J5qDK3Ln/HLBCV5LBqGw6lTuEP2al4=
 knative.dev/control-protocol v0.0.0-20210916135140-1d339f445c6e/go.mod h1:OFhIUB64BOJ/qh4DHiM3nHJhZ8cAdD569gW6Srpk5UU=
-knative.dev/eventing v0.26.0 h1:osDUdav7S0FuChN0onfwL5cEcsdb54Kee2hjAPMpY7o=
-knative.dev/eventing v0.26.0/go.mod h1:6tTam0lsPtBSJHJ63/195obj2VAHlTZZB7TLiBSeqk0=
+knative.dev/eventing v0.26.2-0.20211115113755-3709c3ddbbf5 h1:rEqxh96E53L4yoEL2A+eubPDB3IwT90ZtdLU/+Y5cb0=
+knative.dev/eventing v0.26.2-0.20211115113755-3709c3ddbbf5/go.mod h1:6tTam0lsPtBSJHJ63/195obj2VAHlTZZB7TLiBSeqk0=
 knative.dev/hack v0.0.0-20210806075220-815cd312d65c h1:nOXoDWAAItwr4o0dp3nHr6skgpVD4IvME/UX84YNl5k=
 knative.dev/hack v0.0.0-20210806075220-815cd312d65c/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
 knative.dev/hack/schema v0.0.0-20210806075220-815cd312d65c/go.mod h1:ffjwmdcrH5vN3mPhO8RrF2KfNnbHeCE2C60A+2cv3U0=
diff --git a/pkg/apis/bindings/v1beta1/zz_generated.deepcopy.go b/pkg/apis/bindings/v1beta1/zz_generated.deepcopy.go
index 97ccf09ff..98d9c2412 100644
--- a/pkg/apis/bindings/v1beta1/zz_generated.deepcopy.go
+++ b/pkg/apis/bindings/v1beta1/zz_generated.deepcopy.go
@@ -1,3 +1,4 @@
+//go:build !ignore_autogenerated
 // +build !ignore_autogenerated
 
 /*
diff --git a/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go
index 4a972bfc0..e4e2f4fad 100644
--- a/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go
@@ -1,3 +1,4 @@
+//go:build !ignore_autogenerated
 // +build !ignore_autogenerated
 
 /*
diff --git a/pkg/apis/kafka/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/kafka/v1alpha1/zz_generated.deepcopy.go
index 3b9dfc800..fa3023c4f 100644
--- a/pkg/apis/kafka/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/kafka/v1alpha1/zz_generated.deepcopy.go
@@ -1,3 +1,4 @@
+//go:build !ignore_autogenerated
 // +build !ignore_autogenerated
 
 /*
diff --git a/pkg/apis/messaging/v1beta1/kafka_channel_defaults.go b/pkg/apis/messaging/v1beta1/kafka_channel_defaults.go
index 68a82bea7..2748ccfc4 100644
--- a/pkg/apis/messaging/v1beta1/kafka_channel_defaults.go
+++ b/pkg/apis/messaging/v1beta1/kafka_channel_defaults.go
@@ -20,6 +20,7 @@ import (
 	"context"
 
 	"knative.dev/eventing/pkg/apis/messaging"
+	"knative.dev/pkg/apis"
 
 	"knative.dev/eventing-kafka/pkg/common/constants"
 )
@@ -38,6 +39,7 @@ func (kc *KafkaChannel) SetDefaults(ctx context.Context) {
 		kc.Annotations[messaging.SubscribableDuckVersionAnnotation] = "v1"
 	}
 
+	ctx = apis.WithinParent(ctx, kc.ObjectMeta)
 	kc.Spec.SetDefaults(ctx)
 }
 
@@ -51,4 +53,5 @@ func (kcs *KafkaChannelSpec) SetDefaults(ctx context.Context) {
 	if len(kcs.RetentionDuration) <= 0 {
 		kcs.RetentionDuration = constants.DefaultRetentionISO8601Duration
 	}
+	kcs.Delivery.SetDefaults(ctx)
 }
diff --git a/pkg/apis/messaging/v1beta1/zz_generated.deepcopy.go b/pkg/apis/messaging/v1beta1/zz_generated.deepcopy.go
index 1a36f8324..15d5b34c5 100644
--- a/pkg/apis/messaging/v1beta1/zz_generated.deepcopy.go
+++ b/pkg/apis/messaging/v1beta1/zz_generated.deepcopy.go
@@ -1,3 +1,4 @@
+//go:build !ignore_autogenerated
 // +build !ignore_autogenerated
 
 /*
diff --git a/pkg/apis/sources/v1beta1/zz_generated.deepcopy.go b/pkg/apis/sources/v1beta1/zz_generated.deepcopy.go
index f494920ef..72294c409 100644
--- a/pkg/apis/sources/v1beta1/zz_generated.deepcopy.go
+++ b/pkg/apis/sources/v1beta1/zz_generated.deepcopy.go
@@ -1,3 +1,4 @@
+//go:build !ignore_autogenerated
 // +build !ignore_autogenerated
 
 /*
diff --git a/vendor/knative.dev/eventing/pkg/apis/config/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/config/zz_generated.deepcopy.go
index 4fd7c636f..cc31958e7 100644
--- a/vendor/knative.dev/eventing/pkg/apis/config/zz_generated.deepcopy.go
+++ b/vendor/knative.dev/eventing/pkg/apis/config/zz_generated.deepcopy.go
@@ -1,3 +1,4 @@
+//go:build !ignore_autogenerated
 // +build !ignore_autogenerated
 
 /*
diff --git a/vendor/knative.dev/eventing/pkg/apis/duck/v1/delivery_defaults.go b/vendor/knative.dev/eventing/pkg/apis/duck/v1/delivery_defaults.go
new file mode 100644
index 000000000..b06c792ef
--- /dev/null
+++ b/vendor/knative.dev/eventing/pkg/apis/duck/v1/delivery_defaults.go
@@ -0,0 +1,28 @@
+/*
+Copyright 2021 The Knative Authors
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1
+
+import "context"
+
+func (ds *DeliverySpec) SetDefaults(ctx context.Context) {
+	if ds == nil {
+		return
+	}
+	if ds.DeadLetterSink != nil {
+		ds.DeadLetterSink.SetDefaults(ctx)
+	}
+}
diff --git a/vendor/knative.dev/eventing/pkg/apis/duck/v1/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/duck/v1/zz_generated.deepcopy.go
index 0501d0e60..c96550411 100644
--- a/vendor/knative.dev/eventing/pkg/apis/duck/v1/zz_generated.deepcopy.go
+++ b/vendor/knative.dev/eventing/pkg/apis/duck/v1/zz_generated.deepcopy.go
@@ -1,3 +1,4 @@
+//go:build !ignore_autogenerated
 // +build !ignore_autogenerated
 
 /*
diff --git a/vendor/knative.dev/eventing/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go
index 175fbad98..7a0e6e05e 100644
--- a/vendor/knative.dev/eventing/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go
+++ b/vendor/knative.dev/eventing/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go
@@ -1,3 +1,4 @@
+//go:build !ignore_autogenerated
 // +build !ignore_autogenerated
 
 /*
diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1/broker_defaults.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1/broker_defaults.go
index 468964bb6..e101713e7 100644
--- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1/broker_defaults.go
+++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1/broker_defaults.go
@@ -21,9 +21,10 @@ import (
 
 	eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1"
 
+	"knative.dev/pkg/apis"
+
 	"knative.dev/eventing/pkg/apis/config"
 	"knative.dev/eventing/pkg/apis/eventing"
-	"knative.dev/pkg/apis"
 )
 
 func (b *Broker) SetDefaults(ctx context.Context) {
@@ -53,4 +54,5 @@ func (bs *BrokerSpec) SetDefaults(ctx context.Context) {
 	if bs.Config != nil {
 		bs.Config.SetDefaults(ctx)
 	}
+	bs.Delivery.SetDefaults(ctx)
 }
diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1/trigger_defaults.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1/trigger_defaults.go
index 4c90811f3..1dde6bab9 100644
--- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1/trigger_defaults.go
+++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1/trigger_defaults.go
@@ -39,6 +39,7 @@ func (ts *TriggerSpec) SetDefaults(ctx context.Context) {
 	}
 	// Default the Subscriber namespace
 	ts.Subscriber.SetDefaults(ctx)
+	ts.Delivery.SetDefaults(ctx)
 }
 
 func setLabels(t *Trigger) {
diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1/zz_generated.deepcopy.go
index 908b4e354..f14dd7afa 100644
--- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1/zz_generated.deepcopy.go
+++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1/zz_generated.deepcopy.go
@@ -1,3 +1,4 @@
+//go:build !ignore_autogenerated
 // +build !ignore_autogenerated
 
 /*
diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/zz_generated.deepcopy.go
index f50a3b144..e24968fcb 100644
--- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/zz_generated.deepcopy.go
+++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/zz_generated.deepcopy.go
@@ -1,3 +1,4 @@
+//go:build !ignore_autogenerated
 // +build !ignore_autogenerated
 
 /*
diff --git a/vendor/knative.dev/eventing/pkg/apis/flows/v1/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/flows/v1/zz_generated.deepcopy.go
index 2e550d061..ecc465859 100644
--- a/vendor/knative.dev/eventing/pkg/apis/flows/v1/zz_generated.deepcopy.go
+++ b/vendor/knative.dev/eventing/pkg/apis/flows/v1/zz_generated.deepcopy.go
@@ -1,3 +1,4 @@
+//go:build !ignore_autogenerated
 // +build !ignore_autogenerated
 
 /*
diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/config/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/messaging/config/zz_generated.deepcopy.go
index 50ae7673f..4f9f9c099 100644
--- a/vendor/knative.dev/eventing/pkg/apis/messaging/config/zz_generated.deepcopy.go
+++ b/vendor/knative.dev/eventing/pkg/apis/messaging/config/zz_generated.deepcopy.go
@@ -1,3 +1,4 @@
+//go:build !ignore_autogenerated
 // +build !ignore_autogenerated
 
 /*
diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1/channel_defaults.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1/channel_defaults.go
index 82746cdd4..682e4d171 100644
--- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1/channel_defaults.go
+++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1/channel_defaults.go
@@ -19,9 +19,10 @@ package v1
 import (
 	"context"
 
+	"knative.dev/pkg/apis"
+
 	"knative.dev/eventing/pkg/apis/messaging"
 	"knative.dev/eventing/pkg/apis/messaging/config"
-	"knative.dev/pkg/apis"
 )
 
 func (c *Channel) SetDefaults(ctx context.Context) {
@@ -48,6 +49,7 @@ func (cs *ChannelSpec) SetDefaults(ctx context.Context) {
 			c.Spec,
 		}
 	}
+	cs.Delivery.SetDefaults(ctx)
 }
 
 // ChannelDefaulter sets the default Channel CRD and Arguments on Channels that do not
diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1/channel_validation.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1/channel_validation.go
index 8220d6515..5f0a10b4c 100644
--- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1/channel_validation.go
+++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1/channel_validation.go
@@ -49,6 +49,13 @@ func (cs *ChannelSpec) Validate(ctx context.Context) *apis.FieldError {
 	if len(cs.SubscribableSpec.Subscribers) > 0 {
 		errs = errs.Also(apis.ErrDisallowedFields("subscribers").ViaField("subscribable"))
 	}
+
+	if cs.Delivery != nil {
+		if fe := cs.Delivery.Validate(ctx); fe != nil {
+			errs = errs.Also(fe.ViaField("delivery"))
+		}
+	}
+
 	return errs
 }
 
diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1/in_memory_channel_defaults.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1/in_memory_channel_defaults.go
index a081d6bb6..a3f3bedff 100644
--- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1/in_memory_channel_defaults.go
+++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1/in_memory_channel_defaults.go
@@ -19,6 +19,8 @@ package v1
 import (
 	"context"
 
+	"knative.dev/pkg/apis"
+
 	"knative.dev/eventing/pkg/apis/messaging"
 )
 
@@ -35,9 +37,10 @@ func (imc *InMemoryChannel) SetDefaults(ctx context.Context) {
 		imc.Annotations[messaging.SubscribableDuckVersionAnnotation] = "v1"
 	}
 
+	ctx = apis.WithinParent(ctx, imc.ObjectMeta)
 	imc.Spec.SetDefaults(ctx)
 }
 
 func (imcs *InMemoryChannelSpec) SetDefaults(ctx context.Context) {
-	// TODO: Nothing to default here...
+	imcs.Delivery.SetDefaults(ctx)
 }
diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1/subscription_defaults.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1/subscription_defaults.go
index 2beb73d00..0e894fc63 100644
--- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1/subscription_defaults.go
+++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1/subscription_defaults.go
@@ -18,10 +18,21 @@ package v1
 
 import (
 	"context"
+
+	"knative.dev/pkg/apis"
 )
 
 func (s *Subscription) SetDefaults(ctx context.Context) {
+	if s == nil {
+		return
+	}
+	ctx = apis.WithinParent(ctx, s.ObjectMeta)
 	s.Spec.SetDefaults(ctx)
 }
 
-func (ss *SubscriptionSpec) SetDefaults(ctx context.Context) {}
+func (ss *SubscriptionSpec) SetDefaults(ctx context.Context) {
+	if ss == nil {
+		return
+	}
+	ss.Delivery.SetDefaults(ctx)
+}
diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1/subscription_validation.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1/subscription_validation.go
index 93bcdf8c0..033654529 100644
--- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1/subscription_validation.go
+++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1/subscription_validation.go
@@ -68,6 +68,12 @@ func (ss *SubscriptionSpec) Validate(ctx context.Context) *apis.FieldError {
 		}
 	}
 
+	if ss.Delivery != nil {
+		if fe := ss.Delivery.Validate(ctx); fe != nil {
+			errs = errs.Also(fe.ViaField("delivery"))
+		}
+	}
+
 	return errs
 }
 
diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1/zz_generated.deepcopy.go
index 752f11d6e..bc0dc043c 100644
--- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1/zz_generated.deepcopy.go
+++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1/zz_generated.deepcopy.go
@@ -1,3 +1,4 @@
+//go:build !ignore_autogenerated
 // +build !ignore_autogenerated
 
 /*
diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1/zz_generated.deepcopy.go
index 62c833778..3d8878ca5 100644
--- a/vendor/knative.dev/eventing/pkg/apis/sources/v1/zz_generated.deepcopy.go
+++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1/zz_generated.deepcopy.go
@@ -1,3 +1,4 @@
+//go:build !ignore_autogenerated
 // +build !ignore_autogenerated
 
 /*
diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1beta2/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1beta2/zz_generated.deepcopy.go
index 5326d83b3..86b4e093a 100644
--- a/vendor/knative.dev/eventing/pkg/apis/sources/v1beta2/zz_generated.deepcopy.go
+++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1beta2/zz_generated.deepcopy.go
@@ -1,3 +1,4 @@
+//go:build !ignore_autogenerated
 // +build !ignore_autogenerated
 
 /*
diff --git a/vendor/modules.txt b/vendor/modules.txt
index a69d63662..5d9002d1a 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -1109,7 +1109,7 @@ knative.dev/control-protocol/pkg/message
 knative.dev/control-protocol/pkg/network
 knative.dev/control-protocol/pkg/reconciler
 knative.dev/control-protocol/pkg/service
-# knative.dev/eventing v0.26.0
+# knative.dev/eventing v0.26.2-0.20211115113755-3709c3ddbbf5
 ## explicit
 knative.dev/eventing/pkg/adapter/v2
 knative.dev/eventing/pkg/adapter/v2/test


Test patch:
diff --git a/pkg/apis/messaging/v1beta1/kafka_channel_defaults_test.go b/pkg/apis/messaging/v1beta1/kafka_channel_defaults_test.go
index 9e5092c4c..05ed4bfc7 100644
--- a/pkg/apis/messaging/v1beta1/kafka_channel_defaults_test.go
+++ b/pkg/apis/messaging/v1beta1/kafka_channel_defaults_test.go
@@ -20,6 +20,9 @@ import (
 	"github.com/google/go-cmp/cmp"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 
+	eventingduck "knative.dev/eventing/pkg/apis/duck/v1"
+	duck "knative.dev/pkg/apis/duck/v1"
+
 	"knative.dev/eventing-kafka/pkg/common/constants"
 )
 
@@ -101,6 +104,55 @@ func TestKafkaChannelDefaults(t *testing.T) {
 				},
 			},
 		},
+		"delivery.deadLetterSink.ref.namespace not set": {
+			initial: KafkaChannel{
+				ObjectMeta: metav1.ObjectMeta{
+					Namespace:   "custom",
+					Name:        "ch",
+					Annotations: map[string]string{"messaging.knative.dev/subscribable": "v1"},
+				},
+				Spec: KafkaChannelSpec{
+					NumPartitions:     testNumPartitions,
+					ReplicationFactor: testReplicationFactor,
+					RetentionDuration: constants.DefaultRetentionISO8601Duration,
+					ChannelableSpec: eventingduck.ChannelableSpec{
+						Delivery: &eventingduck.DeliverySpec{
+							DeadLetterSink: &duck.Destination{
+								Ref: &duck.KReference{
+									APIVersion: "v1",
+									Name:       "svc",
+									Kind:       "Service",
+								},
+							},
+						},
+					},
+				},
+			},
+			expected: KafkaChannel{
+				ObjectMeta: metav1.ObjectMeta{
+					Namespace:   "custom",
+					Name:        "ch",
+					Annotations: map[string]string{"messaging.knative.dev/subscribable": "v1"},
+				},
+				Spec: KafkaChannelSpec{
+					NumPartitions:     testNumPartitions,
+					ReplicationFactor: testReplicationFactor,
+					RetentionDuration: constants.DefaultRetentionISO8601Duration,
+					ChannelableSpec: eventingduck.ChannelableSpec{
+						Delivery: &eventingduck.DeliverySpec{
+							DeadLetterSink: &duck.Destination{
+								Ref: &duck.KReference{
+									APIVersion: "v1",
+									Name:       "svc",
+									Namespace:  "custom",
+									Kind:       "Service",
+								},
+							},
+						},
+					},
+				},
+			},
+		},
 	}
 	for n, tc := range testCases {
 		t.Run(n, func(t *testing.T) {