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
60fe17d3
Commit
60fe17d3
authored
Apr 19, 2016
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update resource quota controller for shared informers
parent
8c4e3af1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
28 deletions
+32
-28
controllermanager.go
cmd/kube-controller-manager/app/controllermanager.go
+1
-1
controllermanager.go
contrib/mesos/pkg/controllermanager/controllermanager.go
+1
-1
replenishment_controller.go
pkg/controller/resourcequota/replenishment_controller.go
+25
-21
resource_quota_controller.go
pkg/controller/resourcequota/resource_quota_controller.go
+2
-2
resource_quota_controller_test.go
...ontroller/resourcequota/resource_quota_controller_test.go
+3
-3
No files found.
cmd/kube-controller-manager/app/controllermanager.go
View file @
60fe17d3
...
@@ -263,7 +263,7 @@ func StartControllers(s *options.CMServer, kubeClient *client.Client, kubeconfig
...
@@ -263,7 +263,7 @@ func StartControllers(s *options.CMServer, kubeClient *client.Client, kubeconfig
KubeClient
:
resourceQuotaControllerClient
,
KubeClient
:
resourceQuotaControllerClient
,
ResyncPeriod
:
controller
.
StaticResyncPeriodFunc
(
s
.
ResourceQuotaSyncPeriod
.
Duration
),
ResyncPeriod
:
controller
.
StaticResyncPeriodFunc
(
s
.
ResourceQuotaSyncPeriod
.
Duration
),
Registry
:
resourceQuotaRegistry
,
Registry
:
resourceQuotaRegistry
,
ControllerFactory
:
resourcequotacontroller
.
NewReplenishmentControllerFactory
(
resourceQuotaControllerClient
),
ControllerFactory
:
resourcequotacontroller
.
NewReplenishmentControllerFactory
(
podInformer
,
resourceQuotaControllerClient
),
ReplenishmentResyncPeriod
:
ResyncPeriod
(
s
),
ReplenishmentResyncPeriod
:
ResyncPeriod
(
s
),
GroupKindsToReplenish
:
groupKindsToReplenish
,
GroupKindsToReplenish
:
groupKindsToReplenish
,
}
}
...
...
contrib/mesos/pkg/controllermanager/controllermanager.go
View file @
60fe17d3
...
@@ -193,7 +193,7 @@ func (s *CMServer) Run(_ []string) error {
...
@@ -193,7 +193,7 @@ func (s *CMServer) Run(_ []string) error {
Registry
:
resourceQuotaRegistry
,
Registry
:
resourceQuotaRegistry
,
GroupKindsToReplenish
:
groupKindsToReplenish
,
GroupKindsToReplenish
:
groupKindsToReplenish
,
ReplenishmentResyncPeriod
:
s
.
resyncPeriod
,
ReplenishmentResyncPeriod
:
s
.
resyncPeriod
,
ControllerFactory
:
resourcequotacontroller
.
NewReplenishmentControllerFactory
(
resourceQuotaControllerClient
),
ControllerFactory
:
resourcequotacontroller
.
NewReplenishmentControllerFactory
FromClient
(
resourceQuotaControllerClient
),
}
}
go
resourcequotacontroller
.
NewResourceQuotaController
(
resourceQuotaControllerOptions
)
.
Run
(
s
.
ConcurrentResourceQuotaSyncs
,
wait
.
NeverStop
)
go
resourcequotacontroller
.
NewResourceQuotaController
(
resourceQuotaControllerOptions
)
.
Run
(
s
.
ConcurrentResourceQuotaSyncs
,
wait
.
NeverStop
)
...
...
pkg/controller/resourcequota/replenishment_controller.go
View file @
60fe17d3
...
@@ -28,6 +28,7 @@ import (
...
@@ -28,6 +28,7 @@ import (
clientset
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
clientset
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/controller/framework"
"k8s.io/kubernetes/pkg/controller/framework"
"k8s.io/kubernetes/pkg/controller/framework/informers"
"k8s.io/kubernetes/pkg/quota/evaluator/core"
"k8s.io/kubernetes/pkg/quota/evaluator/core"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
utilruntime
"k8s.io/kubernetes/pkg/util/runtime"
utilruntime
"k8s.io/kubernetes/pkg/util/runtime"
...
@@ -86,43 +87,46 @@ func ObjectReplenishmentDeleteFunc(options *ReplenishmentControllerOptions) func
...
@@ -86,43 +87,46 @@ func ObjectReplenishmentDeleteFunc(options *ReplenishmentControllerOptions) func
// ReplenishmentControllerFactory knows how to build replenishment controllers
// ReplenishmentControllerFactory knows how to build replenishment controllers
type
ReplenishmentControllerFactory
interface
{
type
ReplenishmentControllerFactory
interface
{
// NewController returns a controller configured with the specified options
// NewController returns a controller configured with the specified options.
NewController
(
options
*
ReplenishmentControllerOptions
)
(
*
framework
.
Controller
,
error
)
// This method is NOT thread-safe.
NewController
(
options
*
ReplenishmentControllerOptions
)
(
framework
.
ControllerInterface
,
error
)
}
}
// replenishmentControllerFactory implements ReplenishmentControllerFactory
// replenishmentControllerFactory implements ReplenishmentControllerFactory
type
replenishmentControllerFactory
struct
{
type
replenishmentControllerFactory
struct
{
kubeClient
clientset
.
Interface
kubeClient
clientset
.
Interface
podInformer
framework
.
SharedInformer
}
}
// NewReplenishmentControllerFactory returns a factory that knows how to build controllers
// NewReplenishmentControllerFactory returns a factory that knows how to build controllers
// to replenish resources when updated or deleted
// to replenish resources when updated or deleted
func
NewReplenishmentControllerFactory
(
kubeClient
clientset
.
Interface
)
ReplenishmentControllerFactory
{
func
NewReplenishmentControllerFactory
(
podInformer
framework
.
SharedInformer
,
kubeClient
clientset
.
Interface
)
ReplenishmentControllerFactory
{
return
&
replenishmentControllerFactory
{
return
&
replenishmentControllerFactory
{
kubeClient
:
kubeClient
,
kubeClient
:
kubeClient
,
podInformer
:
podInformer
,
}
}
}
}
func
(
r
*
replenishmentControllerFactory
)
NewController
(
options
*
ReplenishmentControllerOptions
)
(
*
framework
.
Controller
,
error
)
{
func
NewReplenishmentControllerFactoryFromClient
(
kubeClient
clientset
.
Interface
)
ReplenishmentControllerFactory
{
var
result
*
framework
.
Controller
return
NewReplenishmentControllerFactory
(
nil
,
kubeClient
)
}
func
(
r
*
replenishmentControllerFactory
)
NewController
(
options
*
ReplenishmentControllerOptions
)
(
framework
.
ControllerInterface
,
error
)
{
var
result
framework
.
ControllerInterface
switch
options
.
GroupKind
{
switch
options
.
GroupKind
{
case
api
.
Kind
(
"Pod"
)
:
case
api
.
Kind
(
"Pod"
)
:
_
,
result
=
framework
.
NewInformer
(
if
r
.
podInformer
!=
nil
{
&
cache
.
ListWatch
{
r
.
podInformer
.
AddEventHandler
(
framework
.
ResourceEventHandlerFuncs
{
ListFunc
:
func
(
options
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
return
r
.
kubeClient
.
Core
()
.
Pods
(
api
.
NamespaceAll
)
.
List
(
options
)
},
WatchFunc
:
func
(
options
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
r
.
kubeClient
.
Core
()
.
Pods
(
api
.
NamespaceAll
)
.
Watch
(
options
)
},
},
&
api
.
Pod
{},
options
.
ResyncPeriod
(),
framework
.
ResourceEventHandlerFuncs
{
UpdateFunc
:
PodReplenishmentUpdateFunc
(
options
),
UpdateFunc
:
PodReplenishmentUpdateFunc
(
options
),
DeleteFunc
:
ObjectReplenishmentDeleteFunc
(
options
),
DeleteFunc
:
ObjectReplenishmentDeleteFunc
(
options
),
},
})
)
result
=
r
.
podInformer
.
GetController
()
break
}
r
.
podInformer
=
informers
.
CreateSharedPodInformer
(
r
.
kubeClient
,
options
.
ResyncPeriod
())
result
=
r
.
podInformer
case
api
.
Kind
(
"Service"
)
:
case
api
.
Kind
(
"Service"
)
:
_
,
result
=
framework
.
NewInformer
(
_
,
result
=
framework
.
NewInformer
(
&
cache
.
ListWatch
{
&
cache
.
ListWatch
{
...
...
pkg/controller/resourcequota/resource_quota_controller.go
View file @
60fe17d3
...
@@ -69,7 +69,7 @@ type ResourceQuotaController struct {
...
@@ -69,7 +69,7 @@ type ResourceQuotaController struct {
// knows how to calculate usage
// knows how to calculate usage
registry
quota
.
Registry
registry
quota
.
Registry
// controllers monitoring to notify for replenishment
// controllers monitoring to notify for replenishment
replenishmentControllers
[]
*
framework
.
Controller
replenishmentControllers
[]
framework
.
ControllerInterface
}
}
func
NewResourceQuotaController
(
options
*
ResourceQuotaControllerOptions
)
*
ResourceQuotaController
{
func
NewResourceQuotaController
(
options
*
ResourceQuotaControllerOptions
)
*
ResourceQuotaController
{
...
@@ -79,7 +79,7 @@ func NewResourceQuotaController(options *ResourceQuotaControllerOptions) *Resour
...
@@ -79,7 +79,7 @@ func NewResourceQuotaController(options *ResourceQuotaControllerOptions) *Resour
queue
:
workqueue
.
New
(),
queue
:
workqueue
.
New
(),
resyncPeriod
:
options
.
ResyncPeriod
,
resyncPeriod
:
options
.
ResyncPeriod
,
registry
:
options
.
Registry
,
registry
:
options
.
Registry
,
replenishmentControllers
:
[]
*
framework
.
Controller
{},
replenishmentControllers
:
[]
framework
.
ControllerInterface
{},
}
}
// set the synchronization handler
// set the synchronization handler
...
...
pkg/controller/resourcequota/resource_quota_controller_test.go
View file @
60fe17d3
...
@@ -113,7 +113,7 @@ func TestSyncResourceQuota(t *testing.T) {
...
@@ -113,7 +113,7 @@ func TestSyncResourceQuota(t *testing.T) {
api
.
Kind
(
"ReplicationController"
),
api
.
Kind
(
"ReplicationController"
),
api
.
Kind
(
"PersistentVolumeClaim"
),
api
.
Kind
(
"PersistentVolumeClaim"
),
},
},
ControllerFactory
:
NewReplenishmentControllerFactory
(
kubeClient
),
ControllerFactory
:
NewReplenishmentControllerFactory
FromClient
(
kubeClient
),
ReplenishmentResyncPeriod
:
controller
.
NoResyncPeriodFunc
,
ReplenishmentResyncPeriod
:
controller
.
NoResyncPeriodFunc
,
}
}
quotaController
:=
NewResourceQuotaController
(
resourceQuotaControllerOptions
)
quotaController
:=
NewResourceQuotaController
(
resourceQuotaControllerOptions
)
...
@@ -199,7 +199,7 @@ func TestSyncResourceQuotaSpecChange(t *testing.T) {
...
@@ -199,7 +199,7 @@ func TestSyncResourceQuotaSpecChange(t *testing.T) {
api
.
Kind
(
"ReplicationController"
),
api
.
Kind
(
"ReplicationController"
),
api
.
Kind
(
"PersistentVolumeClaim"
),
api
.
Kind
(
"PersistentVolumeClaim"
),
},
},
ControllerFactory
:
NewReplenishmentControllerFactory
(
kubeClient
),
ControllerFactory
:
NewReplenishmentControllerFactory
FromClient
(
kubeClient
),
ReplenishmentResyncPeriod
:
controller
.
NoResyncPeriodFunc
,
ReplenishmentResyncPeriod
:
controller
.
NoResyncPeriodFunc
,
}
}
quotaController
:=
NewResourceQuotaController
(
resourceQuotaControllerOptions
)
quotaController
:=
NewResourceQuotaController
(
resourceQuotaControllerOptions
)
...
@@ -276,7 +276,7 @@ func TestSyncResourceQuotaNoChange(t *testing.T) {
...
@@ -276,7 +276,7 @@ func TestSyncResourceQuotaNoChange(t *testing.T) {
api
.
Kind
(
"ReplicationController"
),
api
.
Kind
(
"ReplicationController"
),
api
.
Kind
(
"PersistentVolumeClaim"
),
api
.
Kind
(
"PersistentVolumeClaim"
),
},
},
ControllerFactory
:
NewReplenishmentControllerFactory
(
kubeClient
),
ControllerFactory
:
NewReplenishmentControllerFactory
FromClient
(
kubeClient
),
ReplenishmentResyncPeriod
:
controller
.
NoResyncPeriodFunc
,
ReplenishmentResyncPeriod
:
controller
.
NoResyncPeriodFunc
,
}
}
quotaController
:=
NewResourceQuotaController
(
resourceQuotaControllerOptions
)
quotaController
:=
NewResourceQuotaController
(
resourceQuotaControllerOptions
)
...
...
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