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
12845ba9
Commit
12845ba9
authored
Jan 21, 2016
by
Alex Mohr
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #18877 from markturansky/fix_18830
Trigger syncClaim after PV provisioning to reduce wait
parents
f788e1e1
66b58448
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
1 deletion
+79
-1
persistentvolume_claim_binder_controller.go
...sistentvolume/persistentvolume_claim_binder_controller.go
+9
-1
persistentvolume_claim_binder_controller_test.go
...ntvolume/persistentvolume_claim_binder_controller_test.go
+70
-0
No files found.
pkg/controller/persistentvolume/persistentvolume_claim_binder_controller.go
View file @
12845ba9
...
...
@@ -226,7 +226,7 @@ func syncVolume(volumeIndex *persistentVolumeOrderedIndex, binderClient binderCl
nextPhase
=
api
.
VolumeAvailable
if
volume
.
Spec
.
ClaimRef
!=
nil
{
_
,
err
:=
binderClient
.
GetPersistentVolumeClaim
(
volume
.
Spec
.
ClaimRef
.
Namespace
,
volume
.
Spec
.
ClaimRef
.
Name
)
claim
,
err
:=
binderClient
.
GetPersistentVolumeClaim
(
volume
.
Spec
.
ClaimRef
.
Namespace
,
volume
.
Spec
.
ClaimRef
.
Name
)
if
errors
.
IsNotFound
(
err
)
{
// Pending volumes that have a ClaimRef where the claim is missing were recently recycled.
// The Recycler set the phase to VolumePending to start the volume at the beginning of this lifecycle.
...
...
@@ -250,6 +250,14 @@ func syncVolume(volumeIndex *persistentVolumeOrderedIndex, binderClient binderCl
}
else
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Error getting PersistentVolumeClaim[%s/%s]: %v"
,
volume
.
Spec
.
ClaimRef
.
Namespace
,
volume
.
Spec
.
ClaimRef
.
Name
,
err
)
}
// Dynamically provisioned claims remain Pending until its volume is completely provisioned.
// The provisioner updates the PV and triggers this update for the volume. Explicitly sync'ing
// the claim here prevents the need to wait until the next sync period when the claim would normally
// advance to Bound phase. Otherwise, the maximum wait time for the claim to be Bound is the default sync period.
if
claim
!=
nil
&&
claim
.
Status
.
Phase
==
api
.
ClaimPending
&&
keyExists
(
qosProvisioningKey
,
claim
.
Annotations
)
&&
isProvisioningComplete
(
volume
)
{
syncClaim
(
volumeIndex
,
binderClient
,
claim
)
}
}
glog
.
V
(
5
)
.
Infof
(
"PersistentVolume[%s] is available
\n
"
,
volume
.
Name
)
...
...
pkg/controller/persistentvolume/persistentvolume_claim_binder_controller_test.go
View file @
12845ba9
...
...
@@ -143,6 +143,76 @@ func TestClaimRace(t *testing.T) {
}
}
func
TestClaimSyncAfterVolumeProvisioning
(
t
*
testing
.
T
)
{
// Tests that binder.syncVolume will also syncClaim if the PV has completed
// provisioning but the claim is still Pending. We want to advance to Bound
// without having to wait until the binder's next sync period.
claim
:=
&
api
.
PersistentVolumeClaim
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Namespace
:
"bar"
,
Annotations
:
map
[
string
]
string
{
qosProvisioningKey
:
"foo"
,
},
},
Spec
:
api
.
PersistentVolumeClaimSpec
{
AccessModes
:
[]
api
.
PersistentVolumeAccessMode
{
api
.
ReadWriteOnce
},
Resources
:
api
.
ResourceRequirements
{
Requests
:
api
.
ResourceList
{
api
.
ResourceName
(
api
.
ResourceStorage
)
:
resource
.
MustParse
(
"3Gi"
),
},
},
},
Status
:
api
.
PersistentVolumeClaimStatus
{
Phase
:
api
.
ClaimPending
,
},
}
claim
.
ObjectMeta
.
SelfLink
=
testapi
.
Default
.
SelfLink
(
"pvc"
,
""
)
claimRef
,
_
:=
api
.
GetReference
(
claim
)
pv
:=
&
api
.
PersistentVolume
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Annotations
:
map
[
string
]
string
{
pvProvisioningRequiredAnnotationKey
:
pvProvisioningCompletedAnnotationValue
,
},
},
Spec
:
api
.
PersistentVolumeSpec
{
AccessModes
:
[]
api
.
PersistentVolumeAccessMode
{
api
.
ReadWriteOnce
},
Capacity
:
api
.
ResourceList
{
api
.
ResourceName
(
api
.
ResourceStorage
)
:
resource
.
MustParse
(
"10Gi"
),
},
PersistentVolumeSource
:
api
.
PersistentVolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
Path
:
"/tmp/data01"
,
},
},
ClaimRef
:
claimRef
,
},
Status
:
api
.
PersistentVolumeStatus
{
Phase
:
api
.
VolumePending
,
},
}
volumeIndex
:=
NewPersistentVolumeOrderedIndex
()
mockClient
:=
&
mockBinderClient
{
claim
:
claim
,
}
plugMgr
:=
volume
.
VolumePluginMgr
{}
plugMgr
.
InitPlugins
(
host_path
.
ProbeRecyclableVolumePlugins
(
newMockRecycler
,
volume
.
VolumeConfig
{}),
volume
.
NewFakeVolumeHost
(
"/tmp/fake"
,
nil
,
nil
))
// adds the volume to the index, making the volume available.
// pv also completed provisioning, so syncClaim should cause claim's phase to advance to Bound
syncVolume
(
volumeIndex
,
mockClient
,
pv
)
if
mockClient
.
volume
.
Status
.
Phase
!=
api
.
VolumeAvailable
{
t
.
Errorf
(
"Expected phase %s but got %s"
,
api
.
VolumeAvailable
,
mockClient
.
volume
.
Status
.
Phase
)
}
if
mockClient
.
claim
.
Status
.
Phase
!=
api
.
ClaimBound
{
t
.
Errorf
(
"Expected phase %s but got %s"
,
api
.
ClaimBound
,
claim
.
Status
.
Phase
)
}
}
func
TestExampleObjects
(
t
*
testing
.
T
)
{
scenarios
:=
map
[
string
]
struct
{
expected
interface
{}
...
...
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