Skip to content

Conversation

@kashifest
Copy link
Member

We should check if bootstrapReadyCondition is nil or not before checking bootstrapReadyCondition.Status

What this PR does / why we need it:

Fixes #2956

Checklist:

  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • E2E tests have been added, if necessary.
  • Integration tests have been added, if necessary.

We should check if bootstrapReadyCondition is nil or not before checking bootstrapReadyCondition.Status
Signed-off-by: Kashif Khan <[email protected]>
@metal3-io-bot metal3-io-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 19, 2025
@kashifest kashifest changed the title Fix nil pointer issue while checking bootstrapReadyCondition 🐛 :Fix nil pointer issue while checking bootstrapReadyCondition Nov 19, 2025
@kashifest kashifest changed the title 🐛 :Fix nil pointer issue while checking bootstrapReadyCondition 🐛 Fix nil pointer issue while checking bootstrapReadyCondition Nov 19, 2025
@kashifest
Copy link
Member Author

/test metal3-ubuntu-e2e-integration-test-main metal3-centos-e2e-integration-test-main

@kashifest
Copy link
Member Author

@adilGhaffarDev @fmuyassarov @lentzi90 I think this fixes the nil pointer issue as I dont see the error in the controller logs anymore. However, PTAL also yourself and also the worth checking, is it now suppressing any log info.

@tuminoid tuminoid requested a review from Copilot November 20, 2025 08:11
Copilot finished reviewing on behalf of tuminoid November 20, 2025 08:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes nil pointer dereference issues when checking bootstrap and infrastructure ready conditions by adding nil checks before accessing condition properties.

  • Added nil checks before accessing Status field on conditions retrieved via Get() method
  • Introduced test coverage for the scenario where ConfigRef is defined but the condition is not set

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
controllers/metal3machine_controller.go Added nil check for infrastructureReadyCondition before accessing its Status field
baremetal/metal3machine_manager.go Added nil check for bootstrapReadyCondition before accessing its Status field
baremetal/metal3machine_manager_test.go Added test case to verify behavior when ConfigRef is defined but condition is not set

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@lentzi90 lentzi90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. We will at some point need to add v1beta2 conditions, and then change this so we also check them, but for now I think it is correct.
/approve

@metal3-io-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lentzi90

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:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@metal3-io-bot metal3-io-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 20, 2025
Copy link
Member

@tuminoid tuminoid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Backports?

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label Nov 20, 2025
@metal3-io-bot metal3-io-bot merged commit 226a422 into metal3-io:main Nov 20, 2025
34 of 35 checks passed
@metal3-io-bot metal3-io-bot deleted the fix/nil-pointer-kashif branch November 20, 2025 08:29
@metal3-io-bot metal3-io-bot added this to the CAPM3 - v1.12 milestone Nov 20, 2025
@adilGhaffarDev
Copy link
Member

Sorry, it got merged before I had a chance to review it. We need to use sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions instead of sigs.k8s.io/cluster-api/util/conditions/deprecated/v1beta1. That should fix the issue.

The difference is:

  • util/deprecated/v1beta1/conditions pulls conditions from sigs.k8s.io/cluster-api/api/core/v1beta1.
  • util/conditions/deprecated/v1beta1 pulls conditions from sigs.k8s.io/cluster-api/api/core/v1beta2.

Both packages expose v1beta1 conditions, but one sources them from the v1beta1 API and the other from the v1beta2 API. It’s a bit confusing, but this is how CAPI ensures that v1beta1 behavior continues to work during the transition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nil pointer issue in CAPM3 controller

5 participants