Skip to content

Commit

Permalink
Fix #673: add support for status.domainInternal (#684)
Browse files Browse the repository at this point in the history
  • Loading branch information
evankanderson authored and knative-prow-robot committed Dec 17, 2018
1 parent 74e0727 commit b432c14
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pkg/controller/eventing/subscription/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,19 @@ func (r *reconciler) resolveSubscriberSpec(namespace string, s v1alpha1.Subscrib
return "", err
}
t := duckv1alpha1.AddressableType{}
err = duck.FromUnstructured(obj, &t)
if err != nil {
glog.Warningf("Failed to deserialize legacy target: %s", err)
return "", err
if err := duck.FromUnstructured(obj, &t); err == nil {
if t.Status.Address != nil {
return domainToURL(t.Status.Address.Hostname), nil
}
}

if t.Status.Address != nil {
return domainToURL(t.Status.Address.Hostname), nil
legacy := duckv1alpha1.LegacyTarget{}
if err := duck.FromUnstructured(obj, &legacy); err == nil {
if legacy.Status.DomainInternal != "" {
return domainToURL(legacy.Status.DomainInternal), nil
}
}

return "", fmt.Errorf("status does not contain address")
}

Expand Down
44 changes: 44 additions & 0 deletions pkg/controller/eventing/subscription/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,50 @@ var testCases = []controllertesting.TestCase{
},
},
},
}, {
Name: "new subscription: adds status, target points to the legacy targetable interface",
InitialState: []runtime.Object{
Subscription().EmptyNonNilReply(),
},
// TODO: JSON patch is not working on the fake, see
// https://github.com/kubernetes/client-go/issues/478. Marking this as expecting a specific
// failure for now, until upstream is fixed.
WantResult: reconcile.Result{},
WantPresent: []runtime.Object{
Subscription().ReferencesResolved().PhysicalSubscriber(targetDNS).EmptyNonNilReply(),
},
WantErrMsg: "invalid JSON document",
Scheme: scheme.Scheme,
Objects: []runtime.Object{
// Source channel
&unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": eventingv1alpha1.SchemeGroupVersion.String(),
"kind": channelKind,
"metadata": map[string]interface{}{
"namespace": testNS,
"name": fromChannelName,
},
"spec": map[string]interface{}{
"subscribable": map[string]interface{}{},
},
},
},
// Subscriber (using knative route)
&unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": "serving.knative.dev/v1alpha1",
"kind": routeKind,
"metadata": map[string]interface{}{
"namespace": testNS,
"name": routeName,
},
"status": map[string]interface{}{
"domainInternal": targetDNS,
},
},
},
},
}, {
Name: "new subscription: adds status, all targets resolved, subscribers modified -- empty but non-nil subscriber",
InitialState: []runtime.Object{
Expand Down

0 comments on commit b432c14

Please sign in to comment.