Skip to content

Commit

Permalink
Mark IngressNotConfigured on Route when there is no Ingress status
Browse files Browse the repository at this point in the history
Fixes #4072
  • Loading branch information
tanzeeb committed Jun 13, 2019
1 parent 3cbdfc3 commit c01795f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
6 changes: 6 additions & 0 deletions pkg/apis/serving/v1alpha1/route_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ func (rs *RouteStatus) MarkServiceNotOwned(name string) {
fmt.Sprintf("There is an existing placeholder Service %q that we do not own.", name))
}

func (rs *RouteStatus) MarkIngressNotConfigured() {
routeCondSet.Manage(rs).MarkUnknown(RouteConditionIngressReady,
"IngressNotConfigured", "Failed to configure route ingress.")
}

func (rs *RouteStatus) MarkTrafficAssigned() {
routeCondSet.Manage(rs).MarkTrue(RouteConditionAllTrafficAssigned)
}
Expand Down Expand Up @@ -150,6 +155,7 @@ func (rs *RouteStatus) MarkCertificateNotOwned(name string) {
func (rs *RouteStatus) PropagateClusterIngressStatus(cs v1alpha1.IngressStatus) {
cc := cs.GetCondition(v1alpha1.IngressConditionReady)
if cc == nil {
rs.MarkIngressNotConfigured()
return
}
switch {
Expand Down
10 changes: 9 additions & 1 deletion pkg/apis/serving/v1alpha1/route_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func TestClusterIngressFailureRecovery(t *testing.T) {
apitesting.CheckConditionOngoing(r.duck(), RouteConditionIngressReady, t)
apitesting.CheckConditionOngoing(r.duck(), RouteConditionReady, t)

// Empty IngressStatus keeps things as-is.
// Empty IngressStatus marks ingress "NotConfigured"
r.PropagateClusterIngressStatus(netv1alpha1.IngressStatus{})
apitesting.CheckConditionOngoing(r.duck(), RouteConditionAllTrafficAssigned, t)
apitesting.CheckConditionOngoing(r.duck(), RouteConditionIngressReady, t)
Expand Down Expand Up @@ -378,3 +378,11 @@ func TestRouteNotOwnCertificate(t *testing.T) {

apitesting.CheckConditionFailed(r.duck(), RouteConditionCertificateProvisioned, t)
}

func TestIngressNotConfigured(t *testing.T) {
r := &RouteStatus{}
r.InitializeConditions()
r.MarkIngressNotConfigured()

apitesting.CheckConditionOngoing(r.duck(), RouteConditionIngressReady, t)
}
14 changes: 7 additions & 7 deletions pkg/reconciler/route/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func TestReconcile(t *testing.T) {
WithRouteUID("12-34"),
// Populated by reconciliation when all traffic has been assigned.
WithURL, WithAddress, WithInitRouteConditions,
MarkTrafficAssigned, WithStatusTraffic(v1alpha1.TrafficTarget{
MarkTrafficAssigned, MarkIngressNotConfigured, WithStatusTraffic(v1alpha1.TrafficTarget{
TrafficTarget: v1beta1.TrafficTarget{
RevisionName: "config-00001",
Percent: 100,
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestReconcile(t *testing.T) {
WithRouteUID("12-34"), WithIngressClass("custom-ingress-class"),
// Populated by reconciliation when all traffic has been assigned.
WithURL, WithAddress, WithInitRouteConditions,
MarkTrafficAssigned, WithStatusTraffic(v1alpha1.TrafficTarget{
MarkTrafficAssigned, MarkIngressNotConfigured, WithStatusTraffic(v1alpha1.TrafficTarget{
TrafficTarget: v1beta1.TrafficTarget{
RevisionName: "config-00001",
Percent: 100,
Expand Down Expand Up @@ -274,7 +274,7 @@ func TestReconcile(t *testing.T) {
// Populated by reconciliation when all traffic has been assigned.
WithLocalDomain, WithAddress, WithInitRouteConditions,
WithRouteLabel("serving.knative.dev/visibility", "cluster-local"),
MarkTrafficAssigned, WithStatusTraffic(v1alpha1.TrafficTarget{
MarkTrafficAssigned, MarkIngressNotConfigured, WithStatusTraffic(v1alpha1.TrafficTarget{
TrafficTarget: v1beta1.TrafficTarget{
RevisionName: "config-00001",
Percent: 100,
Expand Down Expand Up @@ -1273,7 +1273,7 @@ func TestReconcile(t *testing.T) {
},
}), WithRouteUID("34-78"),
WithURL, WithAddress, WithInitRouteConditions,
MarkTrafficAssigned, WithStatusTraffic(
MarkTrafficAssigned, MarkIngressNotConfigured, WithStatusTraffic(
v1alpha1.TrafficTarget{
TrafficTarget: v1beta1.TrafficTarget{
RevisionName: "blue-00001",
Expand Down Expand Up @@ -1434,7 +1434,7 @@ func TestReconcile(t *testing.T) {
},
}), WithRouteUID("1-2"), WithRouteFinalizer,
WithURL, WithAddress, WithInitRouteConditions,
MarkTrafficAssigned, WithStatusTraffic(
MarkTrafficAssigned, MarkIngressNotConfigured, WithStatusTraffic(
v1alpha1.TrafficTarget{
TrafficTarget: v1beta1.TrafficTarget{
Tag: "gray",
Expand Down Expand Up @@ -1948,7 +1948,7 @@ func TestReconcile_EnableAutoTLS(t *testing.T) {
WithRouteUID("12-34"),
// Populated by reconciliation when all traffic has been assigned.
WithURL, WithAddress, WithInitRouteConditions,
MarkTrafficAssigned, WithStatusTraffic(v1alpha1.TrafficTarget{
MarkTrafficAssigned, MarkIngressNotConfigured, WithStatusTraffic(v1alpha1.TrafficTarget{
TrafficTarget: v1beta1.TrafficTarget{
RevisionName: "config-00001",
Percent: 100,
Expand Down Expand Up @@ -2027,7 +2027,7 @@ func TestReconcile_EnableAutoTLS(t *testing.T) {
WithRouteUID("12-34"),
// Populated by reconciliation when all traffic has been assigned.
WithAddress, WithInitRouteConditions,
MarkTrafficAssigned, WithStatusTraffic(v1alpha1.TrafficTarget{
MarkTrafficAssigned, MarkIngressNotConfigured, WithStatusTraffic(v1alpha1.TrafficTarget{
TrafficTarget: v1beta1.TrafficTarget{
RevisionName: "config-00001",
Percent: 100,
Expand Down
5 changes: 5 additions & 0 deletions pkg/testing/v1alpha1/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ func MarkIngressReady(r *v1alpha1.Route) {
})
}

// MarkIngressNotConfigured calls the method of the same name on .Status
func MarkIngressNotConfigured(r *v1alpha1.Route) {
r.Status.MarkIngressNotConfigured()
}

// MarkMissingTrafficTarget calls the method of the same name on .Status
func MarkMissingTrafficTarget(kind, revision string) RouteOption {
return func(r *v1alpha1.Route) {
Expand Down

0 comments on commit c01795f

Please sign in to comment.