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

🐛 Log node updates with a normal logger #1420

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions pkg/provisioner/ironic/ironic.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func (p *ironicProvisioner) ValidateManagementAccess(data provisioner.Management
}

var ironicNode *nodes.Node
updater := updateOptsBuilder(p.debugLog)
updater := updateOptsBuilder(p.log)

p.debugLog.Info("validating management access")

Expand Down Expand Up @@ -541,7 +541,7 @@ func (p *ironicProvisioner) ValidateManagementAccess(data provisioner.Management
}

func (p *ironicProvisioner) configureImages(data provisioner.ManagementAccessData, ironicNode *nodes.Node, bmcAccess bmc.AccessDetails) (result provisioner.Result, err error) {
updater := updateOptsBuilder(p.debugLog)
updater := updateOptsBuilder(p.log)

deployImageInfo := setDeployImage(p.config, bmcAccess, data.PreprovisioningImage)
updater.SetDriverInfoOpts(deployImageInfo, ironicNode)
Expand Down Expand Up @@ -710,13 +710,13 @@ func (p *ironicProvisioner) tryUpdateNode(ironicNode *nodes.Node, updater *nodeU
return
}

p.log.Info("updating node settings in ironic")
p.log.Info("updating node settings in ironic", "updateCount", len(updater.Updates))
updatedNode, err = nodes.Update(p.client, ironicNode.UUID, updater.Updates).Extract()
switch err.(type) {
case nil:
success = true
case gophercloud.ErrDefault409:
p.log.Info("could not update node settings in ironic, busy")
p.log.Info("could not update node settings in ironic, busy or update cannot be applied in the current state")
result, err = retryAfterDelay(provisionRequeueDelay)
default:
result, err = transientError(errors.Wrap(err, "failed to update host settings in ironic"))
Expand Down Expand Up @@ -780,7 +780,7 @@ func (p *ironicProvisioner) abortInspection(ironicNode *nodes.Node) (result prov
func (p *ironicProvisioner) startInspection(data provisioner.InspectData, ironicNode *nodes.Node) (result provisioner.Result, started bool, err error) {
_, started, result, err = p.tryUpdateNode(
ironicNode,
updateOptsBuilder(p.debugLog).
updateOptsBuilder(p.log).
SetPropertiesOpts(optionsData{
"capabilities": buildCapabilitiesValue(ironicNode, data.BootMode),
}, ironicNode),
Expand Down Expand Up @@ -1042,7 +1042,7 @@ func (p *ironicProvisioner) getImageUpdateOptsForNode(ironicNode *nodes.Node, im
}

func (p *ironicProvisioner) getUpdateOptsForNode(ironicNode *nodes.Node, data provisioner.ProvisionData) *nodeUpdater {
updater := updateOptsBuilder(p.debugLog)
updater := updateOptsBuilder(p.log)

hasCustomDeploy := data.CustomDeploy != nil && data.CustomDeploy.Method != ""
p.getImageUpdateOptsForNode(ironicNode, &data.Image, data.BootMode, hasCustomDeploy, updater)
Expand Down Expand Up @@ -1798,7 +1798,7 @@ func (p *ironicProvisioner) Delete() (result provisioner.Result, err error) {
// Make sure we don't have a stale instance UUID
if ironicNode.InstanceUUID != "" {
p.log.Info("removing stale instance UUID before deletion", "instanceUUID", ironicNode.InstanceUUID)
updater := updateOptsBuilder(p.debugLog)
updater := updateOptsBuilder(p.log)
updater.SetTopLevelOpt("instance_uuid", nil, ironicNode.InstanceUUID)
_, success, result, err := p.tryUpdateNode(ironicNode, updater)
if !success {
Expand Down
2 changes: 1 addition & 1 deletion pkg/provisioner/ironic/raid.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func setTargetRAIDCfg(p *ironicProvisioner, raidInterface string, ironicNode *no
p.log.Info("rootDeviceHints is used, the first volume of raid will not be set to root")
}

updater := updateOptsBuilder(p.debugLog)
updater := updateOptsBuilder(p.log)
updater.SetTopLevelOpt("raid_interface", targetRaidInterface, ironicNode.RAIDInterface)
ironicNode, success, result, err := p.tryUpdateNode(ironicNode, updater)
if !success {
Expand Down
23 changes: 8 additions & 15 deletions pkg/provisioner/ironic/update_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,13 @@ func getUpdateOperation(name string, currentData map[string]interface{}, desired
desiredValue = deref(desiredValue)
if desiredValue != nil {
if !(present && optionValueEqual(deref(current), desiredValue)) {
if log.GetSink() != nil {
if present {
log.Info("updating option data",
"value", sanitisedValue(desiredValue),
"old_value", current)
} else {
log.Info("adding option data",
"value", sanitisedValue(desiredValue))
}
if present {
log.Info("updating option data",
"value", sanitisedValue(desiredValue),
"oldValue", current)
} else {
log.Info("adding option data",
"value", sanitisedValue(desiredValue))
}
return &nodes.UpdateOperation{
Op: nodes.AddOp, // Add also does replace
Expand All @@ -118,9 +116,7 @@ func getUpdateOperation(name string, currentData map[string]interface{}, desired
}
} else {
if present {
if log.GetSink() != nil {
log.Info("removing option data")
}
log.Info("removing option data")
return &nodes.UpdateOperation{
Op: nodes.RemoveOp,
Path: path,
Expand All @@ -142,9 +138,6 @@ func updateOptsBuilder(logger logr.Logger) *nodeUpdater {
}

func (nu *nodeUpdater) logger(basepath, option string) logr.Logger {
if nu.log.GetSink() == nil {
return logr.Logger{}
}
log := nu.log.WithValues("option", option)
if basepath != "" {
log = log.WithValues("section", basepath[1:])
Expand Down