Made NamespaceManager.Run indempotent and added graceful shutdown
This commit is contained in:
@@ -62,14 +62,24 @@ func NewNamespaceManager(kubeClient client.Interface, resyncPeriod time.Duration
|
||||
)
|
||||
|
||||
return &NamespaceManager{
|
||||
controller: controller,
|
||||
StopEverything: make(chan struct{}),
|
||||
controller: controller,
|
||||
}
|
||||
}
|
||||
|
||||
// Run begins observing the system. It starts a goroutine and returns immediately.
|
||||
func (nm *NamespaceManager) Run() {
|
||||
go nm.controller.Run(nm.StopEverything)
|
||||
if nm.StopEverything == nil {
|
||||
nm.StopEverything = make(chan struct{})
|
||||
go nm.controller.Run(nm.StopEverything)
|
||||
}
|
||||
}
|
||||
|
||||
// Stop gracefully shutsdown this controller
|
||||
func (nm *NamespaceManager) Stop() {
|
||||
if nm.StopEverything != nil {
|
||||
close(nm.StopEverything)
|
||||
nm.StopEverything = nil
|
||||
}
|
||||
}
|
||||
|
||||
// finalized returns true if the spec.finalizers is empty list
|
||||
|
Reference in New Issue
Block a user