mirror of https://github.com/k3s-io/k3s
event: improve logging on recording failure
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>pull/6/head
parent
c627a3598c
commit
b276132e21
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue