event: improve logging on recording failure

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
pull/6/head
Federico Simoncelli 2015-04-01 09:23:16 -04:00
parent c627a3598c
commit b276132e21
1 changed files with 4 additions and 8 deletions

View File

@ -155,24 +155,20 @@ func recordEvent(sink EventSink, event *api.Event, updateExistingEvent bool) boo
// If we can't contact the server, then hold everything while we keep trying.
// Otherwise, something about the event is malformed and we should abandon it.
giveUp := false
switch err.(type) {
case *client.RequestConstructionError:
// We will construct the request the same next time, so don't keep trying.
giveUp = true
glog.Errorf("Unable to construct event '%#v': '%v' (will not retry!)", event, err)
return true
case *errors.StatusError:
// This indicates that the server understood and rejected our request.
giveUp = true
glog.Errorf("Server rejected event '%#v': '%v' (will not retry!)", event, err)
return true
case *errors.UnexpectedObjectError:
// We don't expect this; it implies the server's response didn't match a
// known pattern. Go ahead and retry.
default:
// This case includes actual http transport errors. Go ahead and retry.
}
if giveUp {
glog.Errorf("Unable to write event '%#v': '%v' (will not retry!)", event, err)
return true
}
glog.Errorf("Unable to write event: '%v' (may retry after sleeping)", err)
return false
}