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
636a181d
Commit
636a181d
authored
Dec 22, 2017
by
andyzhangx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use /dev/disk/by-id instead of /dev/sd* for azure disk
change uuid to id
parent
5001198f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
3 deletions
+33
-3
azure_common_linux.go
pkg/volume/azure_dd/azure_common_linux.go
+33
-3
No files found.
pkg/volume/azure_dd/azure_common_linux.go
View file @
636a181d
...
...
@@ -19,6 +19,7 @@ limitations under the License.
package
azure_dd
import
(
"fmt"
"path"
"strconv"
libstrings
"strings"
...
...
@@ -45,6 +46,27 @@ func listAzureDiskPath(io ioHandler) []string {
return
azureDiskList
}
// getDiskIDByPath get disk id by device name from /dev/disk/by-id
func
getDiskIDByPath
(
io
ioHandler
,
devName
string
)
(
string
,
error
)
{
diskIDPath
:=
"/dev/disk/by-id/"
dirs
,
err
:=
io
.
ReadDir
(
diskIDPath
)
if
err
==
nil
{
for
_
,
f
:=
range
dirs
{
diskPath
:=
diskIDPath
+
f
.
Name
()
link
,
linkErr
:=
io
.
Readlink
(
diskPath
)
if
linkErr
!=
nil
{
glog
.
Warningf
(
"azureDisk - read link (%s) error: %v"
,
diskPath
,
linkErr
)
continue
}
if
libstrings
.
HasSuffix
(
link
,
devName
)
{
return
diskPath
,
nil
}
}
return
""
,
fmt
.
Errorf
(
"device name(%s) is not found under %s"
,
devName
,
diskIDPath
)
}
return
""
,
fmt
.
Errorf
(
"read %s error: %v"
,
diskIDPath
,
err
)
}
func
scsiHostRescan
(
io
ioHandler
,
exec
mount
.
Exec
)
{
scsi_path
:=
"/sys/class/scsi_host/"
if
dirs
,
err
:=
io
.
ReadDir
(
scsi_path
);
err
==
nil
{
...
...
@@ -129,15 +151,23 @@ func findDiskByLunWithConstraint(lun int, io ioHandler, azureDisks []string) (st
dir
:=
path
.
Join
(
sys_path
,
name
,
"block"
)
if
dev
,
err
:=
io
.
ReadDir
(
dir
);
err
==
nil
{
found
:=
false
devName
:=
dev
[
0
]
.
Name
()
for
_
,
diskName
:=
range
azureDisks
{
glog
.
V
(
12
)
.
Infof
(
"azure
disk - validating disk %q with sys disk %q"
,
dev
[
0
]
.
Name
()
,
diskName
)
if
string
(
dev
[
0
]
.
Name
()
)
==
diskName
{
glog
.
V
(
12
)
.
Infof
(
"azure
Disk - validating disk %q with sys disk %q"
,
devName
,
diskName
)
if
string
(
dev
Name
)
==
diskName
{
found
=
true
break
}
}
if
!
found
{
return
"/dev/"
+
dev
[
0
]
.
Name
(),
nil
diskPath
,
err
:=
getDiskIDByPath
(
io
,
devName
)
if
err
==
nil
{
glog
.
V
(
4
)
.
Infof
(
"azureDisk - found %s by %s under /dev/disk/by-id"
,
diskPath
,
devName
)
return
diskPath
,
nil
}
else
{
glog
.
Warningf
(
"azureDisk - getDiskIDByPath by %s failed, error: %v"
,
devName
,
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