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
25e9b9dc
Commit
25e9b9dc
authored
Sep 13, 2016
by
Matthew Wong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Use PV shared informer in PV controller"
parent
115855bb
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
80 deletions
+44
-80
controllermanager.go
cmd/kube-controller-manager/app/controllermanager.go
+1
-1
controllermanager.go
contrib/mesos/pkg/controllermanager/controllermanager.go
+1
-1
controller.go
pkg/controller/volume/persistentvolume/controller.go
+2
-9
controller_base.go
pkg/controller/volume/persistentvolume/controller_base.go
+38
-67
framework_test.go
pkg/controller/volume/persistentvolume/framework_test.go
+1
-1
persistent_volumes_test.go
.../integration/persistentvolumes/persistent_volumes_test.go
+1
-1
No files found.
cmd/kube-controller-manager/app/controllermanager.go
View file @
25e9b9dc
...
...
@@ -430,7 +430,7 @@ func StartControllers(s *options.CMServer, kubeClient *client.Client, kubeconfig
ProbeControllerVolumePlugins
(
cloud
,
s
.
VolumeConfiguration
),
cloud
,
s
.
ClusterName
,
sharedInformers
.
PersistentVolumes
()
.
Informer
(),
nil
,
// volumeSource
nil
,
// claimSource
nil
,
// classSource
nil
,
// eventRecorder
...
...
contrib/mesos/pkg/controllermanager/controllermanager.go
View file @
25e9b9dc
...
...
@@ -289,7 +289,7 @@ func (s *CMServer) Run(_ []string) error {
if
err
!=
nil
{
glog
.
Fatalf
(
"An backward-compatible provisioner could not be created: %v, but one was expected. Provisioning will not work. This functionality is considered an early Alpha version."
,
err
)
}
volumeController
:=
persistentvolumecontroller
.
NewPersistentVolumeController
FromClient
(
volumeController
:=
persistentvolumecontroller
.
NewPersistentVolumeController
(
clientset
.
NewForConfigOrDie
(
restclient
.
AddUserAgent
(
kubeconfig
,
"persistent-volume-binder"
)),
s
.
PVClaimBinderSyncPeriod
.
Duration
,
alphaProvisioner
,
...
...
pkg/controller/volume/persistentvolume/controller.go
View file @
25e9b9dc
...
...
@@ -154,8 +154,8 @@ const createProvisionedPVInterval = 10 * time.Second
// framework.Controllers that watch PersistentVolume and PersistentVolumeClaim
// changes.
type
PersistentVolumeController
struct
{
volumeController
framework
.
ControllerInterface
pvInformer
framework
.
SharedIndexInform
er
volumeController
*
framework
.
Controller
volumeSource
cache
.
ListerWatch
er
claimController
*
framework
.
Controller
claimSource
cache
.
ListerWatcher
classReflector
*
cache
.
Reflector
...
...
@@ -176,13 +176,6 @@ type PersistentVolumeController struct {
claims
cache
.
Store
classes
cache
.
Store
// isInformerInternal is true if the informer we hold is a personal informer,
// false if it is a shared informer. If we're using a normal shared informer,
// then the informer will be started for us. If we have a personal informer,
// we must start it ourselves. If you start the controller using
// NewPersistentVolumeController(passing SharedInformer), this will be false.
isInformerInternal
bool
// Map of scheduled/running operations.
runningOperations
goroutinemap
.
GoRoutineMap
...
...
pkg/controller/volume/persistentvolume/controller_base.go
View file @
25e9b9dc
...
...
@@ -38,8 +38,6 @@ import (
"k8s.io/kubernetes/pkg/watch"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/controller/framework/informers"
"k8s.io/kubernetes/pkg/util/wait"
)
// This file contains the controller base functionality, i.e. framework to
...
...
@@ -54,8 +52,7 @@ func NewPersistentVolumeController(
volumePlugins
[]
vol
.
VolumePlugin
,
cloud
cloudprovider
.
Interface
,
clusterName
string
,
pvInformer
framework
.
SharedIndexInformer
,
claimSource
,
classSource
cache
.
ListerWatcher
,
volumeSource
,
claimSource
,
classSource
cache
.
ListerWatcher
,
eventRecorder
record
.
EventRecorder
,
enableDynamicProvisioning
bool
,
)
*
PersistentVolumeController
{
...
...
@@ -87,8 +84,17 @@ func NewPersistentVolumeController(
}
}
controller
.
pvInformer
=
pvInformer
controller
.
isInformerInternal
=
false
if
volumeSource
==
nil
{
volumeSource
=
&
cache
.
ListWatch
{
ListFunc
:
func
(
options
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
return
kubeClient
.
Core
()
.
PersistentVolumes
()
.
List
(
options
)
},
WatchFunc
:
func
(
options
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
kubeClient
.
Core
()
.
PersistentVolumes
()
.
Watch
(
options
)
},
}
}
controller
.
volumeSource
=
volumeSource
if
claimSource
==
nil
{
claimSource
=
&
cache
.
ListWatch
{
...
...
@@ -114,8 +120,17 @@ func NewPersistentVolumeController(
}
controller
.
classSource
=
classSource
controller
.
volumeController
=
pvInformer
.
GetController
()
_
,
controller
.
volumeController
=
framework
.
NewIndexerInformer
(
volumeSource
,
&
api
.
PersistentVolume
{},
syncPeriod
,
framework
.
ResourceEventHandlerFuncs
{
AddFunc
:
controller
.
addVolume
,
UpdateFunc
:
controller
.
updateVolume
,
DeleteFunc
:
controller
.
deleteVolume
,
},
cache
.
Indexers
{
"accessmodes"
:
accessModesIndexFunc
},
)
_
,
controller
.
claimController
=
framework
.
NewInformer
(
claimSource
,
&
api
.
PersistentVolumeClaim
{},
...
...
@@ -139,55 +154,25 @@ func NewPersistentVolumeController(
return
controller
}
// NewPersistentVolumeControllerFromClient returns a new
// *PersistentVolumeController that runs its own informer.
func
NewPersistentVolumeControllerFromClient
(
kubeClient
clientset
.
Interface
,
syncPeriod
time
.
Duration
,
alphaProvisioner
vol
.
ProvisionableVolumePlugin
,
volumePlugins
[]
vol
.
VolumePlugin
,
cloud
cloudprovider
.
Interface
,
clusterName
string
,
volumeSource
,
claimSource
,
classSource
cache
.
ListerWatcher
,
eventRecorder
record
.
EventRecorder
,
enableDynamicProvisioning
bool
,
)
*
PersistentVolumeController
{
pvInformer
:=
informers
.
NewPVInformer
(
kubeClient
,
syncPeriod
)
if
volumeSource
!=
nil
{
pvInformer
=
framework
.
NewSharedIndexInformer
(
volumeSource
,
&
api
.
PersistentVolume
{},
syncPeriod
,
cache
.
Indexers
{
"accessmodes"
:
accessModesIndexFunc
})
}
ctrl
:=
NewPersistentVolumeController
(
kubeClient
,
syncPeriod
,
alphaProvisioner
,
volumePlugins
,
cloud
,
clusterName
,
pvInformer
,
claimSource
,
classSource
,
eventRecorder
,
enableDynamicProvisioning
,
)
ctrl
.
isInformerInternal
=
true
return
ctrl
}
// initializeCaches fills all controller caches with initial data from etcd in
// order to have the caches already filled when first addClaim/addVolume to
// perform initial synchronization of the controller.
func
(
ctrl
*
PersistentVolumeController
)
initializeCaches
(
volumeStore
cache
.
Store
,
claimSource
cache
.
ListerWatcher
)
{
volumeList
:=
volumeStore
.
List
()
for
_
,
obj
:=
range
volumeList
{
volume
,
ok
:=
obj
.
(
*
api
.
PersistentVolume
)
if
!
ok
{
glog
.
Errorf
(
"PersistentVolumeController can't initialize caches, expected list of volumes, got: %#v"
,
obj
)
}
func
(
ctrl
*
PersistentVolumeController
)
initializeCaches
(
volumeSource
,
claimSource
cache
.
ListerWatcher
)
{
volumeListObj
,
err
:=
volumeSource
.
List
(
api
.
ListOptions
{})
if
err
!=
nil
{
glog
.
Errorf
(
"PersistentVolumeController can't initialize caches: %v"
,
err
)
return
}
volumeList
,
ok
:=
volumeListObj
.
(
*
api
.
PersistentVolumeList
)
if
!
ok
{
glog
.
Errorf
(
"PersistentVolumeController can't initialize caches, expected list of volumes, got: %#v"
,
volumeListObj
)
return
}
for
_
,
volume
:=
range
volumeList
.
Items
{
// Ignore template volumes from kubernetes 1.2
deleted
:=
ctrl
.
upgradeVolumeFrom1_2
(
volume
)
deleted
:=
ctrl
.
upgradeVolumeFrom1_2
(
&
volume
)
if
!
deleted
{
clone
,
err
:=
conversion
.
NewCloner
()
.
DeepCopy
(
volume
)
clone
,
err
:=
conversion
.
NewCloner
()
.
DeepCopy
(
&
volume
)
if
err
!=
nil
{
glog
.
Errorf
(
"error cloning volume %q: %v"
,
volume
.
Name
,
err
)
continue
...
...
@@ -459,21 +444,7 @@ func (ctrl *PersistentVolumeController) deleteClaim(obj interface{}) {
// Run starts all of this controller's control loops
func
(
ctrl
*
PersistentVolumeController
)
Run
(
stopCh
<-
chan
struct
{})
{
glog
.
V
(
4
)
.
Infof
(
"starting PersistentVolumeController"
)
if
ctrl
.
isInformerInternal
{
go
ctrl
.
pvInformer
.
Run
(
stopCh
)
// Wait to avoid data race between Run and AddEventHandler in tests
wait
.
Poll
(
100
*
time
.
Millisecond
,
wait
.
ForeverTestTimeout
,
func
()
(
bool
,
error
)
{
return
ctrl
.
pvInformer
.
HasSynced
(),
nil
})
}
ctrl
.
initializeCaches
(
ctrl
.
pvInformer
.
GetStore
(),
ctrl
.
claimSource
)
// AddEventHandler will send synthetic add events which we don't want until
// we have initialized the caches
ctrl
.
pvInformer
.
AddEventHandler
(
framework
.
ResourceEventHandlerFuncs
{
AddFunc
:
ctrl
.
addVolume
,
UpdateFunc
:
ctrl
.
updateVolume
,
DeleteFunc
:
ctrl
.
deleteVolume
,
})
ctrl
.
initializeCaches
(
ctrl
.
volumeSource
,
ctrl
.
claimSource
)
go
ctrl
.
volumeController
.
Run
(
stopCh
)
go
ctrl
.
claimController
.
Run
(
stopCh
)
go
ctrl
.
classReflector
.
RunUntil
(
stopCh
)
...
...
pkg/controller/volume/persistentvolume/framework_test.go
View file @
25e9b9dc
...
...
@@ -594,7 +594,7 @@ func newTestController(kubeClient clientset.Interface, volumeSource, claimSource
if
classSource
==
nil
{
classSource
=
framework
.
NewFakeControllerSource
()
}
ctrl
:=
NewPersistentVolumeController
FromClient
(
ctrl
:=
NewPersistentVolumeController
(
kubeClient
,
5
*
time
.
Second
,
// sync period
nil
,
// alpha provisioner
...
...
test/integration/persistentvolumes/persistent_volumes_test.go
View file @
25e9b9dc
...
...
@@ -1126,7 +1126,7 @@ func createClients(ns *api.Namespace, t *testing.T, s *httptest.Server, syncPeri
cloud
:=
&
fake_cloud
.
FakeCloud
{}
syncPeriod
=
getSyncPeriod
(
syncPeriod
)
ctrl
:=
persistentvolumecontroller
.
NewPersistentVolumeController
FromClient
(
ctrl
:=
persistentvolumecontroller
.
NewPersistentVolumeController
(
binderClient
,
syncPeriod
,
nil
,
// alpha provisioner
...
...
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