From 93c6d56a34327cb0def398f8c58e2303a5ef3c8a Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Mon, 20 Sep 2021 11:32:54 -0700 Subject: [PATCH 1/2] Remove v1.DeliveryStatus, which was unused outside of `pkg/apis`. --- docs/delivery/README.md | 16 ---- docs/eventing-api.md | 47 ++++------ pkg/apis/duck/v1/channelable_types.go | 4 + pkg/apis/duck/v1/delivery_conversion.go | 10 --- pkg/apis/duck/v1/delivery_conversion_test.go | 12 --- pkg/apis/duck/v1/delivery_types.go | 8 -- pkg/apis/duck/v1/zz_generated.deepcopy.go | 26 ++---- pkg/apis/duck/v1beta1/delivery_conversion.go | 22 ----- .../duck/v1beta1/delivery_conversion_test.go | 89 ------------------- 9 files changed, 25 insertions(+), 209 deletions(-) diff --git a/docs/delivery/README.md b/docs/delivery/README.md index 794b7c775c1..78db6fdc94a 100644 --- a/docs/delivery/README.md +++ b/docs/delivery/README.md @@ -121,22 +121,6 @@ const ( Channel, brokers and event sources are not required to support all these capabilities and are free to add more delivery options. -### Exposing underlying DLC - -Channel implementation supporting dead letter channel should advertise it in -their status. - -```go - -// DeliveryStatus contains the Status of an object supporting delivery options. -type DeliveryStatus struct { - // DeadLetterChannel is a KReference that is the reference to the native, platform specific channel - // where failed events are sent to. - // +optional - DeadLetterChannel *duckv1.KReference `json:"deadLetterChannel,omitempty"` -} -``` - ### Error events The error event is the original events annotated with various CloudEvents diff --git a/docs/eventing-api.md b/docs/eventing-api.md index 1e2cb9cfe3f..ab4b61de70d 100644 --- a/docs/eventing-api.md +++ b/docs/eventing-api.md @@ -273,7 +273,22 @@ knative.dev/pkg/apis/duck/v1.KReference (Optional)

DeadLetterChannel is a KReference and is set by the channel when it supports native error handling via a channel -Failed messages are delivered here.

+Failed messages are delivered here. +Deprecated, see DeadLetterSinkUri insteam

+ + + + +deadLetterSinkUri
+ + +knative.dev/pkg/apis.URL + + + + +(Optional) +

DeadLetterSinkUri is the resolved URI of the dead letter sink.

@@ -372,36 +387,6 @@ For exponential policy, backoff delay is backoffDelay*2^.

-

DeliveryStatus -

-

-

DeliveryStatus contains the Status of an object supporting delivery options.

-

- - - - - - - - - - - - - -
FieldDescription
-deadLetterChannel
- - -knative.dev/pkg/apis/duck/v1.KReference - - -
-(Optional) -

DeadLetterChannel is a KReference that is the reference to the native, platform specific channel -where failed events are sent to.

-

Subscribable

diff --git a/pkg/apis/duck/v1/channelable_types.go b/pkg/apis/duck/v1/channelable_types.go index 2d03a3f879c..65a3625559c 100644 --- a/pkg/apis/duck/v1/channelable_types.go +++ b/pkg/apis/duck/v1/channelable_types.go @@ -65,8 +65,12 @@ type ChannelableStatus struct { SubscribableStatus `json:",inline"` // DeadLetterChannel is a KReference and is set by the channel when it supports native error handling via a channel // Failed messages are delivered here. + // Deprecated, see DeadLetterSinkUri insteam // +optional DeadLetterChannel *duckv1.KReference `json:"deadLetterChannel,omitempty"` + // DeadLetterSinkUri is the resolved URI of the dead letter sink. + // +optional + DeadLetterSinkURI *apis.URL `json:"deadLetterSinkUri,omitempty"` } var ( diff --git a/pkg/apis/duck/v1/delivery_conversion.go b/pkg/apis/duck/v1/delivery_conversion.go index bae7a804ec2..49fc3888dd3 100644 --- a/pkg/apis/duck/v1/delivery_conversion.go +++ b/pkg/apis/duck/v1/delivery_conversion.go @@ -32,13 +32,3 @@ func (source *DeliverySpec) ConvertTo(ctx context.Context, sink apis.Convertible func (sink *DeliverySpec) ConvertFrom(ctx context.Context, source apis.Convertible) error { return fmt.Errorf("v1 is the highest known version, got: %T", source) } - -// ConvertTo implements apis.Convertible -func (source *DeliveryStatus) ConvertTo(ctx context.Context, sink apis.Convertible) error { - return fmt.Errorf("v1 is the highest known version, got: %T", sink) -} - -// ConvertFrom implements apis.Convertible -func (sink *DeliveryStatus) ConvertFrom(ctx context.Context, source apis.Convertible) error { - return fmt.Errorf("v1 is the highest known version, got: %T", source) -} diff --git a/pkg/apis/duck/v1/delivery_conversion_test.go b/pkg/apis/duck/v1/delivery_conversion_test.go index bc348da09cc..e13cdc9523b 100644 --- a/pkg/apis/duck/v1/delivery_conversion_test.go +++ b/pkg/apis/duck/v1/delivery_conversion_test.go @@ -32,15 +32,3 @@ func TestDeliverySpecConversionBadType(t *testing.T) { t.Errorf("ConvertFrom() = %#v, wanted error", good) } } - -func TestDeliveryStatusConversionBadType(t *testing.T) { - good, bad := &DeliveryStatus{}, &DeliveryStatus{} - - if err := good.ConvertTo(context.Background(), bad); err == nil { - t.Errorf("ConvertTo() = %#v, wanted error", bad) - } - - if err := good.ConvertFrom(context.Background(), bad); err == nil { - t.Errorf("ConvertFrom() = %#v, wanted error", good) - } -} diff --git a/pkg/apis/duck/v1/delivery_types.go b/pkg/apis/duck/v1/delivery_types.go index b82bbc4f9b7..68b74552c6f 100644 --- a/pkg/apis/duck/v1/delivery_types.go +++ b/pkg/apis/duck/v1/delivery_types.go @@ -114,11 +114,3 @@ const ( // Exponential backoff policy BackoffPolicyExponential BackoffPolicyType = "exponential" ) - -// DeliveryStatus contains the Status of an object supporting delivery options. -type DeliveryStatus struct { - // DeadLetterChannel is a KReference that is the reference to the native, platform specific channel - // where failed events are sent to. - // +optional - DeadLetterChannel *duckv1.KReference `json:"deadLetterChannel,omitempty"` -} diff --git a/pkg/apis/duck/v1/zz_generated.deepcopy.go b/pkg/apis/duck/v1/zz_generated.deepcopy.go index 0501d0e6045..c47723ef89f 100644 --- a/pkg/apis/duck/v1/zz_generated.deepcopy.go +++ b/pkg/apis/duck/v1/zz_generated.deepcopy.go @@ -120,6 +120,11 @@ func (in *ChannelableStatus) DeepCopyInto(out *ChannelableStatus) { *out = new(duckv1.KReference) **out = **in } + if in.DeadLetterSinkURI != nil { + in, out := &in.DeadLetterSinkURI, &out.DeadLetterSinkURI + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } return } @@ -174,27 +179,6 @@ func (in *DeliverySpec) DeepCopy() *DeliverySpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DeliveryStatus) DeepCopyInto(out *DeliveryStatus) { - *out = *in - if in.DeadLetterChannel != nil { - in, out := &in.DeadLetterChannel, &out.DeadLetterChannel - *out = new(duckv1.KReference) - **out = **in - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeliveryStatus. -func (in *DeliveryStatus) DeepCopy() *DeliveryStatus { - if in == nil { - return nil - } - out := new(DeliveryStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Subscribable) DeepCopyInto(out *Subscribable) { *out = *in diff --git a/pkg/apis/duck/v1beta1/delivery_conversion.go b/pkg/apis/duck/v1beta1/delivery_conversion.go index d48ccde0c18..3b6d6c504a9 100644 --- a/pkg/apis/duck/v1beta1/delivery_conversion.go +++ b/pkg/apis/duck/v1beta1/delivery_conversion.go @@ -75,25 +75,3 @@ func (sink *DeliverySpec) ConvertFrom(ctx context.Context, from apis.Convertible return fmt.Errorf("unknown version, got: %T", source) } } - -// ConvertTo implements apis.Convertible -func (source *DeliveryStatus) ConvertTo(ctx context.Context, to apis.Convertible) error { - switch sink := to.(type) { - case *eventingduckv1.DeliveryStatus: - sink.DeadLetterChannel = source.DeadLetterChannel - return nil - default: - return fmt.Errorf("unknown version, got: %T", sink) - } -} - -// ConvertFrom implements apis.Convertible -func (sink *DeliveryStatus) ConvertFrom(ctx context.Context, from apis.Convertible) error { - switch source := from.(type) { - case *eventingduckv1.DeliveryStatus: - sink.DeadLetterChannel = source.DeadLetterChannel - return nil - default: - return fmt.Errorf("unknown version, got: %T", source) - } -} diff --git a/pkg/apis/duck/v1beta1/delivery_conversion_test.go b/pkg/apis/duck/v1beta1/delivery_conversion_test.go index 7746135bf35..b5528ab2ee7 100644 --- a/pkg/apis/duck/v1beta1/delivery_conversion_test.go +++ b/pkg/apis/duck/v1beta1/delivery_conversion_test.go @@ -23,7 +23,6 @@ import ( "github.com/google/go-cmp/cmp" v1 "knative.dev/eventing/pkg/apis/duck/v1" "knative.dev/pkg/apis" - duckv1 "knative.dev/pkg/apis/duck/v1" pkgduck "knative.dev/pkg/apis/duck/v1" ) @@ -39,18 +38,6 @@ func TestDeliverySpecConversionBadType(t *testing.T) { } } -func TestDeliveryStatusConversionBadType(t *testing.T) { - good, bad := &DeliveryStatus{}, &DeliveryStatus{} - - if err := good.ConvertTo(context.Background(), bad); err == nil { - t.Errorf("ConvertTo() = %#v, wanted error", bad) - } - - if err := good.ConvertFrom(context.Background(), bad); err == nil { - t.Errorf("ConvertFrom() = %#v, wanted error", good) - } -} - // Test v1beta1 -> v1 -> v1beta1 func TestDeliverySpecConversion(t *testing.T) { var retryCount int32 = 10 @@ -204,79 +191,3 @@ func TestDeliverySpecConversionV1(t *testing.T) { }) } } - -// Test v1beta1 -> v1 -> v1beta1 -func TestDeliveryStatusConversion(t *testing.T) { - tests := []struct { - name string - in *DeliveryStatus - err *string - }{{ - name: "min configuration", - in: &DeliveryStatus{ - DeadLetterChannel: &duckv1.KReference{ - Kind: "dlKind", - Namespace: "dlNamespace", - Name: "dlName", - APIVersion: "dlAPIVersion", - }, - }, - }} - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - ver := &v1.DeliveryStatus{} - err := test.in.ConvertTo(context.Background(), ver) - if err != nil { - if test.err == nil || *test.err != err.Error() { - t.Error("ConvertTo() =", err) - } - return - } - got := &DeliveryStatus{} - if err := got.ConvertFrom(context.Background(), ver); err != nil { - t.Error("ConvertFrom() =", err) - } - if diff := cmp.Diff(test.in, got); diff != "" { - t.Error("roundtrip (-want, +got) =", diff) - } - }) - } -} - -// Test v1 -> v1beta1 -> v1 -func TestDeliveryStatusConversionV1(t *testing.T) { - tests := []struct { - name string - in *v1.DeliveryStatus - err *string - }{{ - name: "min configuration", - in: &v1.DeliveryStatus{ - DeadLetterChannel: &duckv1.KReference{ - Kind: "dlKind", - Namespace: "dlNamespace", - Name: "dlName", - APIVersion: "dlAPIVersion", - }, - }, - }} - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - ver := &DeliveryStatus{} - err := ver.ConvertFrom(context.Background(), test.in) - if err != nil { - if test.err == nil || *test.err != err.Error() { - t.Error("ConvertFrom() =", err) - } - return - } - got := &v1.DeliveryStatus{} - if err := ver.ConvertTo(context.Background(), got); err != nil { - t.Error("ConvertTo() =", err) - } - if diff := cmp.Diff(test.in, got); diff != "" { - t.Error("roundtrip (-want, +got) =", diff) - } - }) - } -} From bc4cc1d1dde5ae7d04843627953516f62ec7afc4 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Mon, 20 Sep 2021 12:00:53 -0700 Subject: [PATCH 2/2] Revert addition of `deadLetterSinkUri`, which goes into a different PR. --- docs/eventing-api.md | 17 +---------------- pkg/apis/duck/v1/channelable_types.go | 4 ---- pkg/apis/duck/v1/zz_generated.deepcopy.go | 5 ----- 3 files changed, 1 insertion(+), 25 deletions(-) diff --git a/docs/eventing-api.md b/docs/eventing-api.md index ab4b61de70d..cfda2651167 100644 --- a/docs/eventing-api.md +++ b/docs/eventing-api.md @@ -273,22 +273,7 @@ knative.dev/pkg/apis/duck/v1.KReference (Optional)

DeadLetterChannel is a KReference and is set by the channel when it supports native error handling via a channel -Failed messages are delivered here. -Deprecated, see DeadLetterSinkUri insteam

- - - - -deadLetterSinkUri
- - -knative.dev/pkg/apis.URL - - - - -(Optional) -

DeadLetterSinkUri is the resolved URI of the dead letter sink.

+Failed messages are delivered here.

diff --git a/pkg/apis/duck/v1/channelable_types.go b/pkg/apis/duck/v1/channelable_types.go index 65a3625559c..2d03a3f879c 100644 --- a/pkg/apis/duck/v1/channelable_types.go +++ b/pkg/apis/duck/v1/channelable_types.go @@ -65,12 +65,8 @@ type ChannelableStatus struct { SubscribableStatus `json:",inline"` // DeadLetterChannel is a KReference and is set by the channel when it supports native error handling via a channel // Failed messages are delivered here. - // Deprecated, see DeadLetterSinkUri insteam // +optional DeadLetterChannel *duckv1.KReference `json:"deadLetterChannel,omitempty"` - // DeadLetterSinkUri is the resolved URI of the dead letter sink. - // +optional - DeadLetterSinkURI *apis.URL `json:"deadLetterSinkUri,omitempty"` } var ( diff --git a/pkg/apis/duck/v1/zz_generated.deepcopy.go b/pkg/apis/duck/v1/zz_generated.deepcopy.go index c47723ef89f..814048947ed 100644 --- a/pkg/apis/duck/v1/zz_generated.deepcopy.go +++ b/pkg/apis/duck/v1/zz_generated.deepcopy.go @@ -120,11 +120,6 @@ func (in *ChannelableStatus) DeepCopyInto(out *ChannelableStatus) { *out = new(duckv1.KReference) **out = **in } - if in.DeadLetterSinkURI != nil { - in, out := &in.DeadLetterSinkURI, &out.DeadLetterSinkURI - *out = new(apis.URL) - (*in).DeepCopyInto(*out) - } return }