Skip to content

Commit

Permalink
fix: imc dispatcher reconciler no longer panics on error
Browse files Browse the repository at this point in the history
Signed-off-by: Calum Murray <cmurray@redhat.com>
  • Loading branch information
Cali0707 committed Mar 18, 2024
1 parent 65a995d commit 91c27e1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
10 changes: 6 additions & 4 deletions pkg/reconciler/inmemorychannel/dispatcher/inmemorychannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,18 @@ func newConfigForInMemoryChannel(ctx context.Context, imc *v1.InMemoryChannel) (

for i, sub := range imc.Spec.Subscribers {
conf, err := fanout.SubscriberSpecToFanoutConfig(sub)
conf.Namespace = imc.GetNamespace()
if err != nil {
return nil, err
}

conf.Namespace = imc.Namespace
if isOIDCEnabled {
conf.ServiceAccount = &types.NamespacedName{
Name: *sub.Auth.ServiceAccountName,
Namespace: imc.Namespace,
}
}
if err != nil {
return nil, err
}

subs[i] = *conf
}

Expand Down
20 changes: 16 additions & 4 deletions pkg/reconciler/inmemorychannel/dispatcher/inmemorychannel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,16 @@ func TestReconciler_ReconcileKind(t *testing.T) {
Reply: &duckv1.Addressable{
URL: apis.HTTP("sink2"),
},
Namespace: testNS,
}, {
Subscriber: duckv1.Addressable{
URL: apis.HTTP("call2"),
},
Reply: &duckv1.Addressable{
URL: apis.HTTP("sink2"),
}},
},
Namespace: testNS,
},
},
},
"with one subscriber, one added": {
Expand All @@ -375,12 +378,14 @@ func TestReconciler_ReconcileKind(t *testing.T) {
WithInMemoryChannelDLSUnknown()),
subs: []fanout.Subscription{*subscription1},
wantSubs: []fanout.Subscription{{
Namespace: testNS,
Subscriber: duckv1.Addressable{
URL: apis.HTTP("call1"),
},
Reply: &duckv1.Addressable{
URL: apis.HTTP("sink2"),
}}, {
Namespace: testNS,
Subscriber: duckv1.Addressable{
URL: apis.HTTP("call2"),
},
Expand All @@ -401,12 +406,14 @@ func TestReconciler_ReconcileKind(t *testing.T) {
WithInMemoryChannelDLSUnknown()),
subs: []fanout.Subscription{*subscription1, *subscription2},
wantSubs: []fanout.Subscription{{
Namespace: testNS,
Subscriber: duckv1.Addressable{
URL: apis.HTTP("call1"),
},
Reply: &duckv1.Addressable{
URL: apis.HTTP("sink2"),
}}, {
Namespace: testNS,
Subscriber: duckv1.Addressable{
URL: apis.HTTP("call2"),
},
Expand All @@ -428,6 +435,7 @@ func TestReconciler_ReconcileKind(t *testing.T) {
subs: []fanout.Subscription{*subscription1, *subscription2},
wantSubs: []fanout.Subscription{
{
Namespace: testNS,
Subscriber: duckv1.Addressable{
URL: apis.HTTP("call1"),
},
Expand All @@ -449,12 +457,14 @@ func TestReconciler_ReconcileKind(t *testing.T) {
subs: []fanout.Subscription{*subscription1, *subscription2},
wantSubs: []fanout.Subscription{
{
Namespace: testNS,
Subscriber: duckv1.Addressable{
URL: apis.HTTP("call1"),
},
Reply: &duckv1.Addressable{
URL: apis.HTTP("sink2"),
}}, {
Namespace: testNS,
Subscriber: duckv1.Addressable{
URL: apis.HTTP("call3"),
},
Expand Down Expand Up @@ -482,9 +492,11 @@ func TestReconciler_ReconcileKind(t *testing.T) {
},
RetryConfig: &kncloudevents.RetryConfig{RetryMax: 2, BackoffPolicy: &exponential}}},
wantSubs: []fanout.Subscription{
{Subscriber: duckv1.Addressable{
URL: apis.HTTP("call1"),
},
{
Namespace: testNS,
Subscriber: duckv1.Addressable{
URL: apis.HTTP("call1"),
},
Reply: &duckv1.Addressable{
URL: apis.HTTP("sink2"),
},
Expand Down

0 comments on commit 91c27e1

Please sign in to comment.