1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-31 03:45:17 +00:00

Do not log error when resource is not namespaced ()

Signed-off-by: Jose Armesto <github@armesto.net>
This commit is contained in:
Jose Armesto 2021-11-17 15:09:00 +01:00 committed by GitHub
parent f90b982903
commit 1ff16ba5d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions
pkg
common
policy

View file

@ -53,7 +53,7 @@ func GetNamespaceSelectorsFromGenericInformer(kind, namespaceOfResource string,
// GetNamespaceSelectorsFromNamespaceLister - extract the namespacelabels when namespace lister is passed
func GetNamespaceSelectorsFromNamespaceLister(kind, namespaceOfResource string, nsLister listerv1.NamespaceLister, logger logr.Logger) map[string]string {
namespaceLabels := make(map[string]string)
if kind != "Namespace" {
if kind != "Namespace" && namespaceOfResource != "" {
namespaceObj, err := nsLister.Get(namespaceOfResource)
if err != nil {
log.Log.Error(err, "failed to get the namespace", "name", namespaceOfResource)

View file

@ -172,7 +172,7 @@ func (pc *PolicyController) getResourceList(kind, namespace string, labelSelecto
resourceList, err := pc.client.ListResource("", kind, namespace, labelSelector)
if err != nil {
log.Error(err, "failed to list resources", "kind")
log.Error(err, "failed to list resources", "kind", kind, "namespace", namespace)
return nil
}