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
0df3e167
Commit
0df3e167
authored
Aug 28, 2018
by
NickrenREN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
only when accessmodes equals to ROX, we don't need check rbd status of being used
parent
963adda7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
23 deletions
+22
-23
rbd_util.go
pkg/volume/rbd/rbd_util.go
+22
-23
No files found.
pkg/volume/rbd/rbd_util.go
View file @
0df3e167
...
@@ -395,39 +395,38 @@ func (util *RBDUtil) AttachDisk(b rbdMounter) (string, error) {
...
@@ -395,39 +395,38 @@ func (util *RBDUtil) AttachDisk(b rbdMounter) (string, error) {
Steps
:
rbdImageWatcherSteps
,
Steps
:
rbdImageWatcherSteps
,
}
}
needValidUsed
:=
true
needValidUsed
:=
true
// If accessModes contain ReadOnlyMany, we don't need check rbd status of being used.
if
b
.
accessModes
!=
nil
{
if
b
.
accessModes
!=
nil
{
for
_
,
v
:=
range
b
.
accessModes
{
// If accessModes only contains ReadOnlyMany, we don't need check rbd status of being used.
if
v
!=
v1
.
ReadWriteOnce
{
if
len
(
b
.
accessModes
)
==
1
&&
b
.
accessModes
[
0
]
==
v1
.
ReadOnlyMany
{
needValidUsed
=
false
needValidUsed
=
false
break
}
}
}
}
else
{
// ReadOnly rbd volume should not check rbd status of being used to
// support mounted as read-only by multiple consumers simultaneously.
needValidUsed
=
!
b
.
rbd
.
ReadOnly
}
}
err
:=
wait
.
ExponentialBackoff
(
backoff
,
func
()
(
bool
,
error
)
{
// If accessModes is nil, the volume is referenced by in-line volume.
used
,
rbdOutput
,
err
:=
util
.
rbdStatus
(
&
b
)
// We can assume the AccessModes to be {"RWO" and "ROX"}, which is what the volume plugin supports.
// We do not need to consider ReadOnly here, because it is used for VolumeMounts.
if
needValidUsed
{
err
:=
wait
.
ExponentialBackoff
(
backoff
,
func
()
(
bool
,
error
)
{
used
,
rbdOutput
,
err
:=
util
.
rbdStatus
(
&
b
)
if
err
!=
nil
{
return
false
,
fmt
.
Errorf
(
"fail to check rbd image status with: (%v), rbd output: (%s)"
,
err
,
rbdOutput
)
}
return
!
used
,
nil
})
// Return error if rbd image has not become available for the specified timeout.
if
err
==
wait
.
ErrWaitTimeout
{
return
""
,
fmt
.
Errorf
(
"rbd image %s/%s is still being used"
,
b
.
Pool
,
b
.
Image
)
}
// Return error if any other errors were encountered during wating for the image to become available.
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
fmt
.
Errorf
(
"fail to check rbd image status with: (%v), rbd output: (%s)"
,
err
,
rbdOutput
)
return
""
,
err
}
}
return
!
needValidUsed
||
!
used
,
nil
})
// Return error if rbd image has not become available for the specified timeout.
if
err
==
wait
.
ErrWaitTimeout
{
return
""
,
fmt
.
Errorf
(
"rbd image %s/%s is still being used"
,
b
.
Pool
,
b
.
Image
)
}
// Return error if any other errors were encountered during wating for the image to become available.
if
err
!=
nil
{
return
""
,
err
}
}
mon
:=
util
.
kernelRBDMonitorsOpt
(
b
.
Mon
)
mon
:=
util
.
kernelRBDMonitorsOpt
(
b
.
Mon
)
glog
.
V
(
1
)
.
Infof
(
"rbd: map mon %s"
,
mon
)
glog
.
V
(
1
)
.
Infof
(
"rbd: map mon %s"
,
mon
)
_
,
err
=
b
.
exec
.
Run
(
"modprobe"
,
"rbd"
)
_
,
err
:
=
b
.
exec
.
Run
(
"modprobe"
,
"rbd"
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Warningf
(
"rbd: failed to load rbd kernel module:%v"
,
err
)
glog
.
Warningf
(
"rbd: failed to load rbd kernel module:%v"
,
err
)
}
}
...
...
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