@@ -14,6 +14,7 @@ import (
1414 clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
1515 runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1"
1616 "sigs.k8s.io/cluster-api/exp/runtime/topologymutation"
17+ ctrl "sigs.k8s.io/controller-runtime"
1718 "sigs.k8s.io/controller-runtime/pkg/client"
1819
1920 "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers"
@@ -99,12 +100,27 @@ func (mgp metaGeneratePatches) GeneratePatches(
99100 vars map [string ]apiextensionsv1.JSON ,
100101 holderRef runtimehooksv1.HolderReference ,
101102 ) error {
102- for _ , h := range mgp .mutators {
103+ log := ctrl .LoggerFrom (ctx ).WithValues (
104+ "holderRef" , holderRef ,
105+ "objectKind" , obj .GetObjectKind ().GroupVersionKind ().String (),
106+ "handlerName" , mgp .name ,
107+ )
108+
109+ log .V (3 ).Info ("Starting mutation pipeline" , "handlerCount" , len (mgp .mutators ))
110+
111+ for i , h := range mgp .mutators {
112+ handlerName := fmt .Sprintf ("%T" , h )
113+ log .V (5 ).Info ("Running mutator" , "index" , i , "handler" , handlerName )
114+
103115 if err := h .Mutate (ctx , obj .(* unstructured.Unstructured ), vars , holderRef , clusterKey , clusterGetter ); err != nil {
116+ log .Error (err , "Mutator failed" , "index" , i , "handler" , handlerName )
104117 return err
105118 }
119+
120+ log .V (5 ).Info ("Mutator completed successfully" , "index" , i , "handler" , handlerName )
106121 }
107122
123+ log .V (3 ).Info ("Mutation pipeline completed successfully" , "handlerCount" , len (mgp .mutators ))
108124 return nil
109125 },
110126 )
0 commit comments