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
5941f7b6
Commit
5941f7b6
authored
Aug 01, 2017
by
Kenneth Owens
Committed by
GitHub
Aug 01, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #49016 from jsafrane/pv-controller-no-resync
PV controller: resync informers manually merging to unblock the submit queue
parents
bc5d723c
0eface85
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
6 deletions
+31
-6
pv_controller.go
pkg/controller/volume/persistentvolume/pv_controller.go
+1
-0
pv_controller_base.go
pkg/controller/volume/persistentvolume/pv_controller_base.go
+29
-4
pv_controller_test.go
pkg/controller/volume/persistentvolume/pv_controller_test.go
+1
-2
No files found.
pkg/controller/volume/persistentvolume/pv_controller.go
View file @
5941f7b6
...
...
@@ -164,6 +164,7 @@ type PersistentVolumeController struct {
volumePluginMgr
vol
.
VolumePluginMgr
enableDynamicProvisioning
bool
clusterName
string
resyncPeriod
time
.
Duration
// Cache of the last known version of volumes and claims. This cache is
// thread safe as long as the volumes/claims there are not modified, they
...
...
pkg/controller/volume/persistentvolume/pv_controller_base.go
View file @
5941f7b6
...
...
@@ -87,30 +87,29 @@ func NewController(p ControllerParameters) (*PersistentVolumeController, error)
createProvisionedPVInterval
:
createProvisionedPVInterval
,
claimQueue
:
workqueue
.
NewNamed
(
"claims"
),
volumeQueue
:
workqueue
.
NewNamed
(
"volumes"
),
resyncPeriod
:
p
.
SyncPeriod
,
}
if
err
:=
controller
.
volumePluginMgr
.
InitPlugins
(
p
.
VolumePlugins
,
controller
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Could not initialize volume plugins for PersistentVolume Controller: %v"
,
err
)
}
p
.
VolumeInformer
.
Informer
()
.
AddEventHandler
WithResyncPeriod
(
p
.
VolumeInformer
.
Informer
()
.
AddEventHandler
(
cache
.
ResourceEventHandlerFuncs
{
AddFunc
:
func
(
obj
interface
{})
{
controller
.
enqueueWork
(
controller
.
volumeQueue
,
obj
)
},
UpdateFunc
:
func
(
oldObj
,
newObj
interface
{})
{
controller
.
enqueueWork
(
controller
.
volumeQueue
,
newObj
)
},
DeleteFunc
:
func
(
obj
interface
{})
{
controller
.
enqueueWork
(
controller
.
volumeQueue
,
obj
)
},
},
p
.
SyncPeriod
,
)
controller
.
volumeLister
=
p
.
VolumeInformer
.
Lister
()
controller
.
volumeListerSynced
=
p
.
VolumeInformer
.
Informer
()
.
HasSynced
p
.
ClaimInformer
.
Informer
()
.
AddEventHandler
WithResyncPeriod
(
p
.
ClaimInformer
.
Informer
()
.
AddEventHandler
(
cache
.
ResourceEventHandlerFuncs
{
AddFunc
:
func
(
obj
interface
{})
{
controller
.
enqueueWork
(
controller
.
claimQueue
,
obj
)
},
UpdateFunc
:
func
(
oldObj
,
newObj
interface
{})
{
controller
.
enqueueWork
(
controller
.
claimQueue
,
newObj
)
},
DeleteFunc
:
func
(
obj
interface
{})
{
controller
.
enqueueWork
(
controller
.
claimQueue
,
obj
)
},
},
p
.
SyncPeriod
,
)
controller
.
claimLister
=
p
.
ClaimInformer
.
Lister
()
controller
.
claimListerSynced
=
p
.
ClaimInformer
.
Informer
()
.
HasSynced
...
...
@@ -276,6 +275,7 @@ func (ctrl *PersistentVolumeController) Run(stopCh <-chan struct{}) {
ctrl
.
initializeCaches
(
ctrl
.
volumeLister
,
ctrl
.
claimLister
)
go
wait
.
Until
(
ctrl
.
resync
,
ctrl
.
resyncPeriod
,
stopCh
)
go
wait
.
Until
(
ctrl
.
volumeWorker
,
time
.
Second
,
stopCh
)
go
wait
.
Until
(
ctrl
.
claimWorker
,
time
.
Second
,
stopCh
)
...
...
@@ -397,6 +397,31 @@ func (ctrl *PersistentVolumeController) claimWorker() {
}
}
// resync supplements short resync period of shared informers - we don't want
// all consumers of PV/PVC shared informer to have a short resync period,
// therefore we do our own.
func
(
ctrl
*
PersistentVolumeController
)
resync
()
{
glog
.
V
(
4
)
.
Infof
(
"resyncing PV controller"
)
pvcs
,
err
:=
ctrl
.
claimLister
.
List
(
labels
.
NewSelector
())
if
err
!=
nil
{
glog
.
Warningf
(
"cannot list claims: %s"
,
err
)
return
}
for
_
,
pvc
:=
range
pvcs
{
ctrl
.
enqueueWork
(
ctrl
.
claimQueue
,
pvc
)
}
pvs
,
err
:=
ctrl
.
volumeLister
.
List
(
labels
.
NewSelector
())
if
err
!=
nil
{
glog
.
Warningf
(
"cannot list persistent volumes: %s"
,
err
)
return
}
for
_
,
pv
:=
range
pvs
{
ctrl
.
enqueueWork
(
ctrl
.
volumeQueue
,
pv
)
}
}
// setClaimProvisioner saves
// claim.Annotations[annStorageProvisioner] = class.Provisioner
func
(
ctrl
*
PersistentVolumeController
)
setClaimProvisioner
(
claim
*
v1
.
PersistentVolumeClaim
,
class
*
storage
.
StorageClass
)
(
*
v1
.
PersistentVolumeClaim
,
error
)
{
...
...
pkg/controller/volume/persistentvolume/pv_controller_test.go
View file @
5941f7b6
...
...
@@ -145,8 +145,7 @@ func TestControllerSync(t *testing.T) {
}
// Simulate a periodic resync, just in case some events arrived in a
// wrong order.
ctrl
.
claims
.
Resync
()
ctrl
.
volumes
.
store
.
Resync
()
ctrl
.
resync
()
err
=
reactor
.
waitTest
(
test
)
if
err
!=
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