Skip to content

Commit e6776d4

Browse files
committed
Be more clear on description of route status errors
Signed-off-by: Monis Khan <[email protected]>
1 parent 5b5c08c commit e6776d4

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

pkg/operator2/route.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,20 @@ func (c *authOperator) handleRoute(ingress *configv1.Ingress) (*routev1.Route, *
2323
return nil, nil, err
2424
}
2525

26+
host := getCanonicalHost(route, ingress)
27+
if len(host) == 0 {
28+
// be careful not to print route.spec as it many contain secrets
29+
return nil, nil, fmt.Errorf("route is not available at canonical host %s: %+v", ingressToHost(ingress), route.Status.Ingress)
30+
}
31+
2632
// assume it is unsafe to mutate route in case we go to a shared informer in the future
2733
// this way everything else can just assume route.Spec.Host is correct
2834
// note that we are not updating route.Spec.Host in the API - that value is nonsense to us
2935
route = route.DeepCopy()
30-
route.Spec.Host = getCanonicalHost(route, ingress)
31-
32-
if len(route.Spec.Host) == 0 {
33-
return nil, nil, fmt.Errorf("route has no host: %#v", route)
34-
}
36+
route.Spec.Host = host
3537

3638
if err := isValidRoute(route, ingress); err != nil {
39+
// TODO remove this delete so that we do not lose the early creation timestamp of our route
3740
// delete the route so that it is replaced with the proper one in next reconcile loop
3841
klog.Infof("deleting invalid route: %#v", route)
3942
opts := &metav1.DeleteOptions{Preconditions: &metav1.Preconditions{UID: &route.UID}}
@@ -48,7 +51,8 @@ func (c *authOperator) handleRoute(ingress *configv1.Ingress) (*routev1.Route, *
4851
return nil, nil, err
4952
}
5053
if len(routerSecret.Data) == 0 {
51-
return nil, nil, fmt.Errorf("router secret is empty: %#v", routerSecret)
54+
// be careful not to print the routerSecret even when it is empty
55+
return nil, nil, fmt.Errorf("router secret %s/%s is empty", routerSecret.Namespace, routerSecret.Name)
5256
}
5357

5458
return route, routerSecret, nil

0 commit comments

Comments
 (0)