mirror of https://github.com/k3s-io/k3s
Merge pull request #78522 from croomes/bugfix-78517-storageos-mountref
StorageOS volume driver: Remove call to clear mount info if already setk3s-v1.15.3
commit
304a2b191d
|
@ -88,7 +88,7 @@ func (u *storageosUtil) NewAPI(apiCfg *storageosAPIConfig) error {
|
||||||
apiPass: defaultAPIPassword,
|
apiPass: defaultAPIPassword,
|
||||||
apiVersion: defaultAPIVersion,
|
apiVersion: defaultAPIVersion,
|
||||||
}
|
}
|
||||||
klog.V(4).Infof("Using default StorageOS API settings: addr %s, version: %s", apiCfg.apiAddr, defaultAPIVersion)
|
klog.V(4).Infof("using default StorageOS API settings: addr %s, version: %s", apiCfg.apiAddr, defaultAPIVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
api, err := storageosapi.NewVersionedClient(apiCfg.apiAddr, defaultAPIVersion)
|
api, err := storageosapi.NewVersionedClient(apiCfg.apiAddr, defaultAPIVersion)
|
||||||
|
@ -103,6 +103,9 @@ func (u *storageosUtil) NewAPI(apiCfg *storageosAPIConfig) error {
|
||||||
// Creates a new StorageOS volume and makes it available as a device within
|
// Creates a new StorageOS volume and makes it available as a device within
|
||||||
// /var/lib/storageos/volumes.
|
// /var/lib/storageos/volumes.
|
||||||
func (u *storageosUtil) CreateVolume(p *storageosProvisioner) (*storageosVolume, error) {
|
func (u *storageosUtil) CreateVolume(p *storageosProvisioner) (*storageosVolume, error) {
|
||||||
|
|
||||||
|
klog.V(4).Infof("creating StorageOS volume %q with namespace %q", p.volName, p.volNamespace)
|
||||||
|
|
||||||
if err := u.NewAPI(p.apiCfg); err != nil {
|
if err := u.NewAPI(p.apiCfg); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -145,6 +148,9 @@ func (u *storageosUtil) CreateVolume(p *storageosProvisioner) (*storageosVolume,
|
||||||
// or a file device. Block devices can be used directly, but file devices must
|
// or a file device. Block devices can be used directly, but file devices must
|
||||||
// be made accessible as a block device before using.
|
// be made accessible as a block device before using.
|
||||||
func (u *storageosUtil) AttachVolume(b *storageosMounter) (string, error) {
|
func (u *storageosUtil) AttachVolume(b *storageosMounter) (string, error) {
|
||||||
|
|
||||||
|
klog.V(4).Infof("attaching StorageOS volume %q with namespace %q", b.volName, b.volNamespace)
|
||||||
|
|
||||||
if err := u.NewAPI(b.apiCfg); err != nil {
|
if err := u.NewAPI(b.apiCfg); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -161,19 +167,6 @@ func (u *storageosUtil) AttachVolume(b *storageosMounter) (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear any existing mount reference from the API. These may be leftover
|
|
||||||
// from previous mounts where the unmount operation couldn't get access to
|
|
||||||
// the API credentials.
|
|
||||||
if vol.Mounted {
|
|
||||||
opts := storageostypes.VolumeUnmountOptions{
|
|
||||||
Name: vol.Name,
|
|
||||||
Namespace: vol.Namespace,
|
|
||||||
}
|
|
||||||
if err := u.api.VolumeUnmount(opts); err != nil {
|
|
||||||
klog.Warningf("Couldn't clear existing StorageOS mount reference: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
srcPath := filepath.Join(b.deviceDir, vol.ID)
|
srcPath := filepath.Join(b.deviceDir, vol.ID)
|
||||||
dt, err := pathDeviceType(srcPath)
|
dt, err := pathDeviceType(srcPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -194,6 +187,9 @@ func (u *storageosUtil) AttachVolume(b *storageosMounter) (string, error) {
|
||||||
// Detach detaches a volume from the host. This is only needed when NBD is not
|
// Detach detaches a volume from the host. This is only needed when NBD is not
|
||||||
// enabled and loop devices are used to simulate a block device.
|
// enabled and loop devices are used to simulate a block device.
|
||||||
func (u *storageosUtil) DetachVolume(b *storageosUnmounter, devicePath string) error {
|
func (u *storageosUtil) DetachVolume(b *storageosUnmounter, devicePath string) error {
|
||||||
|
|
||||||
|
klog.V(4).Infof("detaching StorageOS volume %q with namespace %q", b.volName, b.volNamespace)
|
||||||
|
|
||||||
if !isLoopDevice(devicePath) {
|
if !isLoopDevice(devicePath) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -205,6 +201,9 @@ func (u *storageosUtil) DetachVolume(b *storageosUnmounter, devicePath string) e
|
||||||
|
|
||||||
// AttachDevice attaches the volume device to the host at a given mount path.
|
// AttachDevice attaches the volume device to the host at a given mount path.
|
||||||
func (u *storageosUtil) AttachDevice(b *storageosMounter, deviceMountPath string) error {
|
func (u *storageosUtil) AttachDevice(b *storageosMounter, deviceMountPath string) error {
|
||||||
|
|
||||||
|
klog.V(4).Infof("attaching StorageOS device for volume %q with namespace %q", b.volName, b.volNamespace)
|
||||||
|
|
||||||
if err := u.NewAPI(b.apiCfg); err != nil {
|
if err := u.NewAPI(b.apiCfg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -224,6 +223,9 @@ func (u *storageosUtil) AttachDevice(b *storageosMounter, deviceMountPath string
|
||||||
|
|
||||||
// Mount mounts the volume on the host.
|
// Mount mounts the volume on the host.
|
||||||
func (u *storageosUtil) MountVolume(b *storageosMounter, mntDevice, deviceMountPath string) error {
|
func (u *storageosUtil) MountVolume(b *storageosMounter, mntDevice, deviceMountPath string) error {
|
||||||
|
|
||||||
|
klog.V(4).Infof("mounting StorageOS volume %q with namespace %q", b.volName, b.volNamespace)
|
||||||
|
|
||||||
notMnt, err := b.mounter.IsLikelyNotMountPoint(deviceMountPath)
|
notMnt, err := b.mounter.IsLikelyNotMountPoint(deviceMountPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
|
@ -256,10 +258,13 @@ func (u *storageosUtil) MountVolume(b *storageosMounter, mntDevice, deviceMountP
|
||||||
// Unmount removes the mount reference from the volume allowing it to be
|
// Unmount removes the mount reference from the volume allowing it to be
|
||||||
// re-mounted elsewhere.
|
// re-mounted elsewhere.
|
||||||
func (u *storageosUtil) UnmountVolume(b *storageosUnmounter) error {
|
func (u *storageosUtil) UnmountVolume(b *storageosUnmounter) error {
|
||||||
|
|
||||||
|
klog.V(4).Infof("clearing StorageOS mount reference for volume %q with namespace %q", b.volName, b.volNamespace)
|
||||||
|
|
||||||
if err := u.NewAPI(b.apiCfg); err != nil {
|
if err := u.NewAPI(b.apiCfg); err != nil {
|
||||||
// We can't always get the config we need, so allow the unmount to
|
// We can't always get the config we need, so allow the unmount to
|
||||||
// succeed even if we can't remove the mount reference from the API.
|
// succeed even if we can't remove the mount reference from the API.
|
||||||
klog.V(4).Infof("Could not remove mount reference in the StorageOS API as no credentials available to the unmount operation")
|
klog.Warningf("could not remove mount reference in the StorageOS API as no credentials available to the unmount operation")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue