@@ -15,6 +15,7 @@ import (
1515 k8sErrors "k8s.io/apimachinery/pkg/api/errors"
1616 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
1717 "k8s.io/apimachinery/pkg/runtime"
18+ "k8s.io/klog/v2"
1819 ctrl "sigs.k8s.io/controller-runtime"
1920 "sigs.k8s.io/controller-runtime/pkg/client"
2021 "sigs.k8s.io/controller-runtime/pkg/manager"
@@ -73,6 +74,7 @@ func (handler *Handler) CreateOrUpdate(ctx context.Context, scheme *runtime.Sche
7374 err := handler .Client .Get (ctx , client .ObjectKeyFromObject (obj ), u )
7475 if err != nil {
7576 if k8sErrors .IsNotFound (err ) {
77+ logger .V (1 ).Info ("creating managed resource" , "resource" , klog .KObj (obj ))
7678 return handler .Create (ctx , obj )
7779 }
7880 return emperror .Wrapf (err , "failed to get %s %s" , obj .GetObjectKind ().GroupVersionKind ().Kind , obj .GetName ())
@@ -142,7 +144,7 @@ func (handler *Handler) CreateOrUpdate(ctx context.Context, scheme *runtime.Sche
142144 return emperror .Wrapf (err , "failed to calculate patch for %s %s" , obj .GetObjectKind ().GroupVersionKind ().Kind , obj .GetName ())
143145 }
144146 if ! patchResult .IsEmpty () {
145- logger .Info ("Will update EMQX sub- resource" , "sub- resource" , obj . GetObjectKind (). GroupVersionKind (). GroupKind (). String (), "name" , obj . GetName ( ), "patch" , string (patchResult .Patch ))
147+ logger .V ( 1 ). Info ("updating managed resource" , "resource" , klog . KObj ( obj ), "patch" , string (patchResult .Patch ))
146148 return handler .Update (ctx , obj )
147149 }
148150 return nil
0 commit comments