kubernetes-sigs / cluster-api-provider-azure

Cluster API implementation for Microsoft Azure
https://capz.sigs.k8s.io/
Apache License 2.0
287 stars 414 forks source link

fix: panic in MachinePool log #4942

Closed mweibel closed 4 days ago

mweibel commented 6 days ago

What type of PR is this? /kind bug

What this PR does / why we need it: Fixes a panic when trying to delete a machine where there is no OwnerMachine available anymore. The log statement was wrong in that it didn't specify a key for the value.

Special notes for your reviewer: partial panic log - note, the line numbers are a bit off since I'm running on a fork containing multiple changes which will be submitted as separate PRs today


panic: runtime error: hash of unhashable type v1beta1.AzureMachinePoolMachine [recovered]
       panic: runtime error: hash of unhashable type v1beta1.AzureMachinePoolMachine
manager
goroutine 623 [running]:
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile.func1()
       /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.3/pkg/internal/controller/controller.go:116 +0x1e5
panic({0x2c8dae0?, 0xc001f6ad70?})
       /usr/local/go/src/runtime/panic.go:914 +0x21f
k8s.io/klog/v2/internal/serialize.MergeKVs({0xc002170120, 0x12, 0x0?}, {0xc009c69cc0, 0x2, 0xc0023c4cf0?})
       /go/pkg/mod/k8s.io/klog/v2@v2.120.1/internal/serialize/keyvalues.go:82 +0x134
k8s.io/klog/v2.(*klogger).Info(0xc00088d740, 0x2, {0x328e1ca, 0x33}, {0xc009c69cc0?, 0x40e578?, 0x2cd9ae0?})
       /go/pkg/mod/k8s.io/klog/v2@v2.120.1/klogr.go:56 +0x5a
sigs.k8s.io/cluster-api-provider-azure/util/tele.(*compositeLogSink).Info.func1(...)
       /workspace/util/tele/composite_logger.go:54
sigs.k8s.io/cluster-api-provider-azure/util/tele.(*compositeLogSink).iter(...)
       /workspace/util/tele/composite_logger.go:48
sigs.k8s.io/cluster-api-provider-azure/util/tele.(*compositeLogSink).Info(0xc000079000?, 0x2, {0x328e1ca, 0x33}, {0xc009c69cc0, 0x2, 0x2})
       /workspace/util/tele/composite_logger.go:53 +0x69
github.com/go-logr/logr.Logger.Info({{0x36a7338?, 0xc00a631da0?}, 0x0?}, {0x328e1ca, 0x33}, {0xc009c69cc0, 0x2, 0x2})
       /go/pkg/mod/github.com/go-logr/logr@v1.4.2/logr.go:280 +0xdc
sigs.k8s.io/cluster-api-provider-azure/azure/scope.(*MachinePoolScope).DeleteMachine(_, {_, _}, {{{0x29501e6, 0x17}, {0xc00213ced0, 0x27}}, {{0xc000dd2470, 0x9}, {0x0, ...}, ...}, ...})
       /workspace/azure/scope/machinepool.go:552 +0x45f
sigs.k8s.io/cluster-api-provider-azure/exp/controllers.(*AzureMachinePoolReconciler).reconcileDelete(0xc0005a54a0, {0x36a0b70?, 0xc0003b9ce0?}, 0xc0006cdef0, {0x36e00d8, 0xc006dd2000})
       /workspace/exp/controllers/azuremachinepool_controller.go:413 +0x850
sigs.k8s.io/cluster-api-provider-azure/exp/controllers.(*AzureMachinePoolReconciler).Reconcile(0xc0005a54a0, {0x36a0ac8?, 0xc008ef0210?}, {{{0xc000caaa40?, 0xa?}, {0xc000caaab7?, 0x0?}}})
       /workspace/exp/controllers/azuremachinepool_controller.go:254 +0xb45
sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing.(*reconciler).Reconcile(0xc0003ea400, {0x36a0ac8?, 0xc008ef0150?}, {{{0xc000caaa40?, 0x0?}, {0xc000caaab7?, 0xc001c77d08?}}})
       /workspace/pkg/coalescing/reconciler.go:109 +0x3eb
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile(0x36a6298?, {0x36a0ac8?, 0xc008ef0150?}, {{{0xc000caaa40?, 0xb?}, {0xc000caaab7?, 0x0?}}})
       /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.3/pkg/internal/controller/controller.go:119 +0xb7

TODOs:

Release note:

NONE
k8s-ci-robot commented 6 days ago

Hi @mweibel. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
jackfrancis commented 5 days ago

/ok-to-test

codecov[bot] commented 5 days ago

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 62.19%. Comparing base (44e0cd5) to head (749cb25). Report is 6 commits behind head on main.

Files Patch % Lines
azure/scope/machinepool.go 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #4942 +/- ## ======================================= Coverage 62.19% 62.19% ======================================= Files 201 201 Lines 16884 16884 ======================================= Hits 10501 10501 Misses 5592 5592 Partials 791 791 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

nawazkh commented 5 days ago

/lgtm Thank you

k8s-ci-robot commented 5 days ago

LGTM label has been added.

Git tree hash: 48780b30570491447b6bc5ab2aca7a3c5c8f5817

k8s-ci-robot commented 4 days ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mboersma

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/kubernetes-sigs/cluster-api-provider-azure/blob/main/OWNERS)~~ [mboersma] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment