@@ -11,7 +11,6 @@ import (
1111 "time"
1212
1313 "github.com/openshift/library-go/pkg/controller/factory"
14- "github.com/openshift/library-go/pkg/operator/events"
1514 "github.com/openshift/library-go/pkg/operator/resource/resourcehelper"
1615 "github.com/openshift/library-go/pkg/operator/resource/resourcemerge"
1716 apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
@@ -169,11 +168,12 @@ func DeleteAppliedResources(
169168 resources []workapiv1.AppliedManifestResourceMeta ,
170169 reason string ,
171170 dynamicClient dynamic.Interface ,
172- recorder events.Recorder ,
173171 owner metav1.OwnerReference ) ([]workapiv1.AppliedManifestResourceMeta , []error ) {
174172 var resourcesPendingFinalization []workapiv1.AppliedManifestResourceMeta
175173 var errs []error
176174
175+ logger := klog .FromContext (ctx )
176+
177177 // set owner to be removed
178178 ownerCopy := owner .DeepCopy ()
179179 ownerCopy .UID = types .UID (fmt .Sprintf ("%s-" , owner .UID ))
@@ -190,7 +190,8 @@ func DeleteAppliedResources(
190190 Namespace (resource .Namespace ).
191191 Get (ctx , resource .Name , metav1.GetOptions {})
192192 if errors .IsNotFound (err ) {
193- klog .Infof ("Resource %v with key %s/%s is removed Successfully" , gvr , resource .Namespace , resource .Name )
193+ logger .Info ("Resource is removed Successfully" ,
194+ "gvr" , gvr , "resourceNamespace" , resource .Namespace , "resourceName" , resource .Name )
194195 continue
195196 }
196197
@@ -256,7 +257,8 @@ func DeleteAppliedResources(
256257 }
257258
258259 resourcesPendingFinalization = append (resourcesPendingFinalization , resource )
259- recorder .Eventf ("ResourceDeleted" , "Deleted resource %v with key %s/%s because %s." , gvr , resource .Namespace , resource .Name , reason )
260+ logger .Info ("Deleted resource" ,
261+ "gvr" , gvr , "resourceNamespace" , resource .Namespace , "resourceName" , resource .Name , "reason" , reason )
260262 }
261263
262264 return resourcesPendingFinalization , errs
@@ -409,6 +411,8 @@ func FindManifestCondition(resourceMeta workapiv1.ManifestResourceMeta, manifest
409411
410412func ApplyOwnerReferences (ctx context.Context , dynamicClient dynamic.Interface , gvr schema.GroupVersionResource ,
411413 existing runtime.Object , requiredOwner metav1.OwnerReference ) error {
414+ logger := klog .FromContext (ctx )
415+
412416 accessor , err := meta .Accessor (existing )
413417 if err != nil {
414418 return fmt .Errorf ("type %t cannot be accessed: %v" , existing , err )
@@ -432,7 +436,8 @@ func ApplyOwnerReferences(ctx context.Context, dynamicClient dynamic.Interface,
432436 return err
433437 }
434438
435- klog .V (2 ).Infof ("Patching resource %v %s/%s with patch %s" , gvr , accessor .GetNamespace (), accessor .GetName (), string (patchData ))
439+ logger .V (2 ).Info ("Patching resource" ,
440+ "gvr" , gvr , "resourceNamespace" , accessor .GetNamespace (), "resourceName" , accessor .GetName (), "patch" , string (patchData ))
436441 _ , err = dynamicClient .Resource (gvr ).Namespace (accessor .GetNamespace ()).Patch (ctx , accessor .GetName (), types .MergePatchType , patchData , metav1.PatchOptions {})
437442 return err
438443}
0 commit comments