Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/reconciler/subscription/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ func (r *Reconciler) Reconcile(ctx context.Context, key string) error {
func (r *Reconciler) reconcile(ctx context.Context, subscription *v1alpha1.Subscription) error {
subscription.Status.InitializeConditions()

// Verify subscription is valid.
if err := subscription.Validate(ctx); err != nil {
return err
}
// See if the subscription has been deleted
if subscription.DeletionTimestamp != nil {
// If the subscription is Ready, then we have to remove it
Expand Down Expand Up @@ -282,7 +286,7 @@ func (r *Reconciler) resolveResult(ctx context.Context, namespace string, replyS
if s.Status.Address != nil {
return resolve.DomainToURL(s.Status.Address.Hostname), nil
}
return "", fmt.Errorf("status does not contain address")
return "", fmt.Errorf("reply.status does not contain address")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, thanks!

}

func (r *Reconciler) syncPhysicalChannel(ctx context.Context, sub *v1alpha1.Subscription, isDeleted bool) error {
Expand Down
8 changes: 3 additions & 5 deletions pkg/reconciler/subscription/subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ var (
serviceURI = "http://" + serviceDNS + "/"

subscriberGVK = metav1.GroupVersionKind{
Group: "testing.eventing.knative.dev",
Group: "eventing.knative.dev",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is testing ducktyping for subscribers. testing. was wanted.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed that because in subscriber validation there is hardcoded logic to validate API group is eventing.knative.dev

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, thanks.

Version: "v1alpha1",
Kind: "Subscriber",
}
Expand Down Expand Up @@ -154,7 +154,7 @@ func TestAllCases(t *testing.T) {
Key: testNS + "/" + subscriptionName,
WantErr: true,
WantEvents: []string{
Eventf(corev1.EventTypeWarning, "SubscriberResolveFailed", "Failed to resolve spec.subscriber: subscribers.testing.eventing.knative.dev %q not found", subscriberName),
Eventf(corev1.EventTypeWarning, "SubscriberResolveFailed", "Failed to resolve spec.subscriber: subscribers.eventing.knative.dev %q not found", subscriberName),
},
WantStatusUpdates: []clientgotesting.UpdateActionImpl{{
Object: NewSubscription(subscriptionName, testNS,
Expand Down Expand Up @@ -214,8 +214,7 @@ func TestAllCases(t *testing.T) {
Key: testNS + "/" + subscriptionName,
WantErr: true,
WantEvents: []string{
Eventf(corev1.EventTypeWarning, "ResultResolveFailed", "Failed to resolve spec.reply: status does not contain address"),
Eventf(corev1.EventTypeWarning, "SubscriptionUpdateStatusFailed", "Failed to update Subscription's status: status does not contain address"), // TODO: BUGBUG THIS IS WEIRD
Eventf(corev1.EventTypeWarning, "SubscriptionUpdateStatusFailed", "Failed to update Subscription's status: invalid value: Subscriber: spec.reply.kind\nonly 'Channel' kind is allowed"),
},
WantStatusUpdates: []clientgotesting.UpdateActionImpl{{
Object: NewSubscription(subscriptionName, testNS,
Expand All @@ -224,7 +223,6 @@ func TestAllCases(t *testing.T) {
WithSubscriptionReply(subscriberGVK, replyName),
// The first reconciliation will initialize the status conditions.
WithInitSubscriptionConditions,
WithSubscriptionPhysicalSubscriptionSubscriber(subscriberURI),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, I suppose this is because you are validating. NICE.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

),
}},
}, {
Expand Down