Skip to content

Commit

Permalink
lxd/storage/drivers/powerflex: Cleanup error messages
Browse files Browse the repository at this point in the history
Signed-off-by: Julian Pelizäus <[email protected]>
  • Loading branch information
roosterfish committed Jan 31, 2025
1 parent 2558cda commit 81b20a9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
11 changes: 6 additions & 5 deletions lxd/storage/drivers/driver_powerflex.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package drivers

import (
"errors"
"fmt"
"strings"

Expand Down Expand Up @@ -128,7 +129,7 @@ func (d *powerflex) FillConfig() error {
d.config["powerflex.mode"] = connectors.TypeSDC
} else {
// Fail if no PowerFlex mode can be discovered.
return fmt.Errorf("Failed to discover PowerFlex mode")
return errors.New("Failed to discover PowerFlex mode")
}
}

Expand All @@ -152,17 +153,17 @@ func (d *powerflex) Create() error {
// Since those aren't any cluster member specific keys the general validation
// rules allow empty strings in order to create the pending storage pools.
if d.config["powerflex.pool"] == "" {
return fmt.Errorf("The powerflex.pool cannot be empty")
return errors.New("The powerflex.pool cannot be empty")
}

if d.config["powerflex.gateway"] == "" {
return fmt.Errorf("The powerflex.gateway cannot be empty")
return errors.New("The powerflex.gateway cannot be empty")
}

if d.config["powerflex.mode"] == connectors.TypeSDC {
// In case the SDC mode is used the SDTs cannot be set.
if d.config["powerflex.sdt"] != "" {
return fmt.Errorf("The powerflex.sdt config key is specific to the NVMe/TCP mode")
return fmt.Errorf("The %q config key is specific to the %q mode", "powerflex.sdt", connectors.TypeNVME)
}
}

Expand Down Expand Up @@ -274,7 +275,7 @@ func (d *powerflex) Validate(config map[string]string) error {
// Ensure powerflex.mode cannot be changed to avoid leaving volume mappings
// and to prevent disturbing running instances.
if oldMode != "" && oldMode != newMode {
return fmt.Errorf("PowerFlex mode cannot be changed")
return errors.New("PowerFlex mode cannot be changed")
}

// Check if the selected PowerFlex mode is supported on this node.
Expand Down
4 changes: 2 additions & 2 deletions lxd/storage/drivers/driver_powerflex_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1193,12 +1193,12 @@ func (d *powerflex) resolvePool() (*powerFlexStoragePool, error) {
func (d *powerflex) getVolumeName(vol Volume) (string, error) {
volUUID, err := uuid.Parse(vol.config["volatile.uuid"])
if err != nil {
return "", fmt.Errorf(`Failed parsing "volatile.uuid" from volume %q: %w`, vol.name, err)
return "", fmt.Errorf("Failed parsing %q from volume %q: %w", "volatile.uuid", vol.name, err)
}

binUUID, err := volUUID.MarshalBinary()
if err != nil {
return "", fmt.Errorf(`Failed marshalling the "volatile.uuid" of volume %q to binary format: %w`, vol.name, err)
return "", fmt.Errorf("Failed marshalling the %q of volume %q to binary format: %w", "volatile.uuid", vol.name, err)
}

// The volume's name in base64 encoded format.
Expand Down
4 changes: 2 additions & 2 deletions lxd/storage/drivers/driver_powerflex_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func (d *powerflex) DeleteVolume(vol Volume, op *operations.Operation) error {

err = os.Remove(mountPath)
if err != nil && !os.IsNotExist(err) {
return fmt.Errorf("Failed to remove '%s': %w", mountPath, err)
return fmt.Errorf("Failed to remove %q: %w", mountPath, err)
}
}

Expand Down Expand Up @@ -577,7 +577,7 @@ func (d *powerflex) SetVolumeQuota(vol Volume, size string, allowUnsafeResize bo

// PowerFlex supports increasing of size only.
if sizeBytes < oldSizeBytes {
return fmt.Errorf("Volume capacity can only be increased")
return errors.New("Volume capacity can only be increased")
}

// Block image volumes cannot be resized because they have a readonly snapshot that doesn't get
Expand Down

0 comments on commit 81b20a9

Please sign in to comment.