Make testing example more complex; improve handling for NodeUnpublishVolume/ControllerUnpublishVolume for volumes that were externally deleted
This commit is contained in:
@@ -3,10 +3,12 @@ package csi
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"k8s.io/klog"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type p5xApi struct {
|
||||
@@ -45,6 +47,8 @@ func (p5x *p5xApi) CreateVolume(name string, sizeInBytes int64) (*p5xVolume, err
|
||||
return vol, nil
|
||||
}
|
||||
|
||||
var ErrVolumeNotFound = errors.New("p5x volume not found")
|
||||
|
||||
func (p5x *p5xApi) GetVolumeByName(name string) (*p5xVolume, error) {
|
||||
klog.Infof("p5x.GetVolumeByName: %s", name)
|
||||
route := fmt.Sprintf("volumes/%s", name)
|
||||
@@ -53,6 +57,10 @@ func (p5x *p5xApi) GetVolumeByName(name string) (*p5xVolume, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if strings.Contains(string(resBody[:]), "Could not find volume with the name") {
|
||||
return nil, ErrVolumeNotFound
|
||||
}
|
||||
|
||||
vol := &p5xVolume{}
|
||||
err = json.Unmarshal(resBody, vol)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user