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
e8c96afc
Commit
e8c96afc
authored
May 03, 2018
by
Tardis Xu
Committed by
guoshaowei
Jun 15, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue #63183 that pods on different nodes mount Ceph RBD PVC stuck on ContainerCreating.
parent
b44fb756
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
7 deletions
+42
-7
rbd.go
pkg/volume/rbd/rbd.go
+30
-6
rbd_test.go
pkg/volume/rbd/rbd_test.go
+1
-0
rbd_util.go
pkg/volume/rbd/rbd_util.go
+11
-1
No files found.
pkg/volume/rbd/rbd.go
View file @
e8c96afc
...
...
@@ -232,6 +232,10 @@ func (plugin *rbdPlugin) createMounterFromVolumeSpecAndPod(spec *volume.Spec, po
if
err
!=
nil
{
return
nil
,
err
}
ams
,
err
:=
getVolumeAccessModes
(
spec
)
if
err
!=
nil
{
return
nil
,
err
}
secretName
,
secretNs
,
err
:=
getSecretNameAndNamespace
(
spec
,
pod
.
Namespace
)
if
err
!=
nil
{
...
...
@@ -255,12 +259,13 @@ func (plugin *rbdPlugin) createMounterFromVolumeSpecAndPod(spec *volume.Spec, po
}
return
&
rbdMounter
{
rbd
:
newRBD
(
""
,
spec
.
Name
(),
img
,
pool
,
ro
,
plugin
,
&
RBDUtil
{}),
Mon
:
mon
,
Id
:
id
,
Keyring
:
keyring
,
Secret
:
secret
,
fsType
:
fstype
,
rbd
:
newRBD
(
""
,
spec
.
Name
(),
img
,
pool
,
ro
,
plugin
,
&
RBDUtil
{}),
Mon
:
mon
,
Id
:
id
,
Keyring
:
keyring
,
Secret
:
secret
,
fsType
:
fstype
,
accessModes
:
ams
,
},
nil
}
...
...
@@ -319,6 +324,10 @@ func (plugin *rbdPlugin) newMounterInternal(spec *volume.Spec, podUID types.UID,
if
err
!=
nil
{
return
nil
,
err
}
ams
,
err
:=
getVolumeAccessModes
(
spec
)
if
err
!=
nil
{
return
nil
,
err
}
return
&
rbdMounter
{
rbd
:
newRBD
(
podUID
,
spec
.
Name
(),
img
,
pool
,
ro
,
plugin
,
manager
),
...
...
@@ -328,6 +337,7 @@ func (plugin *rbdPlugin) newMounterInternal(spec *volume.Spec, podUID types.UID,
Secret
:
secret
,
fsType
:
fstype
,
mountOptions
:
volutil
.
MountOptionFromSpec
(
spec
),
accessModes
:
ams
,
},
nil
}
...
...
@@ -767,6 +777,7 @@ type rbdMounter struct {
mountOptions
[]
string
imageFormat
string
imageFeatures
[]
string
accessModes
[]
v1
.
PersistentVolumeAccessMode
}
var
_
volume
.
Mounter
=
&
rbdMounter
{}
...
...
@@ -1043,6 +1054,19 @@ func getVolumeSourceReadOnly(spec *volume.Spec) (bool, error) {
return
false
,
fmt
.
Errorf
(
"Spec does not reference a RBD volume type"
)
}
func
getVolumeAccessModes
(
spec
*
volume
.
Spec
)
([]
v1
.
PersistentVolumeAccessMode
,
error
)
{
// Only PersistentVolumeSpec has AccessModes
if
spec
.
PersistentVolume
!=
nil
{
if
spec
.
PersistentVolume
.
Spec
.
RBD
!=
nil
{
return
spec
.
PersistentVolume
.
Spec
.
AccessModes
,
nil
}
else
{
return
nil
,
fmt
.
Errorf
(
"Spec does not reference a RBD volume type"
)
}
}
return
nil
,
nil
}
func
parsePodSecret
(
pod
*
v1
.
Pod
,
secretName
string
,
kubeClient
clientset
.
Interface
)
(
string
,
error
)
{
secret
,
err
:=
volutil
.
GetSecretForPod
(
pod
,
secretName
,
kubeClient
)
if
err
!=
nil
{
...
...
pkg/volume/rbd/rbd_test.go
View file @
e8c96afc
...
...
@@ -357,6 +357,7 @@ func TestPlugin(t *testing.T) {
FSType
:
"ext4"
,
},
},
AccessModes
:
[]
v1
.
PersistentVolumeAccessMode
{
v1
.
ReadOnlyMany
},
},
},
false
),
root
:
tmpDir
,
...
...
pkg/volume/rbd/rbd_util.go
View file @
e8c96afc
...
...
@@ -388,12 +388,22 @@ func (util *RBDUtil) AttachDisk(b rbdMounter) (string, error) {
Factor
:
rbdImageWatcherFactor
,
Steps
:
rbdImageWatcherSteps
,
}
needValidUsed
:=
true
// If accessModes contain ReadOnlyMany, we don't need check rbd status of being used.
if
b
.
accessModes
!=
nil
{
for
_
,
v
:=
range
b
.
accessModes
{
if
v
!=
v1
.
ReadWriteOnce
{
needValidUsed
=
false
break
}
}
}
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
!
needValidUsed
||
!
used
,
nil
})
// Return error if rbd image has not become available for the specified timeout.
if
err
==
wait
.
ErrWaitTimeout
{
...
...
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