Browse code

Merge pull request #7275 from smarterclayton/suppress_error

Merged by openshift-bot

OpenShift Bot authored on 2016/02/19 06:27:51
Showing 2 changed files
... ...
@@ -148,21 +148,26 @@ func (a *StatusAdmitter) hasIngressBeenTouched(route *routeapi.Route, lastTouch
148 148
 	return true
149 149
 }
150 150
 
151
-// recordIngressTouch
152
-func (a *StatusAdmitter) recordIngressTouch(route *routeapi.Route, touch *unversioned.Time, err error) {
151
+// recordIngressTouch tracks whether the ingress record updated succeeded and returns true if the admitter can
152
+// continue. Conflict errors are treated as no error, but indicate the touch was not successful and the caller
153
+// should retry.
154
+func (a *StatusAdmitter) recordIngressTouch(route *routeapi.Route, touch *unversioned.Time, err error) (bool, error) {
153 155
 	switch {
154 156
 	case err == nil:
155 157
 		if touch != nil {
156 158
 			a.expected.Add(route.UID, touch.Time)
157 159
 		}
160
+		return true, nil
158 161
 	case errors.IsConflict(err):
159 162
 		a.expected.Add(route.UID, time.Time{})
163
+		return false, nil
160 164
 	}
165
+	return false, err
161 166
 }
162 167
 
163 168
 // admitRoute returns true if the route has already been accepted to this router, or
164 169
 // updates the route to contain an accepted condition. Returns an error if the route could
165
-// not be admitted.
170
+// not be admitted due to a failure, or false if the route can't be admitted at this time.
166 171
 func (a *StatusAdmitter) admitRoute(oc client.RoutesNamespacer, route *routeapi.Route, name string) (bool, error) {
167 172
 	ingress, updated := findOrCreateIngress(route, name)
168 173
 	if !updated {
... ...
@@ -186,8 +191,7 @@ func (a *StatusAdmitter) admitRoute(oc client.RoutesNamespacer, route *routeapi.
186 186
 	})
187 187
 	glog.V(4).Infof("admit: admitting route by updating status: %s (%t): %s", route.Name, updated, route.Spec.Host)
188 188
 	_, err := oc.Routes(route.Namespace).UpdateStatus(route)
189
-	a.recordIngressTouch(route, ingress.Conditions[0].LastTransitionTime, err)
190
-	return err == nil, err
189
+	return a.recordIngressTouch(route, ingress.Conditions[0].LastTransitionTime, err)
191 190
 }
192 191
 
193 192
 // RecordRouteRejection attempts to update the route status with a reason for a route being rejected.
... ...
@@ -159,8 +159,8 @@ func TestStatusBackoffOnConflict(t *testing.T) {
159 159
 		t.Fatalf("unexpected condition: %#v", condition)
160 160
 	}
161 161
 
162
-	if err == nil {
163
-		t.Fatalf("unexpected non-error: %#v", admitter.expected)
162
+	if err != nil {
163
+		t.Fatalf("unexpected error: %#v", err)
164 164
 	}
165 165
 	if v, ok := admitter.expected.Peek(types.UID("uid1")); !ok || !reflect.DeepEqual(v, time.Time{}) {
166 166
 		t.Fatalf("expected empty time: %#v", v)