From 0171f62e8cedb40e880314f6b7661f02820b29ec Mon Sep 17 00:00:00 2001 From: Lukas Berk Date: Tue, 5 May 2020 20:51:51 -0400 Subject: [PATCH 01/12] Change backingchannel to return a combinedchannelable --- go.mod | 1 + .../v1alpha1/channelable_combined_types.go | 20 +++++----- pkg/reconciler/channel/channel.go | 37 +++++++++++++++++-- 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index ab46d40fbf4..6535950c9ee 100644 --- a/go.mod +++ b/go.mod @@ -36,6 +36,7 @@ require ( k8s.io/utils v0.0.0-20200124190032-861946025e34 knative.dev/pkg v0.0.0-20200507011344-2581370e4a37 knative.dev/test-infra v0.0.0-20200506231144-c8dd15bb7f0b + sigs.k8s.io/yaml v1.2.0 ) diff --git a/pkg/apis/duck/v1alpha1/channelable_combined_types.go b/pkg/apis/duck/v1alpha1/channelable_combined_types.go index 11bfa56f63a..5d957b0d253 100644 --- a/pkg/apis/duck/v1alpha1/channelable_combined_types.go +++ b/pkg/apis/duck/v1alpha1/channelable_combined_types.go @@ -24,8 +24,6 @@ import ( "knative.dev/pkg/apis" "knative.dev/pkg/apis/duck" duckv1 "knative.dev/pkg/apis/duck/v1" - "knative.dev/pkg/apis/duck/v1alpha1" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) // +genduck @@ -66,7 +64,7 @@ type ChannelableCombinedStatus struct { // * Conditions - the latest available observations of a resource's current state. duckv1.Status `json:",inline"` // AddressStatus is the part where the Channelable fulfills the Addressable contract. - v1alpha1.AddressStatus `json:",inline"` + duckv1.AddressStatus `json:",inline"` // SubscribableTypeStatus is the v1alpha1 part of the Subscribers status SubscribableTypeStatus `json:",inline"` // SubscribableStatus is the v1beta1 part of the Subscribers status. @@ -131,16 +129,16 @@ func (c *ChannelableCombined) Populate() { BackoffDelay: &delay, } c.Status = ChannelableCombinedStatus{ - AddressStatus: v1alpha1.AddressStatus{ - Address: &v1alpha1.Addressable{ + AddressStatus: duckv1.AddressStatus{ + Address: &duckv1.Addressable{ // Populate ALL fields - Addressable: duckv1beta1.Addressable{ - URL: &apis.URL{ - Scheme: "http", - Host: "test-domain", - }, + // Addressable: duckv1.Addressable{ + URL: &apis.URL{ + Scheme: "http", + Host: "test-domain", }, - Hostname: "test-domain", + // }, + // Hostname: "test-domain", }, }, SubscribableStatus: eventingduckv1beta1.SubscribableStatus{ diff --git a/pkg/reconciler/channel/channel.go b/pkg/reconciler/channel/channel.go index 47ef1d89983..2d09121ca0e 100644 --- a/pkg/reconciler/channel/channel.go +++ b/pkg/reconciler/channel/channel.go @@ -26,7 +26,9 @@ import ( "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/dynamic" + duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" duckv1beta1 "knative.dev/eventing/pkg/apis/duck/v1beta1" + "knative.dev/eventing/pkg/apis/messaging" "knative.dev/eventing/pkg/apis/messaging/v1beta1" channelreconciler "knative.dev/eventing/pkg/client/injection/reconciler/messaging/v1beta1/channel" listers "knative.dev/eventing/pkg/client/listers/messaging/v1beta1" @@ -90,13 +92,40 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, c *v1beta1.Channel) pkgr } c.Status.Channel = &backingChannelObjRef - c.Status.PropagateStatuses(&backingChannel.Status) + bCS := r.getChannelableStatus(&backingChannel.Status, backingChannel.Annotations) // this needs to decide what api version to draw from before we propogate) + c.Status.PropagateStatuses(&bCS) return newReconciledNormal(c.Namespace, c.Name) } +func (r *Reconciler) getChannelableStatus(bc *duckv1alpha1.ChannelableCombinedStatus, cAnnotations map[string]string) duckv1beta1.ChannelableStatus { + + if cAnnotations != nil { + if cAnnotations[messaging.SubscribableDuckVersionAnnotation] == "v1beta1" { + return duckv1beta1.ChannelableStatus{ + Status: bc.Status, + AddressStatus: bc.AddressStatus, + SubscribableStatus: bc.SubscribableStatus, + } + } else { //v1alpha1 + return duckv1beta1.ChannelableStatus{ + Status: bc.Status, + AddressStatus: bc.AddressStatus, + SubscribableStatus: duckv1beta1.SubscribableStatus{ + Subscribers: bc.SubscribableTypeStatus.SubscribableStatus.Subscribers, + }, + } + } + } + return duckv1beta1.ChannelableStatus{ + Status: bc.Status, + AddressStatus: bc.AddressStatus, + SubscribableStatus: bc.SubscribableStatus, + } +} + // reconcileBackingChannel reconciles Channel's 'c' underlying CRD channel. -func (r *Reconciler) reconcileBackingChannel(ctx context.Context, channelResourceInterface dynamic.ResourceInterface, c *v1beta1.Channel, backingChannelObjRef duckv1.KReference) (*duckv1beta1.Channelable, error) { +func (r *Reconciler) reconcileBackingChannel(ctx context.Context, channelResourceInterface dynamic.ResourceInterface, c *v1beta1.Channel, backingChannelObjRef duckv1.KReference) (*duckv1alpha1.ChannelableCombined, error) { lister, err := r.channelableTracker.ListerForKReference(backingChannelObjRef) if err != nil { logging.FromContext(ctx).Error("Error getting lister for Channel", zap.Any("backingChannel", backingChannelObjRef), zap.Error(err)) @@ -118,7 +147,7 @@ func (r *Reconciler) reconcileBackingChannel(ctx context.Context, channelResourc return nil, err } logging.FromContext(ctx).Debug("Created backing Channel", zap.Any("backingChannel", newBackingChannel)) - channelable := &duckv1beta1.Channelable{} + channelable := &duckv1alpha1.ChannelableCombined{} err = duckapis.FromUnstructured(created, channelable) if err != nil { logging.FromContext(ctx).Error("Failed to convert to Channelable Object", zap.Any("backingChannel", backingChannelObjRef), zap.Any("createdChannel", created), zap.Error(err)) @@ -131,7 +160,7 @@ func (r *Reconciler) reconcileBackingChannel(ctx context.Context, channelResourc return nil, err } logging.FromContext(ctx).Debug("Found backing Channel", zap.Any("backingChannel", backingChannelObjRef)) - channelable, ok := backingChannel.(*duckv1beta1.Channelable) + channelable, ok := backingChannel.(*duckv1alpha1.ChannelableCombined) if !ok { logging.FromContext(ctx).Error("Failed to convert to Channelable Object", zap.Any("backingChannel", backingChannel), zap.Error(err)) return nil, err From 05e317fded8c5a202c9e275dd4370068a1827356 Mon Sep 17 00:00:00 2001 From: Lukas Berk Date: Thu, 7 May 2020 15:34:35 -0400 Subject: [PATCH 02/12] Revert channelable_combined_type changes --- .../v1alpha1/channelable_combined_types.go | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pkg/apis/duck/v1alpha1/channelable_combined_types.go b/pkg/apis/duck/v1alpha1/channelable_combined_types.go index 5d957b0d253..11bfa56f63a 100644 --- a/pkg/apis/duck/v1alpha1/channelable_combined_types.go +++ b/pkg/apis/duck/v1alpha1/channelable_combined_types.go @@ -24,6 +24,8 @@ import ( "knative.dev/pkg/apis" "knative.dev/pkg/apis/duck" duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) // +genduck @@ -64,7 +66,7 @@ type ChannelableCombinedStatus struct { // * Conditions - the latest available observations of a resource's current state. duckv1.Status `json:",inline"` // AddressStatus is the part where the Channelable fulfills the Addressable contract. - duckv1.AddressStatus `json:",inline"` + v1alpha1.AddressStatus `json:",inline"` // SubscribableTypeStatus is the v1alpha1 part of the Subscribers status SubscribableTypeStatus `json:",inline"` // SubscribableStatus is the v1beta1 part of the Subscribers status. @@ -129,16 +131,16 @@ func (c *ChannelableCombined) Populate() { BackoffDelay: &delay, } c.Status = ChannelableCombinedStatus{ - AddressStatus: duckv1.AddressStatus{ - Address: &duckv1.Addressable{ + AddressStatus: v1alpha1.AddressStatus{ + Address: &v1alpha1.Addressable{ // Populate ALL fields - // Addressable: duckv1.Addressable{ - URL: &apis.URL{ - Scheme: "http", - Host: "test-domain", + Addressable: duckv1beta1.Addressable{ + URL: &apis.URL{ + Scheme: "http", + Host: "test-domain", + }, }, - // }, - // Hostname: "test-domain", + Hostname: "test-domain", }, }, SubscribableStatus: eventingduckv1beta1.SubscribableStatus{ From 7187065053a1e0673c6dcbef406602a94c923790 Mon Sep 17 00:00:00 2001 From: Lukas Berk Date: Thu, 7 May 2020 15:35:01 -0400 Subject: [PATCH 03/12] Rework changing channelable status function --- pkg/reconciler/channel/channel.go | 40 +++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/pkg/reconciler/channel/channel.go b/pkg/reconciler/channel/channel.go index 2d09121ca0e..6acfd38adb6 100644 --- a/pkg/reconciler/channel/channel.go +++ b/pkg/reconciler/channel/channel.go @@ -92,36 +92,40 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, c *v1beta1.Channel) pkgr } c.Status.Channel = &backingChannelObjRef - bCS := r.getChannelableStatus(&backingChannel.Status, backingChannel.Annotations) // this needs to decide what api version to draw from before we propogate) - c.Status.PropagateStatuses(&bCS) + bCS := r.getChannelableStatus(ctx, &backingChannel.Status, backingChannel.Annotations) + c.Status.PropagateStatuses(bCS) return newReconciledNormal(c.Namespace, c.Name) } -func (r *Reconciler) getChannelableStatus(bc *duckv1alpha1.ChannelableCombinedStatus, cAnnotations map[string]string) duckv1beta1.ChannelableStatus { +func (r *Reconciler) getChannelableStatus(ctx context.Context, bc *duckv1alpha1.ChannelableCombinedStatus, cAnnotations map[string]string) *duckv1beta1.ChannelableStatus { + channelableStatus := &duckv1beta1.ChannelableStatus{} + if bc.AddressStatus.Address != nil { + channelableStatus.AddressStatus.Address = &duckv1.Addressable{} + bc.AddressStatus.Address.ConvertTo(ctx, channelableStatus.AddressStatus.Address) + } + channelableStatus.Status = bc.Status if cAnnotations != nil { if cAnnotations[messaging.SubscribableDuckVersionAnnotation] == "v1beta1" { - return duckv1beta1.ChannelableStatus{ - Status: bc.Status, - AddressStatus: bc.AddressStatus, - SubscribableStatus: bc.SubscribableStatus, + if len(bc.SubscribableStatus.Subscribers) > 0 { + channelableStatus.SubscribableStatus.Subscribers = bc.SubscribableStatus.Subscribers } } else { //v1alpha1 - return duckv1beta1.ChannelableStatus{ - Status: bc.Status, - AddressStatus: bc.AddressStatus, - SubscribableStatus: duckv1beta1.SubscribableStatus{ - Subscribers: bc.SubscribableTypeStatus.SubscribableStatus.Subscribers, - }, + if len(bc.SubscribableTypeStatus.SubscribableStatus.Subscribers) > 0 { + channelableStatus.SubscribableStatus.Subscribers = make([]duckv1beta1.SubscriberStatus, len(bc.SubscribableTypeStatus.SubscribableStatus.Subscribers)) + for i, ss := range bc.SubscribableTypeStatus.SubscribableStatus.Subscribers { + channelableStatus.SubscribableStatus.Subscribers[i] = duckv1beta1.SubscriberStatus{ + UID: ss.UID, + ObservedGeneration: ss.ObservedGeneration, + Ready: ss.Ready, + Message: ss.Message, + } + } } } } - return duckv1beta1.ChannelableStatus{ - Status: bc.Status, - AddressStatus: bc.AddressStatus, - SubscribableStatus: bc.SubscribableStatus, - } + return channelableStatus } // reconcileBackingChannel reconciles Channel's 'c' underlying CRD channel. From 1ab40ecaefc59bf26e576b18d439459a50823d81 Mon Sep 17 00:00:00 2001 From: Lukas Berk Date: Thu, 7 May 2020 15:46:04 -0400 Subject: [PATCH 04/12] Add nil check to subscribableTypeStatus --- pkg/reconciler/channel/channel.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/reconciler/channel/channel.go b/pkg/reconciler/channel/channel.go index 6acfd38adb6..c31c2bf27e9 100644 --- a/pkg/reconciler/channel/channel.go +++ b/pkg/reconciler/channel/channel.go @@ -112,7 +112,8 @@ func (r *Reconciler) getChannelableStatus(ctx context.Context, bc *duckv1alpha1. channelableStatus.SubscribableStatus.Subscribers = bc.SubscribableStatus.Subscribers } } else { //v1alpha1 - if len(bc.SubscribableTypeStatus.SubscribableStatus.Subscribers) > 0 { + if bc.SubscribableTypeStatus.SubscribableStatus != nil && + len(bc.SubscribableTypeStatus.SubscribableStatus.Subscribers) > 0 { channelableStatus.SubscribableStatus.Subscribers = make([]duckv1beta1.SubscriberStatus, len(bc.SubscribableTypeStatus.SubscribableStatus.Subscribers)) for i, ss := range bc.SubscribableTypeStatus.SubscribableStatus.Subscribers { channelableStatus.SubscribableStatus.Subscribers[i] = duckv1beta1.SubscriberStatus{ From 071be2bc3a83ecb777788cfd24410931f84492ca Mon Sep 17 00:00:00 2001 From: Lukas Berk Date: Thu, 7 May 2020 16:06:22 -0400 Subject: [PATCH 05/12] Update channel controller with combinedchannel --- pkg/reconciler/channel/controller.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/reconciler/channel/controller.go b/pkg/reconciler/channel/controller.go index f3b0a2905f3..285999bdbf9 100644 --- a/pkg/reconciler/channel/controller.go +++ b/pkg/reconciler/channel/controller.go @@ -24,7 +24,7 @@ import ( "knative.dev/pkg/injection/clients/dynamicclient" "knative.dev/pkg/logging" - "knative.dev/eventing/pkg/client/injection/ducks/duck/v1beta1/channelable" + "knative.dev/eventing/pkg/client/injection/ducks/duck/v1alpha1/channelablecombined" channelinformer "knative.dev/eventing/pkg/client/injection/informers/messaging/v1beta1/channel" channelreconciler "knative.dev/eventing/pkg/client/injection/reconciler/messaging/v1beta1/channel" "knative.dev/eventing/pkg/duck" @@ -44,7 +44,7 @@ func NewController( } impl := channelreconciler.NewImpl(ctx, r) - r.channelableTracker = duck.NewListableTracker(ctx, channelable.Get, impl.EnqueueKey, controller.GetTrackerLease(ctx)) + r.channelableTracker = duck.NewListableTracker(ctx, channelablecombined.Get, impl.EnqueueKey, controller.GetTrackerLease(ctx)) logging.FromContext(ctx).Info("Setting up event handlers") From 3cc9c3b36c9e6014236da3890f75349939d70da6 Mon Sep 17 00:00:00 2001 From: Lukas Berk Date: Thu, 7 May 2020 16:19:27 -0400 Subject: [PATCH 06/12] Commit extra go.mod bits --- go.mod | 2 ++ 1 file changed, 2 insertions(+) diff --git a/go.mod b/go.mod index 6535950c9ee..549cb148966 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/google/go-cmp v0.4.0 github.com/google/mako v0.0.0-20190821191249-122f8dcef9e3 github.com/google/uuid v1.1.1 + github.com/googleapis/gax-go/v2 v2.0.5 github.com/influxdata/tdigest v0.0.0-20191024211133-5d87a7585faa // indirect github.com/json-iterator/go v1.1.9 // indirect github.com/kelseyhightower/envconfig v1.4.0 @@ -27,6 +28,7 @@ require ( go.uber.org/atomic v1.6.0 go.uber.org/zap v1.14.1 gomodules.xyz/jsonpatch/v2 v2.1.0 // indirect + google.golang.org/api v0.20.0 google.golang.org/grpc v1.28.0 k8s.io/api v0.17.3 k8s.io/apiextensions-apiserver v0.17.2 From a6404c208af21cee4d85233f0403d5fc76dd53c6 Mon Sep 17 00:00:00 2001 From: Lukas Berk Date: Thu, 7 May 2020 16:47:47 -0400 Subject: [PATCH 07/12] run hack/update-codegen.sh --- go.mod | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.mod b/go.mod index 549cb148966..6535950c9ee 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,6 @@ require ( github.com/google/go-cmp v0.4.0 github.com/google/mako v0.0.0-20190821191249-122f8dcef9e3 github.com/google/uuid v1.1.1 - github.com/googleapis/gax-go/v2 v2.0.5 github.com/influxdata/tdigest v0.0.0-20191024211133-5d87a7585faa // indirect github.com/json-iterator/go v1.1.9 // indirect github.com/kelseyhightower/envconfig v1.4.0 @@ -28,7 +27,6 @@ require ( go.uber.org/atomic v1.6.0 go.uber.org/zap v1.14.1 gomodules.xyz/jsonpatch/v2 v2.1.0 // indirect - google.golang.org/api v0.20.0 google.golang.org/grpc v1.28.0 k8s.io/api v0.17.3 k8s.io/apiextensions-apiserver v0.17.2 From bc1cead9ca3edc05818cb9603d172dacf72ebc01 Mon Sep 17 00:00:00 2001 From: Lukas Berk Date: Thu, 7 May 2020 17:09:25 -0400 Subject: [PATCH 08/12] drop extra space in go.mod --- go.mod | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 6535950c9ee..e938041eb6b 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/google/go-cmp v0.4.0 github.com/google/mako v0.0.0-20190821191249-122f8dcef9e3 github.com/google/uuid v1.1.1 + github.com/googleapis/gax-go/v2 v2.0.5 github.com/influxdata/tdigest v0.0.0-20191024211133-5d87a7585faa // indirect github.com/json-iterator/go v1.1.9 // indirect github.com/kelseyhightower/envconfig v1.4.0 @@ -27,6 +28,7 @@ require ( go.uber.org/atomic v1.6.0 go.uber.org/zap v1.14.1 gomodules.xyz/jsonpatch/v2 v2.1.0 // indirect + google.golang.org/api v0.20.0 google.golang.org/grpc v1.28.0 k8s.io/api v0.17.3 k8s.io/apiextensions-apiserver v0.17.2 @@ -36,7 +38,6 @@ require ( k8s.io/utils v0.0.0-20200124190032-861946025e34 knative.dev/pkg v0.0.0-20200507011344-2581370e4a37 knative.dev/test-infra v0.0.0-20200506231144-c8dd15bb7f0b - sigs.k8s.io/yaml v1.2.0 ) From 910d5926e5fe0282ef4a7b2101b6fa4e5dfdbca0 Mon Sep 17 00:00:00 2001 From: Lukas Berk Date: Thu, 7 May 2020 17:09:41 -0400 Subject: [PATCH 09/12] Remove reference to err to avoid panic --- pkg/reconciler/channel/channel.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/reconciler/channel/channel.go b/pkg/reconciler/channel/channel.go index c31c2bf27e9..3401b0b4ca4 100644 --- a/pkg/reconciler/channel/channel.go +++ b/pkg/reconciler/channel/channel.go @@ -167,8 +167,7 @@ func (r *Reconciler) reconcileBackingChannel(ctx context.Context, channelResourc logging.FromContext(ctx).Debug("Found backing Channel", zap.Any("backingChannel", backingChannelObjRef)) channelable, ok := backingChannel.(*duckv1alpha1.ChannelableCombined) if !ok { - logging.FromContext(ctx).Error("Failed to convert to Channelable Object", zap.Any("backingChannel", backingChannel), zap.Error(err)) - return nil, err + return nil, fmt.Errorf("Failed to convert to Channelable Object %+v", backingChannel) } return channelable, nil } From e72e60710bbdc61009153ecf45bd3e8d91881ba3 Mon Sep 17 00:00:00 2001 From: Lukas Berk Date: Thu, 7 May 2020 17:49:54 -0400 Subject: [PATCH 10/12] gomod again -- update channel_test trackables with channelablecombined --- go.mod | 2 -- pkg/reconciler/channel/channel_test.go | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index e938041eb6b..ab46d40fbf4 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,6 @@ require ( github.com/google/go-cmp v0.4.0 github.com/google/mako v0.0.0-20190821191249-122f8dcef9e3 github.com/google/uuid v1.1.1 - github.com/googleapis/gax-go/v2 v2.0.5 github.com/influxdata/tdigest v0.0.0-20191024211133-5d87a7585faa // indirect github.com/json-iterator/go v1.1.9 // indirect github.com/kelseyhightower/envconfig v1.4.0 @@ -28,7 +27,6 @@ require ( go.uber.org/atomic v1.6.0 go.uber.org/zap v1.14.1 gomodules.xyz/jsonpatch/v2 v2.1.0 // indirect - google.golang.org/api v0.20.0 google.golang.org/grpc v1.28.0 k8s.io/api v0.17.3 k8s.io/apiextensions-apiserver v0.17.2 diff --git a/pkg/reconciler/channel/channel_test.go b/pkg/reconciler/channel/channel_test.go index b2b3cc24b72..568a055da54 100644 --- a/pkg/reconciler/channel/channel_test.go +++ b/pkg/reconciler/channel/channel_test.go @@ -31,7 +31,7 @@ import ( clientgotesting "k8s.io/client-go/testing" eventingduckv1beta1 "knative.dev/eventing/pkg/apis/duck/v1beta1" fakeeventingclient "knative.dev/eventing/pkg/client/injection/client/fake" - "knative.dev/eventing/pkg/client/injection/ducks/duck/v1beta1/channelable" + "knative.dev/eventing/pkg/client/injection/ducks/duck/v1alpha1/channelablecombined" channelreconciler "knative.dev/eventing/pkg/client/injection/reconciler/messaging/v1beta1/channel" "knative.dev/eventing/pkg/duck" . "knative.dev/eventing/pkg/reconciler/testing" @@ -250,11 +250,11 @@ func TestReconcile(t *testing.T) { logger := logtesting.TestLogger(t) table.Test(t, MakeFactory(func(ctx context.Context, listers *Listers, cmw configmap.Watcher) controller.Reconciler { - ctx = channelable.WithDuck(ctx) + ctx = channelablecombined.WithDuck(ctx) r := &Reconciler{ dynamicClientSet: fakedynamicclient.Get(ctx), channelLister: listers.GetV1Beta1MessagingChannelLister(), - channelableTracker: duck.NewListableTracker(ctx, channelable.Get, func(types.NamespacedName) {}, 0), + channelableTracker: duck.NewListableTracker(ctx, channelablecombined.Get, func(types.NamespacedName) {}, 0), } return channelreconciler.NewReconciler(ctx, logger, fakeeventingclient.Get(ctx), listers.GetV1Beta1MessagingChannelLister(), From 225999a04906654ba9285fa2d423fc3bc1f51f15 Mon Sep 17 00:00:00 2001 From: Lukas Berk Date: Thu, 7 May 2020 18:28:20 -0400 Subject: [PATCH 11/12] Add subscribableDuckAnnotation to test channel --- pkg/reconciler/channel/channel_test.go | 1 + pkg/reconciler/testing/inmemorychannel.go | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/pkg/reconciler/channel/channel_test.go b/pkg/reconciler/channel/channel_test.go index 568a055da54..79a6572d960 100644 --- a/pkg/reconciler/channel/channel_test.go +++ b/pkg/reconciler/channel/channel_test.go @@ -226,6 +226,7 @@ func TestReconcile(t *testing.T) { WithChannelAddressV1Beta1(backingChannelHostname)), NewInMemoryChannelV1Beta1(channelName, testNS, WithInitInMemoryChannelConditionsV1Beta1, + WithInMemoryChannelDuckAnnotationV1Beta1, WithInMemoryChannelDeploymentReadyV1Beta1(), WithInMemoryChannelServiceReadyV1Beta1(), WithInMemoryChannelEndpointsReadyV1Beta1(), diff --git a/pkg/reconciler/testing/inmemorychannel.go b/pkg/reconciler/testing/inmemorychannel.go index b698945a7ca..a709ab1d375 100644 --- a/pkg/reconciler/testing/inmemorychannel.go +++ b/pkg/reconciler/testing/inmemorychannel.go @@ -28,6 +28,7 @@ import ( duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" duckv1beta1 "knative.dev/eventing/pkg/apis/duck/v1beta1" "knative.dev/eventing/pkg/apis/eventing" + "knative.dev/eventing/pkg/apis/messaging" "knative.dev/eventing/pkg/apis/messaging/v1alpha1" "knative.dev/eventing/pkg/apis/messaging/v1beta1" "knative.dev/pkg/apis" @@ -56,6 +57,14 @@ func WithInitInMemoryChannelConditionsV1Beta1(imc *v1beta1.InMemoryChannel) { imc.Status.InitializeConditions() } +func WithInMemoryChannelDuckAnnotationV1Beta1(imc *v1beta1.InMemoryChannel) { + annotations := map[string]string{ + messaging.SubscribableDuckVersionAnnotation: "v1beta1", + } + imc.ObjectMeta.SetAnnotations(annotations) + +} + func WithInMemoryChannelGenerationV1Beta1(gen int64) InMemoryChannelOptionV1Beta1 { return func(s *v1beta1.InMemoryChannel) { s.Generation = gen From a87e7882fef3af9ad1d8becebf690270ea2bc008 Mon Sep 17 00:00:00 2001 From: Lukas Berk Date: Thu, 7 May 2020 18:28:33 -0400 Subject: [PATCH 12/12] Fix controller test with correct fake informer --- pkg/reconciler/channel/controller_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/reconciler/channel/controller_test.go b/pkg/reconciler/channel/controller_test.go index 87c23eb68cb..d2346a87de3 100644 --- a/pkg/reconciler/channel/controller_test.go +++ b/pkg/reconciler/channel/controller_test.go @@ -24,7 +24,7 @@ import ( . "knative.dev/pkg/reconciler/testing" // Fake injection informers - _ "knative.dev/eventing/pkg/client/injection/ducks/duck/v1beta1/channelable/fake" + _ "knative.dev/eventing/pkg/client/injection/ducks/duck/v1alpha1/channelablecombined/fake" _ "knative.dev/eventing/pkg/client/injection/informers/messaging/v1beta1/channel/fake" _ "knative.dev/pkg/client/injection/kube/client/fake" _ "knative.dev/pkg/injection/clients/dynamicclient/fake"