Repository: metal3-io/baremetal-operator

Issue:
Enable "mnd" linter in golangci-lint
Enable "mnd" linter in golangci-lint. Fix any warnings enabling it causes.

/area ci
/help
/triage accepted

Hints from issue comments:
@metal3-io-bot: @tuminoid: 
	This request has been marked as needing help from a contributor.

Please ensure the request meets the requirements listed [here](https://git.k8s.io/community/contributors/guide/help-wanted.md).

If this request no longer meets these requirements, the label can be removed
by commenting with the `/remove-help` command.


<details>

In response to [this](https://github.com/metal3-io/baremetal-operator/issues/2359):

>Enable "mnd" linter in golangci-lint. Fix any warnings enabling it causes.
>
>/area ci
>/help
>/triage accepted


Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
</details>@metal3-io-bot: @tuminoid: The label(s) `area/ci` cannot be applied, because the repository doesn't have them.

<details>

In response to [this](https://github.com/metal3-io/baremetal-operator/issues/2359):

>Enable "mnd" linter in golangci-lint. Fix any warnings enabling it causes.
>
>/area ci
>/help
>/triage accepted


Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
</details>

Solution patch:
diff --git a/.golangci.yaml b/.golangci.yaml
index 7c53d88a..075a0062 100644
--- a/.golangci.yaml
+++ b/.golangci.yaml
@@ -48,7 +48,7 @@ linters:
   - makezero
   - mirror
   - misspell
-  #- mnd
+  - mnd
   - nakedret
   - nilerr
   - nilnesserr
diff --git a/cmd/get-hardware-details/main.go b/cmd/get-hardware-details/main.go
index b782bc7b..3638f857 100644
--- a/cmd/get-hardware-details/main.go
+++ b/cmd/get-hardware-details/main.go
@@ -17,6 +17,10 @@ import (
 	"k8s.io/klog/v2"
 )
 
+const (
+	reqOptArgs = 3
+)
+
 type options struct {
 	Endpoint   string
 	AuthConfig clients.AuthConfig
@@ -76,7 +80,7 @@ func main() {
 }
 
 func getOptions() (o options) {
-	if len(os.Args) != 3 {
+	if len(os.Args) != reqOptArgs {
 		fmt.Println("Usage: get-hardware-details <ironic URI> <node UUID>")
 		os.Exit(1)
 	}
diff --git a/hack/tools/deploy-cli/deploy-cli.go b/hack/tools/deploy-cli/deploy-cli.go
index 0dc4399e..f8a12646 100644
--- a/hack/tools/deploy-cli/deploy-cli.go
+++ b/hack/tools/deploy-cli/deploy-cli.go
@@ -21,6 +21,11 @@ import (
 	"sigs.k8s.io/kustomize/kyaml/filesys"
 )
 
+const (
+	filePerm755 = 0755
+	filePerm600 = 0600
+)
+
 // DeployContext defines the context of the deploy run.
 type DeployContext struct {
 	Context context.Context
@@ -75,7 +80,7 @@ func (d *DeployContext) determineIronicAuth() error {
 	ironicAuthDir := filepath.Join(ironicDataDir, "auth")
 	ironicUsernameFile := filepath.Join(ironicAuthDir, "ironic-username")
 
-	if err := os.MkdirAll(ironicAuthDir, 0755); err != nil {
+	if err := os.MkdirAll(ironicAuthDir, filePerm755); err != nil {
 		return err
 	}
 
@@ -84,24 +89,24 @@ func (d *DeployContext) determineIronicAuth() error {
 		return err
 	}
 	if ironicUsername == "" {
-		ironicUsername, err = GenerateRandomString(12)
+		ironicUsername, err = GenerateRandomString(12) //nolint: mnd
 		if err != nil {
 			return err
 		}
 	}
-	if err = os.WriteFile(ironicUsernameFile, []byte(ironicUsername), 0600); err != nil {
+	if err = os.WriteFile(ironicUsernameFile, []byte(ironicUsername), filePerm600); err != nil {
 		return err
 	}
 
 	ironicPasswordFile := filepath.Join(ironicAuthDir, "ironic-password")
 	ironicPassword, err := getEnvOrFileContent("IRONIC_PASSWORD", ironicPasswordFile)
 	if err != nil || ironicPassword == "" {
-		ironicPassword, err = GenerateRandomString(12)
+		ironicPassword, err = GenerateRandomString(12) //nolint: mnd
 		if err != nil {
 			return err
 		}
 	}
-	if err = os.WriteFile(ironicPasswordFile, []byte(ironicPassword), 0600); err != nil {
+	if err = os.WriteFile(ironicPasswordFile, []byte(ironicPassword), filePerm600); err != nil {
 		return err
 	}
 
@@ -132,9 +137,9 @@ func (d *DeployContext) deployIronic() error {
 		if d.BMOPath != "" {
 			ironicOverlay = filepath.Join(d.BMOPath, "ironic-deployment", "overlays", "temp")
 			ironicKustomizeTpl = "templates/ironic-kustomize-bmopath.tpl"
-			err = EnsureCleanDirectory(ironicOverlay, 0755)
+			err = EnsureCleanDirectory(ironicOverlay, filePerm755)
 		} else {
-			ironicOverlay, err = MakeRandomDirectory("/tmp/ironic-overlay-", 0755)
+			ironicOverlay, err = MakeRandomDirectory("/tmp/ironic-overlay-", filePerm755)
 			ironicKustomizeTpl = "templates/ironic-kustomize.tpl"
 		}
 
@@ -176,7 +181,7 @@ func (d *DeployContext) deployIronic() error {
 			return err
 		}
 		htpasswdPath := filepath.Join(d.IronicOverlay, "ironic-htpasswd")
-		if err = os.WriteFile(htpasswdPath, []byte(ironicHtpasswd), 0600); err != nil {
+		if err = os.WriteFile(htpasswdPath, []byte(ironicHtpasswd), filePerm600); err != nil {
 			return err
 		}
 	}
@@ -205,9 +210,9 @@ func (d *DeployContext) deployBMO() error {
 		if d.BMOPath != "" {
 			bmoOverlay = filepath.Join(d.BMOPath, "config", "overlays", "temp")
 			kustomizeTpl = "templates/bmo-kustomize-bmopath.tpl"
-			err = EnsureCleanDirectory(bmoOverlay, 0755)
+			err = EnsureCleanDirectory(bmoOverlay, filePerm755)
 		} else {
-			bmoOverlay, err = MakeRandomDirectory("/tmp/bmo-overlay-", 0755)
+			bmoOverlay, err = MakeRandomDirectory("/tmp/bmo-overlay-", filePerm755)
 			kustomizeTpl = "templates/bmo-kustomize.tpl"
 		}
 		if err != nil {
@@ -238,11 +243,11 @@ func (d *DeployContext) deployBMO() error {
 	username, password := d.IronicUsername, d.IronicPassword
 	if username != "" && password != "" {
 		usernameFile := filepath.Join(bmoOverlay, "ironic-username")
-		if err := os.WriteFile(usernameFile, []byte(username), 0600); err != nil {
+		if err := os.WriteFile(usernameFile, []byte(username), filePerm600); err != nil {
 			return err
 		}
 		passwordFile := filepath.Join(bmoOverlay, "ironic-password")
-		if err := os.WriteFile(passwordFile, []byte(password), 0600); err != nil {
+		if err := os.WriteFile(passwordFile, []byte(password), filePerm600); err != nil {
 			return err
 		}
 	}
@@ -344,7 +349,7 @@ func EnsureCleanDirectory(name string, perm os.FileMode) error {
 // MakeRandomDirectory generates a new directory whose name starts with the
 // provided prefix and ends with a random string.
 func MakeRandomDirectory(prefix string, perm os.FileMode) (string, error) {
-	randomStr, err := GenerateRandomString(6)
+	randomStr, err := GenerateRandomString(6) //nolint: mnd
 	if err != nil {
 		return "", err
 	}
diff --git a/internal/controller/metal3.io/action_result.go b/internal/controller/metal3.io/action_result.go
index 650ecc4f..0b7c83ea 100644
--- a/internal/controller/metal3.io/action_result.go
+++ b/internal/controller/metal3.io/action_result.go
@@ -13,7 +13,10 @@ import (
 
 // This is an upper limit for the ErrorCount, so that the max backoff
 // timeout will not exceed (roughly) 8 hours.
-const maxBackOffCount = 9
+const (
+	maxBackOffCount = 9
+	defaultBackoff  = 0.5
+)
 
 func init() {
 	rand.Seed(time.Now().UTC().UnixNano())
@@ -139,7 +142,7 @@ func calculateBackoff(errorCount int) time.Duration {
 	}
 
 	base := math.Exp2(float64(errorCount))
-	backOff := base - (rand.Float64() * base * 0.5) // #nosec
+	backOff := base - (rand.Float64() * base * defaultBackoff) // #nosec
 	backOffDuration := time.Duration(float64(time.Minute) * backOff)
 	return backOffDuration
 }
diff --git a/internal/controller/metal3.io/host_state_machine.go b/internal/controller/metal3.io/host_state_machine.go
index 8b382553..0a6d8454 100644
--- a/internal/controller/metal3.io/host_state_machine.go
+++ b/internal/controller/metal3.io/host_state_machine.go
@@ -11,6 +11,10 @@ import (
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 )
 
+const (
+	retryCount = 3
+)
+
 // hostStateMachine is a finite state machine that manages transitions between
 // the states of a BareMetalHost.
 type hostStateMachine struct {
@@ -559,7 +563,7 @@ func (hsm *hostStateMachine) handleDeprovisioning(info *reconcileInfo) actionRes
 		case actionFailed:
 			// If the provisioner gives up deprovisioning and
 			// deletion has been requested, continue to delete.
-			if hsm.Host.Status.ErrorCount > 3 {
+			if hsm.Host.Status.ErrorCount > retryCount {
 				info.log.Info("Giving up on host clean up after 3 attempts. The host may still be operational " +
 					"and cause issues in your clusters. You should clean it up manually now.")
 				hsm.NextState = metal3api.StatePoweringOffBeforeDelete
@@ -596,7 +600,7 @@ func (hsm *hostStateMachine) handlePoweringOffBeforeDelete(info *reconcileInfo)
 	case actionFailed:
 		// If the provisioner gives up deprovisioning and
 		// deletion has been requested, continue to delete.
-		if hsm.Host.Status.ErrorCount > 3 {
+		if hsm.Host.Status.ErrorCount > retryCount {
 			info.log.Info("Giving up on host power off after 3 attempts.")
 			return skipToDelete()
 		}
diff --git a/main.go b/main.go
index f95d5436..7426d4f0 100644
--- a/main.go
+++ b/main.go
@@ -144,11 +144,11 @@ func main() {
 		"use the demo provisioner to set host states")
 	flag.StringVar(&healthAddr, "health-addr", ":9440",
 		"The address the health endpoint binds to.")
-	flag.IntVar(&webhookPort, "webhook-port", 9443,
+	flag.IntVar(&webhookPort, "webhook-port", 9443, //nolint:mnd
 		"Webhook Server port (set to 0 to disable)")
-	flag.Float64Var(&restConfigQPS, "kube-api-qps", 20,
+	flag.Float64Var(&restConfigQPS, "kube-api-qps", 20, //nolint:mnd
 		"Maximum queries per second from the controller client to the Kubernetes API server. Default 20")
-	flag.IntVar(&restConfigBurst, "kube-api-burst", 30,
+	flag.IntVar(&restConfigBurst, "kube-api-burst", 30, //nolint:mnd
 		"Maximum number of queries that should be allowed in one burst from the controller client to the Kubernetes API server. Default 30")
 	flag.StringVar(&tlsOptions.TLSMinVersion, "tls-min-version", TLSVersion12,
 		"The minimum TLS version in use by the webhook server.\n"+
@@ -436,10 +436,10 @@ func getMaxConcurrentReconciles(controllerConcurrency int) (int, error) {
 	// controller-concurrency value is 0 i.e. no values passed via the flag
 	// maxConcurrentReconcile value would be set based on env var or number of CPUs.
 	maxConcurrentReconciles := runtime.NumCPU()
-	if maxConcurrentReconciles > 8 {
+	if maxConcurrentReconciles > 8 { //nolint:mnd
 		maxConcurrentReconciles = 8
 	}
-	if maxConcurrentReconciles < 2 {
+	if maxConcurrentReconciles < 2 { //nolint:mnd
 		maxConcurrentReconciles = 2
 	}
 	if mcrEnv, ok := os.LookupEnv("BMO_CONCURRENCY"); ok {
diff --git a/pkg/provisioner/demo/demo.go b/pkg/provisioner/demo/demo.go
index dc764df9..76ceb6af 100644
--- a/pkg/provisioner/demo/demo.go
+++ b/pkg/provisioner/demo/demo.go
@@ -8,6 +8,7 @@ import (
 	metal3api "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
 	"github.com/metal3-io/baremetal-operator/pkg/hardwareutils/bmc"
 	"github.com/metal3-io/baremetal-operator/pkg/provisioner"
+	"github.com/metal3-io/baremetal-operator/pkg/provisioner/fixture"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	logz "sigs.k8s.io/controller-runtime/pkg/log/zap"
 )
@@ -97,7 +98,7 @@ func (p *demoProvisioner) Register(_ provisioner.ManagementAccessData, _, _ bool
 		// Always mark the host as dirty so it never moves past this
 		// point.
 		result.Dirty = true
-		result.RequeueAfter = time.Second * 5
+		result.RequeueAfter = time.Second * fixture.DefaultRequeueSecs
 
 	default:
 		if p.provID == "" {
@@ -126,14 +127,14 @@ func (p *demoProvisioner) InspectHardware(_ provisioner.InspectData, _, _, _ boo
 		// set dirty so we don't allow the host to progress past this
 		// state in Reconcile()
 		result.Dirty = true
-		result.RequeueAfter = time.Second * 5
+		result.RequeueAfter = time.Second * fixture.DefaultRequeueSecs
 		return result, started, nil, nil
 	}
 
 	p.log.Info("continuing inspection by setting details")
 	details =
 		&metal3api.HardwareDetails{
-			RAMMebibytes: 128 * 1024,
+			RAMMebibytes: fixture.DefaultRAMMebibytes * fixture.DefaultGB,
 			NIC: []metal3api.NIC{
 				{
 					Name:      "nic-1",
@@ -156,20 +157,20 @@ func (p *demoProvisioner) InspectHardware(_ provisioner.InspectData, _, _, _ boo
 				{
 					Name:       "disk-1 (boot)",
 					Rotational: false,
-					SizeBytes:  metal3api.TebiByte * 93,
+					SizeBytes:  metal3api.TebiByte * fixture.DefaultSizeBytes,
 					Model:      "Dell CFJ61",
 				},
 				{
 					Name:       "disk-2",
 					Rotational: false,
-					SizeBytes:  metal3api.TebiByte * 93,
+					SizeBytes:  metal3api.TebiByte * fixture.DefaultSizeBytes,
 					Model:      "Dell CFJ61",
 				},
 			},
 			CPU: metal3api.CPU{
 				Arch:           "x86_64",
 				Model:          "Core 2 Duo",
-				ClockMegahertz: 3.0 * metal3api.GigaHertz,
+				ClockMegahertz: fixture.DefaultClockMegahertz * metal3api.GigaHertz,
 				Flags:          []string{"lm", "hypervisor", "vmx"},
 				Count:          1,
 			},
@@ -201,7 +202,7 @@ func (p *demoProvisioner) Prepare(_ provisioner.PrepareData, unprepared bool, _
 		p.log.Info("preparing host")
 		started = unprepared
 		result.Dirty = true
-		result.RequeueAfter = time.Second * 5
+		result.RequeueAfter = time.Second * fixture.DefaultRequeueSecs
 
 	default:
 		p.log.Info("finished preparing")
@@ -223,7 +224,7 @@ func (p *demoProvisioner) Service(_ provisioner.ServicingData, unprepared bool,
 		p.log.Info("servicing host")
 		started = unprepared
 		result.Dirty = true
-		result.RequeueAfter = time.Second * 5
+		result.RequeueAfter = time.Second * fixture.DefaultRequeueSecs
 
 	default:
 		p.log.Info("finished servicing")
@@ -256,7 +257,7 @@ func (p *demoProvisioner) Provision(_ provisioner.ProvisionData, _ bool) (result
 	case ProvisioningHost:
 		p.log.Info("provisioning host")
 		result.Dirty = true
-		result.RequeueAfter = time.Second * 5
+		result.RequeueAfter = time.Second * fixture.DefaultRequeueSecs
 
 	default:
 		p.log.Info("finished provisioning")
diff --git a/pkg/provisioner/fixture/fixture.go b/pkg/provisioner/fixture/fixture.go
index beb0f45a..a78ff5dc 100644
--- a/pkg/provisioner/fixture/fixture.go
+++ b/pkg/provisioner/fixture/fixture.go
@@ -16,6 +16,14 @@ var deprovisionRequeueDelay = time.Second * 10
 var provisionRequeueDelay = time.Second * 10
 var inspectionRequeueDelay = time.Second * 2
 
+const (
+	DefaultRequeueSecs    = 5
+	DefaultSizeBytes      = 93
+	DefaultClockMegahertz = 3.0
+	DefaultRAMMebibytes   = 128
+	DefaultGB             = 1024
+)
+
 type fixtureHostConfigData struct {
 	userData    string
 	networkData string
@@ -129,7 +137,7 @@ func (p *fixtureProvisioner) Register(_ provisioner.ManagementAccessData, _, _ b
 	if p.provID == "" {
 		provID = "temporary-fake-id"
 		result.Dirty = true
-		result.RequeueAfter = time.Second * 5
+		result.RequeueAfter = time.Second * DefaultRequeueSecs
 		p.publisher("Registered", "Registered new host")
 		return
 	}
@@ -154,7 +162,7 @@ func (p *fixtureProvisioner) InspectHardware(_ provisioner.InspectData, _, _, _
 		p.log.Info("continuing inspection by setting details")
 		details =
 			&metal3api.HardwareDetails{
-				RAMMebibytes: 128 * 1024,
+				RAMMebibytes: DefaultRAMMebibytes * DefaultGB,
 				NIC: []metal3api.NIC{
 					{
 						Name:      "nic-1",
@@ -177,20 +185,20 @@ func (p *fixtureProvisioner) InspectHardware(_ provisioner.InspectData, _, _, _
 					{
 						Name:       "disk-1 (boot)",
 						Rotational: false,
-						SizeBytes:  metal3api.TebiByte * 93,
+						SizeBytes:  metal3api.TebiByte * DefaultSizeBytes,
 						Model:      "Dell CFJ61",
 					},
 					{
 						Name:       "disk-2",
 						Rotational: false,
-						SizeBytes:  metal3api.TebiByte * 93,
+						SizeBytes:  metal3api.TebiByte * DefaultSizeBytes,
 						Model:      "Dell CFJ61",
 					},
 				},
 				CPU: metal3api.CPU{
 					Arch:           "x86_64",
 					Model:          "FancyPants CPU",
-					ClockMegahertz: 3.0 * metal3api.GigaHertz,
+					ClockMegahertz: DefaultClockMegahertz * metal3api.GigaHertz,
 					Flags:          []string{"fpu", "hypervisor", "sse", "vmx"},
 					Count:          1,
 				},
diff --git a/pkg/provisioner/ironic/clients/features.go b/pkg/provisioner/ironic/clients/features.go
index db415345..dce6d794 100644
--- a/pkg/provisioner/ironic/clients/features.go
+++ b/pkg/provisioner/ironic/clients/features.go
@@ -47,23 +47,23 @@ func (af AvailableFeatures) Log(logger logr.Logger) {
 }
 
 func (af AvailableFeatures) HasFirmwareUpdates() bool {
-	return af.MaxVersion >= 86
+	return af.MaxVersion >= 86 //nolint:mnd
 }
 
 func (af AvailableFeatures) HasServicing() bool {
-	return af.MaxVersion >= 87
+	return af.MaxVersion >= 87 //nolint:mnd
 }
 
 func (af AvailableFeatures) HasDataImage() bool {
-	return af.MaxVersion >= 89
+	return af.MaxVersion >= 89 //nolint:mnd
 }
 
 func (af AvailableFeatures) HasVirtualMediaGetAPI() bool {
-	return af.MaxVersion >= 93
+	return af.MaxVersion >= 93 //nolint:mnd
 }
 
 func (af AvailableFeatures) HasDisablePowerOff() bool {
-	return af.MaxVersion >= 95
+	return af.MaxVersion >= 95 //nolint:mnd
 }
 
 func (af AvailableFeatures) ChooseMicroversion() string {
diff --git a/pkg/provisioner/ironic/hardwaredetails/hardwaredetails.go b/pkg/provisioner/ironic/hardwaredetails/hardwaredetails.go
index b164b4ef..dbdc72a8 100644
--- a/pkg/provisioner/ironic/hardwaredetails/hardwaredetails.go
+++ b/pkg/provisioner/ironic/hardwaredetails/hardwaredetails.go
@@ -81,7 +81,7 @@ func getNICDetails(ifdata []inventory.InterfaceType,
 				IP:        intf.IPV4Address,
 				VLANs:     vlans,
 				VLANID:    vlanid,
-				SpeedGbps: intf.SpeedMbps / 1000,
+				SpeedGbps: intf.SpeedMbps / 1000, //nolint:mnd
 				PXE:       pxeEnabled,
 			})
 		}
@@ -94,7 +94,7 @@ func getNICDetails(ifdata []inventory.InterfaceType,
 				IP:        intf.IPV6Address,
 				VLANs:     vlans,
 				VLANID:    vlanid,
-				SpeedGbps: intf.SpeedMbps / 1000,
+				SpeedGbps: intf.SpeedMbps / 1000, //nolint:mnd
 				PXE:       pxeEnabled,
 			})
 		}
diff --git a/pkg/provisioner/ironic/inspecthardware.go b/pkg/provisioner/ironic/inspecthardware.go
index f9b2f062..ab78119c 100644
--- a/pkg/provisioner/ironic/inspecthardware.go
+++ b/pkg/provisioner/ironic/inspecthardware.go
@@ -2,6 +2,7 @@ package ironic
 
 import (
 	"fmt"
+	"net/http"
 	"slices"
 	"strings"
 
@@ -125,7 +126,7 @@ func (p *ironicProvisioner) InspectHardware(data provisioner.InspectData, restar
 	response := nodes.GetInventory(p.ctx, p.client, ironicNode.UUID)
 	introData, err := response.Extract()
 	if err != nil {
-		if gophercloud.ResponseCodeIs(err, 404) {
+		if gophercloud.ResponseCodeIs(err, http.StatusNotFound) {
 			// The node has just been enrolled, inspection hasn't been started yet.
 			result, started, err = p.startInspection(data, ironicNode)
 			return result, started, details, err
diff --git a/pkg/provisioner/ironic/ironic.go b/pkg/provisioner/ironic/ironic.go
index 9a4b4589..6e4de555 100644
--- a/pkg/provisioner/ironic/ironic.go
+++ b/pkg/provisioner/ironic/ironic.go
@@ -5,6 +5,7 @@ import (
 	"errors"
 	"fmt"
 	"net"
+	"net/http"
 	"strings"
 	"time"
 
@@ -175,7 +176,7 @@ func (p *ironicProvisioner) getNode() (*nodes.Node, error) {
 		return ironicNode, nil
 	}
 
-	if gophercloud.ResponseCodeIs(err, 404) {
+	if gophercloud.ResponseCodeIs(err, http.StatusNotFound) {
 		// Look by ID failed, trying to lookup by hostname in case it was
 		// previously created
 		return nil, provisioner.ErrNeedsRegistration
@@ -250,7 +251,7 @@ func (p *ironicProvisioner) findExistingHost(bootMACAddress string) (ironicNode
 			return ironicNode, nil
 		}
 
-		if gophercloud.ResponseCodeIs(err, 404) {
+		if gophercloud.ResponseCodeIs(err, http.StatusNotFound) {
 			p.log.Info(fmt.Sprintf("node with name %s doesn't exist", nodeName))
 		} else {
 			return nil, fmt.Errorf("failed to find node by name %s: %w", nodeName, err)
@@ -279,7 +280,7 @@ func (p *ironicProvisioner) findExistingHost(bootMACAddress string) (ironicNode
 
 			return ironicNode, nil
 		}
-		if gophercloud.ResponseCodeIs(err, 404) {
+		if gophercloud.ResponseCodeIs(err, http.StatusNotFound) {
 			return nil, fmt.Errorf("port %s exists but linked node %s doesn't: %w", bootMACAddress, nodeUUID, err)
 		}
 		return nil, fmt.Errorf("port %s exists but failed to find linked node %s by ID: %w", bootMACAddress, nodeUUID, err)
@@ -489,7 +490,7 @@ func (p *ironicProvisioner) tryUpdateNode(ironicNode *nodes.Node, updater *clien
 	updatedNode, err = nodes.Update(p.ctx, p.client, ironicNode.UUID, updater.Updates).Extract()
 	if err == nil {
 		success = true
-	} else if gophercloud.ResponseCodeIs(err, 409) {
+	} else if gophercloud.ResponseCodeIs(err, http.StatusConflict) {
 		p.log.Info("could not update node settings in ironic, busy or update cannot be applied in the current state")
 		result, err = retryAfterDelay(provisionRequeueDelay)
 	} else {
@@ -521,7 +522,7 @@ func (p *ironicProvisioner) tryChangeNodeProvisionState(ironicNode *nodes.Node,
 	changeResult := nodes.ChangeProvisionState(p.ctx, p.client, ironicNode.UUID, opts)
 	if changeResult.Err == nil {
 		success = true
-	} else if gophercloud.ResponseCodeIs(changeResult.Err, 409) {
+	} else if gophercloud.ResponseCodeIs(changeResult.Err, http.StatusConflict) {
 		p.log.Info("could not change state of host, busy")
 		result, err = retryAfterDelay(provisionRequeueDelay)
 		return success, result, err
@@ -758,7 +759,7 @@ func (p *ironicProvisioner) GetFirmwareComponents() ([]metal3api.FirmwareCompone
 	}
 
 	// Setting to 2 since we only support bmc and bios
-	componentsInfo := make([]metal3api.FirmwareComponentStatus, 0, 2)
+	componentsInfo := make([]metal3api.FirmwareComponentStatus, 0, 2) //nolint:mnd
 
 	if ironicNode.FirmwareInterface == "no-firmware" {
 		return componentsInfo, provisioner.ErrFirmwareUpdateUnsupported
@@ -805,7 +806,7 @@ func (p *ironicProvisioner) setUpForProvisioning(ironicNode *nodes.Node, data pr
 	}
 
 	errorMessage, err := p.validateNode(ironicNode)
-	if gophercloud.ResponseCodeIs(err, 409) {
+	if gophercloud.ResponseCodeIs(err, http.StatusConflict) {
 		p.log.Info("could not validate host during registration, busy")
 		return retryAfterDelay(provisionRequeueDelay)
 	} else if err != nil {
@@ -1345,7 +1346,7 @@ func (p *ironicProvisioner) setMaintenanceFlag(ironicNode *nodes.Node, value boo
 
 	if err == nil {
 		result, err = operationContinuing(0)
-	} else if gophercloud.ResponseCodeIs(err, 409) {
+	} else if gophercloud.ResponseCodeIs(err, http.StatusConflict) {
 		p.log.Info("could not update maintenance in ironic, busy")
 		result, err = retryAfterDelay(provisionRequeueDelay)
 	} else {
@@ -1511,10 +1512,10 @@ func (p *ironicProvisioner) Delete() (result provisioner.Result, err error) {
 	err = nodes.Delete(p.ctx, p.client, ironicNode.UUID).ExtractErr()
 	if err == nil {
 		p.log.Info("removed")
-	} else if gophercloud.ResponseCodeIs(err, 409) {
+	} else if gophercloud.ResponseCodeIs(err, http.StatusConflict) {
 		p.log.Info("could not remove host, busy")
 		return retryAfterDelay(provisionRequeueDelay)
-	} else if gophercloud.ResponseCodeIs(err, 404) {
+	} else if gophercloud.ResponseCodeIs(err, http.StatusNotFound) {
 		p.log.Info("did not find host to delete, OK")
 	} else {
 		return transientError(fmt.Errorf("failed to remove host: %w", err))
@@ -1581,10 +1582,10 @@ func (p *ironicProvisioner) changePower(ironicNode *nodes.Node, target nodes.Tar
 		}[target]
 		p.publisher(event.Event, event.Reason)
 		return operationContinuing(0)
-	} else if gophercloud.ResponseCodeIs(changeResult.Err, 409) {
+	} else if gophercloud.ResponseCodeIs(changeResult.Err, http.StatusConflict) {
 		p.log.Info("host is locked, trying again after delay", "delay", powerRequeueDelay)
 		return retryAfterDelay(powerRequeueDelay)
-	} else if gophercloud.ResponseCodeIs(changeResult.Err, 400) {
+	} else if gophercloud.ResponseCodeIs(changeResult.Err, http.StatusBadRequest) {
 		// Error 400 Bad Request means target power state is not supported by vendor driver
 		if target == nodes.SoftPowerOff {
 			changeResult.Err = softPowerOffUnsupportedError{changeResult.Err}
diff --git a/pkg/provisioner/ironic/register.go b/pkg/provisioner/ironic/register.go
index 390e463f..48e069a0 100644
--- a/pkg/provisioner/ironic/register.go
+++ b/pkg/provisioner/ironic/register.go
@@ -2,6 +2,7 @@ package ironic
 
 import (
 	"fmt"
+	"net/http"
 	"reflect"
 	"regexp"
 
@@ -256,7 +257,7 @@ func (p *ironicProvisioner) enrollNode(data provisioner.ManagementAccessData, bm
 	ironicNode, err = nodes.Create(p.ctx, p.client, nodeCreateOpts).Extract()
 	if err == nil {
 		p.publisher("Registered", "Registered new host")
-	} else if gophercloud.ResponseCodeIs(err, 409) {
+	} else if gophercloud.ResponseCodeIs(err, http.StatusConflict) {
 		p.log.Info("could not register host in ironic, busy")
 		return nil, true, nil
 	} else {



Test patch:
diff --git a/test/e2e/common.go b/test/e2e/common.go
index a354f11f..d4af7504 100644
--- a/test/e2e/common.go
+++ b/test/e2e/common.go
@@ -45,6 +45,9 @@ type PowerState string
 const (
 	PoweredOn  PowerState = "on"
 	PoweredOff PowerState = "off"
+
+	filePerm600 = 0600
+	filePerm750 = 0750
 )
 
 func isUndesiredState(currentState metal3api.ProvisioningState, undesiredStates []metal3api.ProvisioningState) bool {
@@ -223,7 +226,7 @@ func HasRootOnDisk(output string) bool {
 		}
 
 		fields := strings.Fields(line)
-		if len(fields) < 6 {
+		if len(fields) < 6 { //nolint: mnd
 			continue // Skip malformed lines
 		}
 
@@ -507,11 +510,11 @@ func dumpObj[T any](obj T, name string, path string) {
 	Expect(err).ToNot(HaveOccurred(), "Failed to marshal %s", name)
 	fullpath := filepath.Join(path, name)
 	filepath.Clean(fullpath)
-	Expect(os.MkdirAll(filepath.Dir(fullpath), 0750)).To(Succeed(), "Failed to create folders on path %s", filepath.Dir(fullpath))
-	f, err := os.OpenFile(fullpath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
+	Expect(os.MkdirAll(filepath.Dir(fullpath), filePerm750)).To(Succeed(), "Failed to create folders on path %s", filepath.Dir(fullpath))
+	f, err := os.OpenFile(fullpath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, filePerm600)
 	Expect(err).ToNot(HaveOccurred(), "Failed to open file with path %s", fullpath)
 	defer f.Close()
-	Expect(os.WriteFile(f.Name(), objYaml, 0600)).To(Succeed())
+	Expect(os.WriteFile(f.Name(), objYaml, filePerm600)).To(Succeed())
 }
 
 // DumpCRDs fetches all CRDs and filedumps them.
diff --git a/test/e2e/e2e_config.go b/test/e2e/e2e_config.go
index 5b7e44f5..17fbb411 100644
--- a/test/e2e/e2e_config.go
+++ b/test/e2e/e2e_config.go
@@ -119,7 +119,7 @@ func (c *Config) Validate() error {
 		switch len(intervals) {
 		case 0:
 			return errors.Errorf("Invalid interval: Intervals[%s]=%q", k, intervals)
-		case 1, 2:
+		case 1, 2: //nolint: mnd
 		default:
 			return errors.Errorf("Invalid interval: Intervals[%s]=%q", k, intervals)
 		}
diff --git a/test/vbmctl/main.go b/test/vbmctl/main.go
index 5c38c327..71f426b1 100644
--- a/test/vbmctl/main.go
+++ b/test/vbmctl/main.go
@@ -16,6 +16,10 @@ import (
 	"libvirt.org/go/libvirt"
 )
 
+const (
+	filePerm777 = 0777
+)
+
 var (
 	//go:embed templates/*.tpl
 	templateFiles embed.FS
@@ -46,7 +50,7 @@ func CreateVolumePool(conn *libvirt.Connect, poolName, poolPath string) (*libvir
 		return pool, nil
 	}
 
-	if err = os.Mkdir(poolPath, 0777); err != nil && !os.IsExist(err) {
+	if err = os.Mkdir(poolPath, filePerm777); err != nil && !os.IsExist(err) {
 		fmt.Println("Cannot determine the state of the poolPath")
 		return nil, err
 	}
@@ -141,7 +145,7 @@ func CreateLibvirtVM(conn *libvirt.Connect, name, networkName, macAddress string
 	poolName := "default"
 	poolPath := "/tmp/pool_oo"
 	opts := make(map[string]any)
-	opts[qcow2.OPT_SIZE] = 3 * (1 << 30) // qcow2 file's size is 3g
+	opts[qcow2.OPT_SIZE] = 3 * (1 << 30) //nolint: mnd // qcow2 file's size is 3g
 	opts[qcow2.OPT_FMT] = "qcow2"        // qcow2 format
 	opts[qcow2.OPT_SUBCLUSTER] = true    // enable sub-cluster
 
@@ -153,7 +157,7 @@ func CreateLibvirtVM(conn *libvirt.Connect, name, networkName, macAddress string
 		return err
 	}
 
-	if err = CreateVolume(conn, name, poolName, poolPath, 20); err != nil {
+	if err = CreateVolume(conn, name, poolName, poolPath, 20); err != nil { //nolint: mnd
 		return err
 	}