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
a4786fc8
Commit
a4786fc8
authored
Jan 03, 2018
by
andyzhangx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prefer /dev/disk/azure/scsi1/ over by-id for azure disk
remove string conversion
parent
636a181d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
15 deletions
+18
-15
azure_common_linux.go
pkg/volume/azure_dd/azure_common_linux.go
+18
-15
No files found.
pkg/volume/azure_dd/azure_common_linux.go
View file @
a4786fc8
...
@@ -46,13 +46,14 @@ func listAzureDiskPath(io ioHandler) []string {
...
@@ -46,13 +46,14 @@ func listAzureDiskPath(io ioHandler) []string {
return
azureDiskList
return
azureDiskList
}
}
// getDisk
IDByPath get disk id by device name from /dev/disk/by-id
// getDisk
LinkByDevName get disk link by device name from devLinkPath, e.g. /dev/disk/azure/, /dev/disk/by-id/
func
getDisk
IDByPath
(
io
ioHandler
,
devName
string
)
(
string
,
error
)
{
func
getDisk
LinkByDevName
(
io
ioHandler
,
devLinkPath
,
devName
string
)
(
string
,
error
)
{
di
skIDPath
:=
"/dev/disk/by-id/"
di
rs
,
err
:=
io
.
ReadDir
(
devLinkPath
)
dirs
,
err
:=
io
.
ReadDir
(
diskID
Path
)
glog
.
V
(
12
)
.
Infof
(
"azureDisk - begin to find %s from %s"
,
devName
,
devLink
Path
)
if
err
==
nil
{
if
err
==
nil
{
for
_
,
f
:=
range
dirs
{
for
_
,
f
:=
range
dirs
{
diskPath
:=
diskIDPath
+
f
.
Name
()
diskPath
:=
devLinkPath
+
f
.
Name
()
glog
.
V
(
12
)
.
Infof
(
"azureDisk - begin to Readlink: %s"
,
diskPath
)
link
,
linkErr
:=
io
.
Readlink
(
diskPath
)
link
,
linkErr
:=
io
.
Readlink
(
diskPath
)
if
linkErr
!=
nil
{
if
linkErr
!=
nil
{
glog
.
Warningf
(
"azureDisk - read link (%s) error: %v"
,
diskPath
,
linkErr
)
glog
.
Warningf
(
"azureDisk - read link (%s) error: %v"
,
diskPath
,
linkErr
)
...
@@ -62,9 +63,9 @@ func getDiskIDByPath(io ioHandler, devName string) (string, error) {
...
@@ -62,9 +63,9 @@ func getDiskIDByPath(io ioHandler, devName string) (string, error) {
return
diskPath
,
nil
return
diskPath
,
nil
}
}
}
}
return
""
,
fmt
.
Errorf
(
"device name(%s) is not found under %s"
,
devName
,
d
iskID
Path
)
return
""
,
fmt
.
Errorf
(
"device name(%s) is not found under %s"
,
devName
,
d
evLink
Path
)
}
}
return
""
,
fmt
.
Errorf
(
"read %s error: %v"
,
d
iskID
Path
,
err
)
return
""
,
fmt
.
Errorf
(
"read %s error: %v"
,
d
evLink
Path
,
err
)
}
}
func
scsiHostRescan
(
io
ioHandler
,
exec
mount
.
Exec
)
{
func
scsiHostRescan
(
io
ioHandler
,
exec
mount
.
Exec
)
{
...
@@ -154,20 +155,22 @@ func findDiskByLunWithConstraint(lun int, io ioHandler, azureDisks []string) (st
...
@@ -154,20 +155,22 @@ func findDiskByLunWithConstraint(lun int, io ioHandler, azureDisks []string) (st
devName
:=
dev
[
0
]
.
Name
()
devName
:=
dev
[
0
]
.
Name
()
for
_
,
diskName
:=
range
azureDisks
{
for
_
,
diskName
:=
range
azureDisks
{
glog
.
V
(
12
)
.
Infof
(
"azureDisk - validating disk %q with sys disk %q"
,
devName
,
diskName
)
glog
.
V
(
12
)
.
Infof
(
"azureDisk - validating disk %q with sys disk %q"
,
devName
,
diskName
)
if
string
(
devName
)
==
diskName
{
if
devName
==
diskName
{
found
=
true
found
=
true
break
break
}
}
}
}
if
!
found
{
if
!
found
{
diskPath
,
err
:=
getDiskIDByPath
(
io
,
devName
)
devLinkPaths
:=
[]
string
{
"/dev/disk/azure/scsi1/"
,
"/dev/disk/by-id/"
}
if
err
==
nil
{
for
_
,
devLinkPath
:=
range
devLinkPaths
{
glog
.
V
(
4
)
.
Infof
(
"azureDisk - found %s by %s under /dev/disk/by-id"
,
diskPath
,
devName
)
diskPath
,
err
:=
getDiskLinkByDevName
(
io
,
devLinkPath
,
devName
)
return
diskPath
,
nil
if
err
==
nil
{
}
else
{
glog
.
V
(
4
)
.
Infof
(
"azureDisk - found %s by %s under %s"
,
diskPath
,
devName
,
devLinkPath
)
glog
.
Warningf
(
"azureDisk - getDiskIDByPath by %s failed, error: %v"
,
devName
,
err
)
return
diskPath
,
nil
return
"/dev/"
+
devName
,
nil
}
glog
.
Warningf
(
"azureDisk - getDiskLinkByDevName by %s under %s failed, error: %v"
,
devName
,
devLinkPath
,
err
)
}
}
return
"/dev/"
+
devName
,
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