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
9f89b57b
Commit
9f89b57b
authored
May 09, 2017
by
divyenpatel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix implementation of VolumesAreAttached function
parent
3fbfafdd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
19 deletions
+25
-19
vsphere.go
pkg/cloudprovider/providers/vsphere/vsphere.go
+19
-14
attacher.go
pkg/volume/vsphere_volume/attacher.go
+6
-5
No files found.
pkg/cloudprovider/providers/vsphere/vsphere.go
View file @
9f89b57b
...
@@ -766,7 +766,10 @@ func (vs *VSphere) AttachDisk(vmDiskPath string, nodeName k8stypes.NodeName) (di
...
@@ -766,7 +766,10 @@ func (vs *VSphere) AttachDisk(vmDiskPath string, nodeName k8stypes.NodeName) (di
return
""
,
""
,
err
return
""
,
""
,
err
}
}
attached
,
_
:=
checkDiskAttached
(
vmDiskPath
,
vmDevices
,
dc
,
vs
.
client
)
attached
,
err
:=
checkDiskAttached
(
vmDiskPath
,
vmDevices
,
dc
,
vs
.
client
)
if
err
!=
nil
{
return
""
,
""
,
err
}
if
attached
{
if
attached
{
diskID
,
_
=
getVirtualDiskID
(
vmDiskPath
,
vmDevices
,
dc
,
vs
.
client
)
diskID
,
_
=
getVirtualDiskID
(
vmDiskPath
,
vmDevices
,
dc
,
vs
.
client
)
diskUUID
,
_
=
getVirtualDiskUUIDByPath
(
vmDiskPath
,
dc
,
vs
.
client
)
diskUUID
,
_
=
getVirtualDiskUUIDByPath
(
vmDiskPath
,
dc
,
vs
.
client
)
...
@@ -1006,14 +1009,10 @@ func (vs *VSphere) DisksAreAttached(volPaths []string, nodeName k8stypes.NodeNam
...
@@ -1006,14 +1009,10 @@ func (vs *VSphere) DisksAreAttached(volPaths []string, nodeName k8stypes.NodeNam
defer
cancel
()
defer
cancel
()
// Create vSphere client
// Create vSphere client
attached
:=
make
(
map
[
string
]
bool
)
for
_
,
volPath
:=
range
volPaths
{
attached
[
volPath
]
=
false
}
err
:=
vSphereLogin
(
ctx
,
vs
)
err
:=
vSphereLogin
(
ctx
,
vs
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Failed to login into vCenter, err: %v"
,
err
)
glog
.
Errorf
(
"Failed to login into vCenter, err: %v"
,
err
)
return
attached
,
err
return
nil
,
err
}
}
// Find VM to detach disk from
// Find VM to detach disk from
...
@@ -1029,14 +1028,14 @@ func (vs *VSphere) DisksAreAttached(volPaths []string, nodeName k8stypes.NodeNam
...
@@ -1029,14 +1028,14 @@ func (vs *VSphere) DisksAreAttached(volPaths []string, nodeName k8stypes.NodeNam
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Failed to check whether node exist. err: %s."
,
err
)
glog
.
Errorf
(
"Failed to check whether node exist. err: %s."
,
err
)
return
attached
,
err
return
nil
,
err
}
}
if
!
nodeExist
{
if
!
nodeExist
{
glog
.
Errorf
(
"DisksAreAttached failed to determine whether disks %v are still attached: node %q does not exist"
,
glog
.
Errorf
(
"DisksAreAttached failed to determine whether disks %v are still attached: node %q does not exist"
,
volPaths
,
volPaths
,
vSphereInstance
)
vSphereInstance
)
return
attached
,
fmt
.
Errorf
(
"DisksAreAttached failed to determine whether disks %v are still attached: node %q does not exist"
,
return
nil
,
fmt
.
Errorf
(
"DisksAreAttached failed to determine whether disks %v are still attached: node %q does not exist"
,
volPaths
,
volPaths
,
vSphereInstance
)
vSphereInstance
)
}
}
...
@@ -1045,17 +1044,23 @@ func (vs *VSphere) DisksAreAttached(volPaths []string, nodeName k8stypes.NodeNam
...
@@ -1045,17 +1044,23 @@ func (vs *VSphere) DisksAreAttached(volPaths []string, nodeName k8stypes.NodeNam
_
,
vmDevices
,
dc
,
err
:=
getVirtualMachineDevices
(
ctx
,
vs
.
cfg
,
vs
.
client
,
vSphereInstance
)
_
,
vmDevices
,
dc
,
err
:=
getVirtualMachineDevices
(
ctx
,
vs
.
cfg
,
vs
.
client
,
vSphereInstance
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Failed to get VM devices for VM %#q. err: %s"
,
vSphereInstance
,
err
)
glog
.
Errorf
(
"Failed to get VM devices for VM %#q. err: %s"
,
vSphereInstance
,
err
)
return
attached
,
err
return
nil
,
err
}
}
attached
:=
make
(
map
[
string
]
bool
)
for
_
,
volPath
:=
range
volPaths
{
for
_
,
volPath
:=
range
volPaths
{
result
,
_
:=
checkDiskAttached
(
volPath
,
vmDevices
,
dc
,
vs
.
client
)
result
,
err
:=
checkDiskAttached
(
volPath
,
vmDevices
,
dc
,
vs
.
client
)
if
result
{
if
err
==
nil
{
attached
[
volPath
]
=
true
if
result
{
attached
[
volPath
]
=
true
}
else
{
attached
[
volPath
]
=
false
}
}
else
{
return
nil
,
err
}
}
}
}
return
attached
,
nil
return
attached
,
err
}
}
func
checkDiskAttached
(
volPath
string
,
vmdevices
object
.
VirtualDeviceList
,
dc
*
object
.
Datacenter
,
client
*
govmomi
.
Client
)
(
bool
,
error
)
{
func
checkDiskAttached
(
volPath
string
,
vmdevices
object
.
VirtualDeviceList
,
dc
*
object
.
Datacenter
,
client
*
govmomi
.
Client
)
(
bool
,
error
)
{
...
...
pkg/volume/vsphere_volume/attacher.go
View file @
9f89b57b
...
@@ -94,9 +94,7 @@ func (attacher *vsphereVMDKAttacher) VolumesAreAttached(specs []*volume.Spec, no
...
@@ -94,9 +94,7 @@ func (attacher *vsphereVMDKAttacher) VolumesAreAttached(specs []*volume.Spec, no
glog
.
Errorf
(
"Error getting volume (%q) source : %v"
,
spec
.
Name
(),
err
)
glog
.
Errorf
(
"Error getting volume (%q) source : %v"
,
spec
.
Name
(),
err
)
continue
continue
}
}
volumePathList
=
append
(
volumePathList
,
volumeSource
.
VolumePath
)
volumePathList
=
append
(
volumePathList
,
volumeSource
.
VolumePath
)
volumesAttachedCheck
[
spec
]
=
true
volumeSpecMap
[
volumeSource
.
VolumePath
]
=
spec
volumeSpecMap
[
volumeSource
.
VolumePath
]
=
spec
}
}
attachedResult
,
err
:=
attacher
.
vsphereVolumes
.
DisksAreAttached
(
volumePathList
,
nodeName
)
attachedResult
,
err
:=
attacher
.
vsphereVolumes
.
DisksAreAttached
(
volumePathList
,
nodeName
)
...
@@ -104,14 +102,17 @@ func (attacher *vsphereVMDKAttacher) VolumesAreAttached(specs []*volume.Spec, no
...
@@ -104,14 +102,17 @@ func (attacher *vsphereVMDKAttacher) VolumesAreAttached(specs []*volume.Spec, no
glog
.
Errorf
(
glog
.
Errorf
(
"Error checking if volumes (%v) are attached to current node (%q). err=%v"
,
"Error checking if volumes (%v) are attached to current node (%q). err=%v"
,
volumePathList
,
nodeName
,
err
)
volumePathList
,
nodeName
,
err
)
return
volumesAttachedCheck
,
err
return
nil
,
err
}
}
for
volumePath
,
attached
:=
range
attachedResult
{
for
volumePath
,
attached
:=
range
attachedResult
{
spec
:=
volumeSpecMap
[
volumePath
]
if
!
attached
{
if
!
attached
{
spec
:=
volumeSpecMap
[
volumePath
]
volumesAttachedCheck
[
spec
]
=
false
volumesAttachedCheck
[
spec
]
=
false
glog
.
V
(
2
)
.
Infof
(
"VolumesAreAttached: check volume %q (specName: %q) is no longer attached"
,
volumePath
,
spec
.
Name
())
glog
.
V
(
2
)
.
Infof
(
"VolumesAreAttached: volume %q (specName: %q) is no longer attached"
,
volumePath
,
spec
.
Name
())
}
else
{
volumesAttachedCheck
[
spec
]
=
true
glog
.
V
(
2
)
.
Infof
(
"VolumesAreAttached: volume %q (specName: %q) is attached"
,
volumePath
,
spec
.
Name
())
}
}
}
}
return
volumesAttachedCheck
,
nil
return
volumesAttachedCheck
,
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