From 4ab91066d091350a64746c558d5edcd02b82069b Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Wed, 15 Jun 2016 14:42:24 +0200 Subject: [PATCH] Allow emitting PersistentVolume events. Similarly to Nodes, PersistentVolumes are not in any namespace and we should not block events on them. Currently, these events are rejected with 'Event "nfs.145841cf9c8cfaf0" is invalid: involvedObject.namespace: Invalid value: "": does not match involvedObject' --- pkg/api/validation/events.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/api/validation/events.go b/pkg/api/validation/events.go index 1182429582..0a5de5443b 100644 --- a/pkg/api/validation/events.go +++ b/pkg/api/validation/events.go @@ -25,15 +25,16 @@ import ( // ValidateEvent makes sure that the event makes sense. func ValidateEvent(event *api.Event) field.ErrorList { allErrs := field.ErrorList{} - // There is no namespace required for node. + // There is no namespace required for node or persistent volume. // However, older client code accidentally sets event.Namespace // to api.NamespaceDefault, so we accept that too, but "" is preferred. - if event.InvolvedObject.Kind == "Node" && + if (event.InvolvedObject.Kind == "Node" || event.InvolvedObject.Kind == "PersistentVolume") && event.Namespace != api.NamespaceDefault && event.Namespace != "" { allErrs = append(allErrs, field.Invalid(field.NewPath("involvedObject", "namespace"), event.InvolvedObject.Namespace, "not allowed for node")) } if event.InvolvedObject.Kind != "Node" && + event.InvolvedObject.Kind != "PersistentVolume" && event.Namespace != event.InvolvedObject.Namespace { allErrs = append(allErrs, field.Invalid(field.NewPath("involvedObject", "namespace"), event.InvolvedObject.Namespace, "does not match involvedObject")) }