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
669ce59b
Commit
669ce59b
authored
Nov 06, 2016
by
Derek Carr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use available informers in quota replenishment
parent
a10975d0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
6 deletions
+28
-6
replenishment_controller.go
pkg/controller/resourcequota/replenishment_controller.go
+28
-6
No files found.
pkg/controller/resourcequota/replenishment_controller.go
View file @
669ce59b
...
...
@@ -113,8 +113,21 @@ func NewReplenishmentControllerFactoryFromClient(kubeClient clientset.Interface)
return
NewReplenishmentControllerFactory
(
nil
,
kubeClient
)
}
func
(
r
*
replenishmentControllerFactory
)
NewController
(
options
*
ReplenishmentControllerOptions
)
(
cache
.
ControllerInterface
,
error
)
{
var
result
cache
.
ControllerInterface
// controllerFor returns a replenishment controller for the specified group resource.
func
controllerFor
(
groupResource
unversioned
.
GroupResource
,
f
informers
.
SharedInformerFactory
,
handlerFuncs
cache
.
ResourceEventHandlerFuncs
)
(
cache
.
ControllerInterface
,
error
)
{
genericInformer
,
err
:=
f
.
ForResource
(
groupResource
)
if
err
!=
nil
{
return
nil
,
err
}
informer
:=
genericInformer
.
Informer
()
informer
.
AddEventHandler
(
handlerFuncs
)
return
informer
.
GetController
(),
nil
}
func
(
r
*
replenishmentControllerFactory
)
NewController
(
options
*
ReplenishmentControllerOptions
)
(
result
cache
.
ControllerInterface
,
err
error
)
{
if
r
.
kubeClient
!=
nil
&&
r
.
kubeClient
.
Core
()
.
RESTClient
()
.
GetRateLimiter
()
!=
nil
{
metrics
.
RegisterMetricAndTrackRateLimiterUsage
(
"replenishment_controller"
,
r
.
kubeClient
.
Core
()
.
RESTClient
()
.
GetRateLimiter
())
}
...
...
@@ -122,16 +135,15 @@ func (r *replenishmentControllerFactory) NewController(options *ReplenishmentCon
switch
options
.
GroupKind
{
case
api
.
Kind
(
"Pod"
)
:
if
r
.
sharedInformerFactory
!=
nil
{
podInformer
:=
r
.
sharedInformerFactory
.
Pods
()
.
Informer
()
podInformer
.
AddEventHandler
(
cache
.
ResourceEventHandlerFuncs
{
result
,
err
=
controllerFor
(
api
.
Resource
(
"pods"
),
r
.
sharedInformerFactory
,
cache
.
ResourceEventHandlerFuncs
{
UpdateFunc
:
PodReplenishmentUpdateFunc
(
options
),
DeleteFunc
:
ObjectReplenishmentDeleteFunc
(
options
),
})
result
=
podInformer
.
GetController
()
break
}
result
=
informers
.
NewPodInformer
(
r
.
kubeClient
,
options
.
ResyncPeriod
())
case
api
.
Kind
(
"Service"
)
:
// TODO move to informer when defined
_
,
result
=
cache
.
NewInformer
(
&
cache
.
ListWatch
{
ListFunc
:
func
(
options
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
...
...
@@ -149,6 +161,7 @@ func (r *replenishmentControllerFactory) NewController(options *ReplenishmentCon
},
)
case
api
.
Kind
(
"ReplicationController"
)
:
// TODO move to informer when defined
_
,
result
=
cache
.
NewInformer
(
&
cache
.
ListWatch
{
ListFunc
:
func
(
options
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
...
...
@@ -165,6 +178,13 @@ func (r *replenishmentControllerFactory) NewController(options *ReplenishmentCon
},
)
case
api
.
Kind
(
"PersistentVolumeClaim"
)
:
if
r
.
sharedInformerFactory
!=
nil
{
result
,
err
=
controllerFor
(
api
.
Resource
(
"persistentvolumeclaims"
),
r
.
sharedInformerFactory
,
cache
.
ResourceEventHandlerFuncs
{
DeleteFunc
:
ObjectReplenishmentDeleteFunc
(
options
),
})
break
}
// TODO (derekwaynecarr) remove me when we can require a sharedInformerFactory in all code paths...
_
,
result
=
cache
.
NewInformer
(
&
cache
.
ListWatch
{
ListFunc
:
func
(
options
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
...
...
@@ -181,6 +201,7 @@ func (r *replenishmentControllerFactory) NewController(options *ReplenishmentCon
},
)
case
api
.
Kind
(
"Secret"
)
:
// TODO move to informer when defined
_
,
result
=
cache
.
NewInformer
(
&
cache
.
ListWatch
{
ListFunc
:
func
(
options
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
...
...
@@ -197,6 +218,7 @@ func (r *replenishmentControllerFactory) NewController(options *ReplenishmentCon
},
)
case
api
.
Kind
(
"ConfigMap"
)
:
// TODO move to informer when defined
_
,
result
=
cache
.
NewInformer
(
&
cache
.
ListWatch
{
ListFunc
:
func
(
options
api
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
...
...
@@ -215,7 +237,7 @@ func (r *replenishmentControllerFactory) NewController(options *ReplenishmentCon
default
:
return
nil
,
NewUnhandledGroupKindError
(
options
.
GroupKind
)
}
return
result
,
nil
return
result
,
err
}
// ServiceReplenishmentUpdateFunc will replenish if the service was quota tracked has changed service type
...
...
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