From a2fffe2758160a9fbd3907a03f3d43a563716c1b Mon Sep 17 00:00:00 2001 From: Knative Prow Robot Date: Mon, 14 Mar 2022 23:17:02 -0700 Subject: [PATCH] [release-1.1] SubscriptionSpec.Delivery is now mutable (#6258) * Make SubscriptionSpec.Delivery mutable Just by creating a subscription in v0.24 and upgrading the cluster to 0.26, the webhook starts throwing errors like this: ``` admission webhook "validation.webhook.eventing.knative.dev" denied the request: validation failed: Immutable fields changed (-old +new): spec {v1.SubscriptionSpec}.Delivery.DeadLetterSink.Ref.Namespace: -: "" +: "kc-broker-v1-dlq" ``` In addition, Subscription.Spec.Delivery wasn't meant to be immutable, in fact, TriggerSpec.Spec.Delivery is mutable. Signed-off-by: Pierangelo Di Pilato * Update subscription_validation_test.go * code style Co-authored-by: Pierangelo Di Pilato Co-authored-by: Pierangelo Di Pilato --- .../messaging/v1/subscription_validation.go | 2 +- .../v1/subscription_validation_test.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pkg/apis/messaging/v1/subscription_validation.go b/pkg/apis/messaging/v1/subscription_validation.go index 7b1b82a06ba..a29363caf03 100644 --- a/pkg/apis/messaging/v1/subscription_validation.go +++ b/pkg/apis/messaging/v1/subscription_validation.go @@ -99,7 +99,7 @@ func (s *Subscription) CheckImmutableFields(ctx context.Context, original *Subsc } // Only Subscriber and Reply are mutable. - ignoreArguments := cmpopts.IgnoreFields(SubscriptionSpec{}, "Subscriber", "Reply") + ignoreArguments := cmpopts.IgnoreFields(SubscriptionSpec{}, "Subscriber", "Reply", "Delivery") if diff, err := kmp.ShortDiff(original.Spec, s.Spec, ignoreArguments); err != nil { return &apis.FieldError{ Message: "Failed to diff Subscription", diff --git a/pkg/apis/messaging/v1/subscription_validation_test.go b/pkg/apis/messaging/v1/subscription_validation_test.go index 8312c1aaadc..6f3144898f9 100644 --- a/pkg/apis/messaging/v1/subscription_validation_test.go +++ b/pkg/apis/messaging/v1/subscription_validation_test.go @@ -22,6 +22,7 @@ import ( "github.com/google/go-cmp/cmp" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" + pointer "knative.dev/pkg/ptr" eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1" "knative.dev/eventing/pkg/apis/feature" @@ -528,6 +529,23 @@ func TestSubscriptionImmutable(t *testing.T) { }, }, want: nil, + }, { + name: "valid, change delivery spec", + c: &Subscription{ + Spec: SubscriptionSpec{ + Channel: getValidChannelRef(), + Subscriber: getValidDestination(), + Delivery: &eventingduckv1.DeliverySpec{Retry: pointer.Int32(2)}, + }, + }, + og: &Subscription{ + Spec: SubscriptionSpec{ + Channel: getValidChannelRef(), + Subscriber: getValidDestination(), + Delivery: &eventingduckv1.DeliverySpec{Retry: pointer.Int32(3)}, + }, + }, + want: nil, }, { name: "Channel changed", c: &Subscription{