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
ff4a5e20
Commit
ff4a5e20
authored
May 10, 2016
by
derekwaynecarr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow a replication manager to be created that does not record events
parent
a598ae2a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
12 deletions
+31
-12
replication_controller.go
pkg/controller/replication/replication_controller.go
+31
-12
No files found.
pkg/controller/replication/replication_controller.go
View file @
ff4a5e20
...
...
@@ -102,11 +102,18 @@ type ReplicationManager struct {
queue
*
workqueue
.
Type
}
// NewReplicationManager creates a replication manager
func
NewReplicationManager
(
podInformer
framework
.
SharedIndexInformer
,
kubeClient
clientset
.
Interface
,
resyncPeriod
controller
.
ResyncPeriodFunc
,
burstReplicas
int
,
lookupCacheSize
int
)
*
ReplicationManager
{
eventBroadcaster
:=
record
.
NewBroadcaster
()
eventBroadcaster
.
StartLogging
(
glog
.
Infof
)
eventBroadcaster
.
StartRecordingToSink
(
&
unversionedcore
.
EventSinkImpl
{
Interface
:
kubeClient
.
Core
()
.
Events
(
""
)})
return
newReplicationManagerInternal
(
eventBroadcaster
.
NewRecorder
(
api
.
EventSource
{
Component
:
"replication-controller"
}),
podInformer
,
kubeClient
,
resyncPeriod
,
burstReplicas
,
lookupCacheSize
)
}
// newReplicationManagerInternal configures a replication manager with the specified event recorder
func
newReplicationManagerInternal
(
eventRecorder
record
.
EventRecorder
,
podInformer
framework
.
SharedIndexInformer
,
kubeClient
clientset
.
Interface
,
resyncPeriod
controller
.
ResyncPeriodFunc
,
burstReplicas
int
,
lookupCacheSize
int
)
*
ReplicationManager
{
if
kubeClient
!=
nil
&&
kubeClient
.
Core
()
.
GetRESTClient
()
.
GetRateLimiter
()
!=
nil
{
metrics
.
RegisterMetricAndTrackRateLimiterUsage
(
"replication_controller"
,
kubeClient
.
Core
()
.
GetRESTClient
()
.
GetRateLimiter
())
}
...
...
@@ -115,7 +122,7 @@ func NewReplicationManager(podInformer framework.SharedIndexInformer, kubeClient
kubeClient
:
kubeClient
,
podControl
:
controller
.
RealPodControl
{
KubeClient
:
kubeClient
,
Recorder
:
event
Broadcaster
.
NewRecorder
(
api
.
EventSource
{
Component
:
"replication-controller"
})
,
Recorder
:
event
Recorder
,
},
burstReplicas
:
burstReplicas
,
expectations
:
controller
.
NewUIDTrackingControllerExpectations
(
controller
.
NewControllerExpectations
()),
...
...
@@ -195,7 +202,14 @@ func NewReplicationManager(podInformer framework.SharedIndexInformer, kubeClient
rm
.
podStoreSynced
=
rm
.
podController
.
HasSynced
rm
.
lookupCache
=
controller
.
NewMatchingCache
(
lookupCacheSize
)
return
rm
}
// NewReplicationManagerFromClientForIntegration creates a new ReplicationManager that runs its own informer. It disables event recording for use in integration tests.
func
NewReplicationManagerFromClientForIntegration
(
kubeClient
clientset
.
Interface
,
resyncPeriod
controller
.
ResyncPeriodFunc
,
burstReplicas
int
,
lookupCacheSize
int
)
*
ReplicationManager
{
podInformer
:=
informers
.
CreateSharedPodIndexInformer
(
kubeClient
,
resyncPeriod
())
rm
:=
newReplicationManagerInternal
(
&
record
.
FakeRecorder
{},
podInformer
,
kubeClient
,
resyncPeriod
,
burstReplicas
,
lookupCacheSize
)
rm
.
internalPodInformer
=
podInformer
return
rm
}
// NewReplicationManagerFromClient creates a new ReplicationManager that runs its own informer.
...
...
@@ -413,18 +427,23 @@ func (rm *ReplicationManager) enqueueController(obj interface{}) {
// worker runs a worker thread that just dequeues items, processes them, and marks them done.
// It enforces that the syncHandler is never invoked concurrently with the same key.
func
(
rm
*
ReplicationManager
)
worker
()
{
workFunc
:=
func
()
bool
{
key
,
quit
:=
rm
.
queue
.
Get
()
if
quit
{
return
true
}
defer
rm
.
queue
.
Done
(
key
)
err
:=
rm
.
syncHandler
(
key
.
(
string
))
if
err
!=
nil
{
glog
.
Errorf
(
"Error syncing replication controller: %v"
,
err
)
}
return
false
}
for
{
func
()
{
key
,
quit
:=
rm
.
queue
.
Get
()
if
quit
{
return
}
defer
rm
.
queue
.
Done
(
key
)
err
:=
rm
.
syncHandler
(
key
.
(
string
))
if
err
!=
nil
{
glog
.
Errorf
(
"Error syncing replication controller: %v"
,
err
)
}
}()
if
quit
:=
workFunc
();
quit
{
glog
.
Infof
(
"replication controller worker shutting down"
)
return
}
}
}
...
...
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