Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
304a2b19
Unverified
Commit
304a2b19
authored
Jun 04, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Jun 04, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #78522 from croomes/bugfix-78517-storageos-mountref
StorageOS volume driver: Remove call to clear mount info if already set
parents
85f2730d
6d9f4659
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
15 deletions
+20
-15
storageos_util.go
pkg/volume/storageos/storageos_util.go
+20
-15
No files found.
pkg/volume/storageos/storageos_util.go
View file @
304a2b19
...
...
@@ -88,7 +88,7 @@ func (u *storageosUtil) NewAPI(apiCfg *storageosAPIConfig) error {
apiPass
:
defaultAPIPassword
,
apiVersion
:
defaultAPIVersion
,
}
klog
.
V
(
4
)
.
Infof
(
"
U
sing default StorageOS API settings: addr %s, version: %s"
,
apiCfg
.
apiAddr
,
defaultAPIVersion
)
klog
.
V
(
4
)
.
Infof
(
"
u
sing default StorageOS API settings: addr %s, version: %s"
,
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
// /var/lib/storageos/volumes.
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
{
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
// be made accessible as a block device before using.
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
{
return
""
,
err
}
...
...
@@ -161,19 +167,6 @@ func (u *storageosUtil) AttachVolume(b *storageosMounter) (string, error) {
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
)
dt
,
err
:=
pathDeviceType
(
srcPath
)
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
// enabled and loop devices are used to simulate a block device.
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
)
{
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.
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
{
return
err
}
...
...
@@ -224,6 +223,9 @@ func (u *storageosUtil) AttachDevice(b *storageosMounter, deviceMountPath string
// Mount mounts the volume on the host.
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
)
if
err
!=
nil
{
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
// re-mounted elsewhere.
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
{
// 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.
klog
.
V
(
4
)
.
Infof
(
"C
ould not remove mount reference in the StorageOS API as no credentials available to the unmount operation"
)
klog
.
Warningf
(
"c
ould not remove mount reference in the StorageOS API as no credentials available to the unmount operation"
)
return
nil
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment