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
821f8cd9
Commit
821f8cd9
authored
Apr 21, 2017
by
divyenpatel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
datastore cluster support
fix verify-gofmt failure
parent
09747e6b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
+22
-2
vsphere.go
pkg/cloudprovider/providers/vsphere/vsphere.go
+22
-2
No files found.
pkg/cloudprovider/providers/vsphere/vsphere.go
View file @
821f8cd9
...
...
@@ -25,6 +25,7 @@ import (
"net/url"
"path"
"path/filepath"
"regexp"
"runtime"
"strings"
"sync"
...
...
@@ -798,7 +799,7 @@ func (vs *VSphere) AttachDisk(vmDiskPath string, nodeName k8stypes.NodeName) (di
glog
.
Errorf
(
"Failed while searching for datastore %+q. err %s"
,
datastorePathObj
.
Datastore
,
err
)
return
""
,
""
,
err
}
vmDiskPath
=
removeClusterFromVDiskPath
(
vmDiskPath
)
disk
:=
vmDevices
.
CreateDisk
(
scsiController
,
ds
.
Reference
(),
vmDiskPath
)
unitNumber
,
err
:=
getNextUnitNumber
(
vmDevices
,
scsiController
)
if
err
!=
nil
{
...
...
@@ -1045,6 +1046,7 @@ func checkDiskAttached(volPath string, vmdevices object.VirtualDeviceList, dc *o
// Returns the object key that denotes the controller object to which vmdk is attached.
func
getVirtualDiskControllerKey
(
volPath
string
,
vmDevices
object
.
VirtualDeviceList
,
dc
*
object
.
Datacenter
,
client
*
govmomi
.
Client
)
(
int32
,
error
)
{
volPath
=
removeClusterFromVDiskPath
(
volPath
)
volumeUUID
,
err
:=
getVirtualDiskUUIDByPath
(
volPath
,
dc
,
client
)
if
err
!=
nil
{
...
...
@@ -1175,7 +1177,7 @@ func (vs *VSphere) DetachDisk(volPath string, nodeName k8stypes.NodeName) error
if
err
!=
nil
{
return
err
}
volPath
=
removeClusterFromVDiskPath
(
volPath
)
diskID
,
err
:=
getVirtualDiskID
(
volPath
,
vmDevices
,
dc
,
vs
.
client
)
if
err
!=
nil
{
glog
.
Warningf
(
"disk ID not found for %v "
,
volPath
)
...
...
@@ -1332,6 +1334,11 @@ func (vs *VSphere) CreateVolume(volumeOptions *VolumeOptions) (volumePath string
return
""
,
fmt
.
Errorf
(
"Failed to create the virtual disk having name: %+q with err: %+v"
,
destVolPath
,
err
)
}
}
if
filepath
.
Base
(
datastore
)
!=
datastore
{
// If Datastore is within cluster, add cluster path to the destVolPath
destVolPath
=
strings
.
Replace
(
destVolPath
,
filepath
.
Base
(
datastore
),
datastore
,
1
)
}
glog
.
V
(
1
)
.
Infof
(
"VM Disk path is %+q"
,
destVolPath
)
return
destVolPath
,
nil
}
...
...
@@ -1380,6 +1387,7 @@ func (vs *VSphere) DeleteVolume(vmDiskPath string) error {
}
// Delete virtual disk
vmDiskPath
=
removeClusterFromVDiskPath
(
vmDiskPath
)
task
,
err
:=
virtualDiskManager
.
DeleteVirtualDisk
(
ctx
,
vmDiskPath
,
dc
)
if
err
!=
nil
{
return
err
...
...
@@ -1829,3 +1837,15 @@ func deleteVM(ctx context.Context, vm *object.VirtualMachine) error {
}
return
destroyTask
.
Wait
(
ctx
)
}
// Remove the cluster or folder path from the vDiskPath
// for vDiskPath [DatastoreCluster/sharedVmfs-0] kubevols/e2e-vmdk-1234.vmdk, return value is [sharedVmfs-0] kubevols/e2e-vmdk-1234.vmdk
// for vDiskPath [sharedVmfs-0] kubevols/e2e-vmdk-1234.vmdk, return value remains same [sharedVmfs-0] kubevols/e2e-vmdk-1234.vmdk
func
removeClusterFromVDiskPath
(
vDiskPath
string
)
string
{
datastore
:=
regexp
.
MustCompile
(
"
\\
[(.*?)
\\
]"
)
.
FindStringSubmatch
(
vDiskPath
)[
1
]
if
filepath
.
Base
(
datastore
)
!=
datastore
{
vDiskPath
=
strings
.
Replace
(
vDiskPath
,
datastore
,
filepath
.
Base
(
datastore
),
1
)
}
return
vDiskPath
}
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