fix warning when using CSI driver to expand volume

Signed-off-by: hoyho <luohaihao@gmail.com>
This commit is contained in:
hoyho 2024-04-13 18:19:37 +08:00
parent a06568062c
commit 02197a9924

View File

@ -17,6 +17,7 @@ limitations under the License.
package volume package volume
import ( import (
"errors"
"fmt" "fmt"
"net" "net"
"strings" "strings"
@ -62,6 +63,8 @@ const (
ProbeRemove ProbeRemove
) )
var ErrNoPluiginMatched = errors.New("no volume plugin matched")
// VolumeOptions contains option information about a volume. // VolumeOptions contains option information about a volume.
type VolumeOptions struct { type VolumeOptions struct {
// The attributes below are required by volume.Provisioner // The attributes below are required by volume.Provisioner
@ -649,7 +652,7 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
} }
if len(matchedPluginNames) == 0 { if len(matchedPluginNames) == 0 {
return nil, fmt.Errorf("no volume plugin matched") return nil, ErrNoPluiginMatched
} }
if len(matchedPluginNames) > 1 { if len(matchedPluginNames) > 1 {
return nil, fmt.Errorf("multiple volume plugins matched: %s", strings.Join(matchedPluginNames, ",")) return nil, fmt.Errorf("multiple volume plugins matched: %s", strings.Join(matchedPluginNames, ","))
@ -876,6 +879,9 @@ func (pm *VolumePluginMgr) FindExpandablePluginBySpec(spec *Spec) (ExpandableVol
klog.V(4).InfoS("FindExpandablePluginBySpec -> returning noopExpandableVolumePluginInstance", "specName", spec.Name()) klog.V(4).InfoS("FindExpandablePluginBySpec -> returning noopExpandableVolumePluginInstance", "specName", spec.Name())
return &noopExpandableVolumePluginInstance{spec}, nil return &noopExpandableVolumePluginInstance{spec}, nil
} }
if errors.Is(err, ErrNoPluiginMatched) {
return nil, nil
}
klog.V(4).InfoS("FindExpandablePluginBySpec -> err", "specName", spec.Name(), "err", err) klog.V(4).InfoS("FindExpandablePluginBySpec -> err", "specName", spec.Name(), "err", err)
return nil, err return nil, err
} }