Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix looking for existing node by MAC #2088

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hex2dec
Copy link
Contributor

@hex2dec hex2dec commented Nov 28, 2024

What this PR does / why we need it:

Fix listing ironic node's ports with empty mac address. Call the listing ports API with empty mac address is same as listing all ironic node ports.

@metal3-io-bot metal3-io-bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 28, 2024
@metal3-io-bot
Copy link
Contributor

Hi @hex2dec. Thanks for your PR.

I'm waiting for a metal3-io 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. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@metal3-io-bot metal3-io-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 28, 2024
@hex2dec hex2dec changed the title 🐛 Fix listing ironic node's ports with empty mac address 🐛 Fix listing ironic node ports with empty mac address Nov 28, 2024
@tuminoid
Copy link
Member

/ok-to-test

@metal3-io-bot metal3-io-bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 28, 2024
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.

I don't know this area well enough to review.
/cc @dtantsur

@tuminoid
Copy link
Member

tuminoid commented Dec 5, 2024

/cc @elfosardo @zaneb

@metal3-io-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kashifest for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 8, 2025
Add null check for bootMACAddress to prevent unnecessary port listing
when finding an existing Ironic node.

Signed-off-by: Zhiwei Huang <[email protected]>
@hex2dec hex2dec changed the title 🐛 Fix listing ironic node ports with empty mac address 🐛 Fix looking for existing node by MAC Feb 8, 2025
p.log.Info("looking for existing node by MAC", "MAC", bootMACAddress)
allPorts, err := p.listAllPorts(bootMACAddress)
// If mac address is present in host config, try to load the node by this port with mac address.
if bootMACAddress != "" {
Copy link
Member

Choose a reason for hiding this comment

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

nit: an early return here would be easier to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a good coding tip 😃 . From the findExistingHost function, it supports multiple methods to find an existing node, and other methods may be added in the future, the early return is not very good at showing the order in which all methods were tried. Therefore, it is recommended to use the method to find an node by port only when the value of bootMACAddress is present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants