The function shouldRecordEvent will panic when the value of input object is nil

This commit is contained in:
Sergey Kanzhelev
2020-10-16 21:13:49 +00:00
parent b2de4a6159
commit 6c2556c5c4
2 changed files with 27 additions and 3 deletions

View File

@@ -191,10 +191,11 @@ type innerEventRecorder struct {
}
func (irecorder *innerEventRecorder) shouldRecordEvent(object runtime.Object) (*v1.ObjectReference, bool) {
if object == nil {
return nil, false
}
if ref, ok := object.(*v1.ObjectReference); ok {
// this check is needed AFTER the cast. See https://github.com/kubernetes/kubernetes/issues/95552
if ref == nil {
return nil, false
}
if !strings.HasPrefix(ref.FieldPath, ImplicitContainerPrefix) {
return ref, true
}