mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 13:31:52 +00:00
event: improve logging on recording failure
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
This commit is contained in:
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.
|
// 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.
|
// Otherwise, something about the event is malformed and we should abandon it.
|
||||||
giveUp := false
|
|
||||||
switch err.(type) {
|
switch err.(type) {
|
||||||
case *client.RequestConstructionError:
|
case *client.RequestConstructionError:
|
||||||
// We will construct the request the same next time, so don't keep trying.
|
// 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:
|
case *errors.StatusError:
|
||||||
// This indicates that the server understood and rejected our request.
|
glog.Errorf("Server rejected event '%#v': '%v' (will not retry!)", event, err)
|
||||||
giveUp = true
|
return true
|
||||||
case *errors.UnexpectedObjectError:
|
case *errors.UnexpectedObjectError:
|
||||||
// We don't expect this; it implies the server's response didn't match a
|
// We don't expect this; it implies the server's response didn't match a
|
||||||
// known pattern. Go ahead and retry.
|
// known pattern. Go ahead and retry.
|
||||||
default:
|
default:
|
||||||
// This case includes actual http transport errors. Go ahead and retry.
|
// 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)
|
glog.Errorf("Unable to write event: '%v' (may retry after sleeping)", err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user