From 8d0fe0ccc9e65e22946e347cb398828fe091ecba Mon Sep 17 00:00:00 2001 From: Zhiwei Huang Date: Mon, 14 Oct 2024 17:42:59 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20listing=20ironic=20node=20?= =?UTF-8?q?ports=20with=20empty=20mac=20address?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zhiwei Huang --- pkg/provisioner/ironic/ironic.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/provisioner/ironic/ironic.go b/pkg/provisioner/ironic/ironic.go index 4446e2cdda..efc1e6658d 100644 --- a/pkg/provisioner/ironic/ironic.go +++ b/pkg/provisioner/ironic/ironic.go @@ -139,14 +139,15 @@ func (p *ironicProvisioner) validateNode(ironicNode *nodes.Node) (errorMessage s func (p *ironicProvisioner) listAllPorts(address string) ([]ports.Port, error) { var allPorts []ports.Port - opts := ports.ListOpts{ - Fields: []string{"node_uuid"}, + // Don't call the ironic api when the port mac address is empty. + if address == "" { + return allPorts, nil } - if address != "" { - opts.Address = address + opts := ports.ListOpts{ + Fields: []string{"node_uuid"}, + Address: address, } - pager := ports.List(p.client, opts) allPages, err := pager.AllPages(p.ctx)