From 8c8110735e965bcd236be3497de8cc41b6b98eab Mon Sep 17 00:00:00 2001 From: Kirsten Laskoski Date: Fri, 22 Nov 2024 15:06:04 -0500 Subject: [PATCH] ocm: add logs to get errors (#793) Similar to a change from #763, Exist can return true even if Get returns an error, causing Pull to succeed but Definition to be nil. By adding a log to Get, this error is no longer silent and has a more obvious root cause. --- pkg/ocm/placementbinding.go | 3 +++ pkg/ocm/placementrule.go | 3 +++ pkg/ocm/policy.go | 3 +++ pkg/ocm/policyset.go | 3 +++ 4 files changed, 12 insertions(+) diff --git a/pkg/ocm/placementbinding.go b/pkg/ocm/placementbinding.go index eef2f309f..db98f3cf5 100644 --- a/pkg/ocm/placementbinding.go +++ b/pkg/ocm/placementbinding.go @@ -160,6 +160,9 @@ func (builder *PlacementBindingBuilder) Get() (*policiesv1.PlacementBinding, err }, placementBinding) if err != nil { + glog.V(100).Infof("Failed to get placementBinding %s in namespace %s: %v", + builder.Definition.Name, builder.Definition.Namespace, err) + return nil, err } diff --git a/pkg/ocm/placementrule.go b/pkg/ocm/placementrule.go index 2980259d7..75fea155b 100644 --- a/pkg/ocm/placementrule.go +++ b/pkg/ocm/placementrule.go @@ -150,6 +150,9 @@ func (builder *PlacementRuleBuilder) Get() (*placementrulev1.PlacementRule, erro }, placementRule) if err != nil { + glog.V(100).Infof("Failed to get placementrule %s in namespace %s: %v", + builder.Definition.Name, builder.Definition.Namespace, err) + return nil, err } diff --git a/pkg/ocm/policy.go b/pkg/ocm/policy.go index dc7e45978..784d886f0 100644 --- a/pkg/ocm/policy.go +++ b/pkg/ocm/policy.go @@ -163,6 +163,9 @@ func (builder *PolicyBuilder) Get() (*policiesv1.Policy, error) { }, policy) if err != nil { + glog.V(100).Infof("Failed to get policy %s in namespace %s: %v", + builder.Definition.Name, builder.Definition.Namespace, err) + return nil, err } diff --git a/pkg/ocm/policyset.go b/pkg/ocm/policyset.go index 9dbb8d68f..87f6b1139 100644 --- a/pkg/ocm/policyset.go +++ b/pkg/ocm/policyset.go @@ -160,6 +160,9 @@ func (builder *PolicySetBuilder) Get() (*policiesv1beta1.PolicySet, error) { }, policySet) if err != nil { + glog.V(100).Infof("Failed to get policySet %s in namespace %s: %v", + builder.Definition.Name, builder.Definition.Namespace, err) + return nil, err }