Skip to content

Commit 1ae0315

Browse files
authored
fix: log mutation failure errors (#649)
**What problem does this PR solve?**: When a mutation fails the CAREN logs does not have any information. we have to refer to capi-controller's logs to see error returned by CAREN hooks. We should log mutation failure logs in CAREN. **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> By forcing an error and checking the logs. ``` E0510 02:17:47.751160 1 generator.go:65] "failed to apply mutation" err="forced logging of error" template="infrastructure.cluster.x-k8s.io/v1beta1/DockerMachineTemplate" holder="controlplane.cluster.x-k8s.io/v1beta1/KubeadmControlPlane/default/shalin-docker-jsbhl" holderRef={"apiVersion":"controlplane.cluster.x-k8s.io/v1beta1","kind":"KubeadmControlPlane","namespace":"default","name":"shalin-docker-jsbhl","fieldPath":"spec.machineTemplate.infrastructureRef"} variableName="clusterConfig" variableFieldPath=["controlPlane","docker","customImage"] variableValue="" objKind="infrastructure.cluster.x-k8s.io/v1beta1, Kind=DockerMachineTemplate" objName="docker-quick-start-control-plane" ``` **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. --> should we also log error at top level `GeneratePatches` functions. https://github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/blob/main/common/pkg/capi/clustertopology/handlers/mutation/meta.go#L103
1 parent 4f7b8dd commit 1ae0315

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

common/pkg/capi/clustertopology/patches/generator.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ func MutateIfApplicable[T runtime.Object](
5959

6060
// Apply the mutation.
6161
if err := mutFn(typed); err != nil {
62+
log.WithValues(
63+
"objKind", obj.GetObjectKind().GroupVersionKind(),
64+
"objName", obj.GetName(),
65+
).Error(err, "failed to apply mutation")
6266
return fmt.Errorf("failed to apply mutation: %w", err)
6367
}
6468

0 commit comments

Comments
 (0)