Skip to content

Commit

Permalink
Merge pull request metal3-io#974 from dtantsur/lookup-log
Browse files Browse the repository at this point in the history
Add more context to node lookup logging
  • Loading branch information
metal3-io-bot authored Sep 20, 2021
2 parents 88aa058 + 8c75d5d commit 8e87262
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions pkg/provisioner/ironic/ironic.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ func (p *ironicProvisioner) nodeHasAssignedPort(ironicNode *nodes.Node) (bool, e
}

if empty {
p.debugLog.Info("node has no assigned port")
p.debugLog.Info("node has no assigned port", "node", ironicNode.UUID)
return false, nil
}

p.debugLog.Info("node has assigned port")
p.debugLog.Info("node has assigned port", "node", ironicNode.UUID)
return true, nil
}

Expand All @@ -213,7 +213,7 @@ func (p *ironicProvisioner) isAddressAllocatedToPort(address string) (bool, erro
return false, nil
}

p.debugLog.Info("address is allocated to port", "address", address)
p.debugLog.Info("address is allocated to port", "address", address, "node", allPorts[0].NodeUUID)
return true, nil
}

Expand All @@ -236,7 +236,7 @@ func (p *ironicProvisioner) findExistingHost(bootMACAddress string) (ironicNode
ironicNode, err = nodes.Get(p.client, nodeName).Extract()
switch err.(type) {
case nil:
p.debugLog.Info("found existing node by name")
p.debugLog.Info("found existing node by name", "name", nodeName, "node", ironicNode.UUID)
return ironicNode, nil
case gophercloud.ErrDefault404:
p.log.Info(
Expand All @@ -261,7 +261,7 @@ func (p *ironicProvisioner) findExistingHost(bootMACAddress string) (ironicNode
ironicNode, err = nodes.Get(p.client, nodeUUID).Extract()
switch err.(type) {
case nil:
p.debugLog.Info("found existing node by ID")
p.debugLog.Info("found existing node by MAC", "MAC", bootMACAddress, "node", ironicNode.UUID, "name", ironicNode.Name)

// If the node has a name, this means we didn't find it above.
if ironicNode.Name != "" {
Expand All @@ -271,10 +271,10 @@ func (p *ironicProvisioner) findExistingHost(bootMACAddress string) (ironicNode
return ironicNode, nil
case gophercloud.ErrDefault404:
return nil, errors.Wrap(err,
fmt.Sprintf("port exists but linked node doesn't %s", nodeUUID))
fmt.Sprintf("port %s exists but linked node doesn't %s", bootMACAddress, nodeUUID))
default:
return nil, errors.Wrap(err,
fmt.Sprintf("port exists but failed to find linked node by ID %s", nodeUUID))
fmt.Sprintf("port %s exists but failed to find linked node by ID %s", bootMACAddress, nodeUUID))
}
} else {
p.log.Info("port with address doesn't exist", "MAC", bootMACAddress)
Expand Down
2 changes: 1 addition & 1 deletion pkg/provisioner/ironic/validatemanagementaccess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ func TestValidateManagementAccessExistingPortWithWrongUUID(t *testing.T) {
}

_, _, err = prov.ValidateManagementAccess(provisioner.ManagementAccessData{}, false, false)
assert.EqualError(t, err, "failed to find existing host: port exists but linked node doesn't random-wrong-id: Resource not found")
assert.EqualError(t, err, "failed to find existing host: port 11:11:11:11:11:11 exists but linked node doesn't random-wrong-id: Resource not found")
}

func TestValidateManagementAccessExistingPortButHasName(t *testing.T) {
Expand Down

0 comments on commit 8e87262

Please sign in to comment.