diff --git a/pkg/policyviolation/builder.go b/pkg/policyviolation/builder.go index e886f819f5..647dcbfacd 100644 --- a/pkg/policyviolation/builder.go +++ b/pkg/policyviolation/builder.go @@ -26,8 +26,11 @@ func newPvBuilder(dclient *client.Client) *pvBuilder { return &pvb } func (pvb *pvBuilder) generate(info Info) []kyverno.PolicyViolation { + // https://github.com/nirmata/kyverno/issues/535 var owners []kyverno.ResourceSpec - if !info.Blocked { + // get the owners if the resource is blocked or + // the resource does not have a name assigned yet(uses generateName) + if info.Blocked || info.Resource.GetName() == "" { // get resource owners owners = GetOwners(pvb.dclient, info.Resource) }