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
4213f4d7
Commit
4213f4d7
authored
May 15, 2019
by
andyzhangx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix azure disk lun error
parent
adf6fa69
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
8 deletions
+9
-8
attacher.go
pkg/volume/azure_dd/attacher.go
+1
-1
azure_dd.go
pkg/volume/azure_dd/azure_dd.go
+1
-1
azure_controller_common.go
...o/legacy-cloud-providers/azure/azure_controller_common.go
+6
-5
azure_controller_common_test.go
...acy-cloud-providers/azure/azure_controller_common_test.go
+1
-1
No files found.
pkg/volume/azure_dd/attacher.go
View file @
4213f4d7
...
...
@@ -82,7 +82,7 @@ func (a *azureDiskAttacher) Attach(spec *volume.Spec, nodeName types.NodeName) (
klog
.
V
(
2
)
.
Infof
(
"GetDiskLun returned: %v. Initiating attaching volume %q to node %q."
,
err
,
volumeSource
.
DataDiskURI
,
nodeName
)
isManagedDisk
:=
(
*
volumeSource
.
Kind
==
v1
.
AzureManagedDisk
)
err
=
diskController
.
AttachDisk
(
isManagedDisk
,
volumeSource
.
DiskName
,
volumeSource
.
DataDiskURI
,
nodeName
,
compute
.
CachingTypes
(
*
volumeSource
.
CachingMode
))
lun
,
err
=
diskController
.
AttachDisk
(
isManagedDisk
,
volumeSource
.
DiskName
,
volumeSource
.
DataDiskURI
,
nodeName
,
compute
.
CachingTypes
(
*
volumeSource
.
CachingMode
))
if
err
==
nil
{
klog
.
V
(
2
)
.
Infof
(
"Attach operation successful: volume %q attached to node %q."
,
volumeSource
.
DataDiskURI
,
nodeName
)
}
else
{
...
...
pkg/volume/azure_dd/azure_dd.go
View file @
4213f4d7
...
...
@@ -44,7 +44,7 @@ type DiskController interface {
DeleteManagedDisk
(
diskURI
string
)
error
// Attaches the disk to the host machine.
AttachDisk
(
isManagedDisk
bool
,
diskName
,
diskUri
string
,
nodeName
types
.
NodeName
,
cachingMode
compute
.
CachingTypes
)
error
AttachDisk
(
isManagedDisk
bool
,
diskName
,
diskUri
string
,
nodeName
types
.
NodeName
,
cachingMode
compute
.
CachingTypes
)
(
int32
,
error
)
// Detaches the disk, identified by disk name or uri, from the host machine.
DetachDisk
(
diskName
,
diskUri
string
,
nodeName
types
.
NodeName
)
error
...
...
staging/src/k8s.io/legacy-cloud-providers/azure/azure_controller_common.go
View file @
4213f4d7
...
...
@@ -91,16 +91,17 @@ func (c *controllerCommon) getNodeVMSet(nodeName types.NodeName) (VMSet, error)
}
// AttachDisk attaches a vhd to vm. The vhd must exist, can be identified by diskName, diskURI.
func
(
c
*
controllerCommon
)
AttachDisk
(
isManagedDisk
bool
,
diskName
,
diskURI
string
,
nodeName
types
.
NodeName
,
cachingMode
compute
.
CachingTypes
)
error
{
// return (lun, error)
func
(
c
*
controllerCommon
)
AttachDisk
(
isManagedDisk
bool
,
diskName
,
diskURI
string
,
nodeName
types
.
NodeName
,
cachingMode
compute
.
CachingTypes
)
(
int32
,
error
)
{
vmset
,
err
:=
c
.
getNodeVMSet
(
nodeName
)
if
err
!=
nil
{
return
err
return
-
1
,
err
}
instanceid
,
err
:=
c
.
cloud
.
InstanceID
(
context
.
TODO
(),
nodeName
)
if
err
!=
nil
{
klog
.
Warningf
(
"failed to get azure instance id (%v)"
,
err
)
return
fmt
.
Errorf
(
"failed to get azure instance id for node %q (%v)"
,
nodeName
,
err
)
return
-
1
,
fmt
.
Errorf
(
"failed to get azure instance id for node %q (%v)"
,
nodeName
,
err
)
}
diskOpMutex
.
LockKey
(
instanceid
)
...
...
@@ -109,11 +110,11 @@ func (c *controllerCommon) AttachDisk(isManagedDisk bool, diskName, diskURI stri
lun
,
err
:=
c
.
GetNextDiskLun
(
nodeName
)
if
err
!=
nil
{
klog
.
Warningf
(
"no LUN available for instance %q (%v)"
,
nodeName
,
err
)
return
fmt
.
Errorf
(
"all LUNs are used, cannot attach volume (%s, %s) to instance %q (%v)"
,
diskName
,
diskURI
,
instanceid
,
err
)
return
-
1
,
fmt
.
Errorf
(
"all LUNs are used, cannot attach volume (%s, %s) to instance %q (%v)"
,
diskName
,
diskURI
,
instanceid
,
err
)
}
klog
.
V
(
2
)
.
Infof
(
"Trying to attach volume %q lun %d to node %q."
,
diskURI
,
lun
,
nodeName
)
return
vmset
.
AttachDisk
(
isManagedDisk
,
diskName
,
diskURI
,
nodeName
,
lun
,
cachingMode
)
return
lun
,
vmset
.
AttachDisk
(
isManagedDisk
,
diskName
,
diskURI
,
nodeName
,
lun
,
cachingMode
)
}
// DetachDisk detaches a disk from host. The vhd can be identified by diskName or diskURI.
...
...
staging/src/k8s.io/legacy-cloud-providers/azure/azure_controller_common_test.go
View file @
4213f4d7
...
...
@@ -36,7 +36,7 @@ func TestAttachDisk(t *testing.T) {
diskURI
:=
fmt
.
Sprintf
(
"/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/disks/disk-name"
,
c
.
SubscriptionID
,
c
.
ResourceGroup
)
err
:=
common
.
AttachDisk
(
true
,
""
,
diskURI
,
"node1"
,
compute
.
CachingTypesReadOnly
)
_
,
err
:=
common
.
AttachDisk
(
true
,
""
,
diskURI
,
"node1"
,
compute
.
CachingTypesReadOnly
)
if
err
!=
nil
{
fmt
.
Printf
(
"TestAttachDisk return expected error: %v"
,
err
)
}
else
{
...
...
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