mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Move periodic backoff gc to federation utils
This commit is contained in:
parent
e72f26a3ff
commit
47f0e738e9
@ -228,17 +228,7 @@ func (fdc *DeploymentController) Run(workers int, stopCh <-chan struct{}) {
|
||||
go wait.Until(fdc.worker, time.Second, stopCh)
|
||||
}
|
||||
|
||||
go func() {
|
||||
for {
|
||||
// Perform backof registry cleanup from time to time.
|
||||
select {
|
||||
case <-time.After(time.Minute):
|
||||
fdc.deploymentBackoff.GC()
|
||||
case <-stopCh:
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
fedutil.StartBackoffGC(fdc.deploymentBackoff, stopCh)
|
||||
|
||||
<-stopCh
|
||||
glog.Infof("Shutting down DeploymentController")
|
||||
|
@ -317,17 +317,9 @@ func (ic *IngressController) Run(stopChan <-chan struct{}) {
|
||||
}
|
||||
ic.reconcileConfigMapForCluster(clusterName)
|
||||
})
|
||||
go func() {
|
||||
select {
|
||||
case <-time.After(time.Minute):
|
||||
glog.V(4).Infof("Ingress controller is garbage collecting")
|
||||
ic.ingressBackoff.GC()
|
||||
ic.configMapBackoff.GC()
|
||||
glog.V(4).Infof("Ingress controller garbage collection complete")
|
||||
case <-stopChan:
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
util.StartBackoffGC(ic.ingressBackoff, stopChan)
|
||||
util.StartBackoffGC(ic.configMapBackoff, stopChan)
|
||||
}
|
||||
|
||||
func (ic *IngressController) deliverIngressObj(obj interface{}, delay time.Duration, failed bool) {
|
||||
|
@ -180,14 +180,7 @@ func (nc *NamespaceController) Run(stopChan <-chan struct{}) {
|
||||
nc.clusterDeliverer.StartWithHandler(func(_ *util.DelayingDelivererItem) {
|
||||
nc.reconcileNamespacesOnClusterChange()
|
||||
})
|
||||
go func() {
|
||||
select {
|
||||
case <-time.After(time.Minute):
|
||||
nc.namespaceBackoff.GC()
|
||||
case <-stopChan:
|
||||
return
|
||||
}
|
||||
}()
|
||||
util.StartBackoffGC(nc.namespaceBackoff, stopChan)
|
||||
}
|
||||
|
||||
func (nc *NamespaceController) deliverNamespaceObj(obj interface{}, delay time.Duration, failed bool) {
|
||||
|
@ -228,14 +228,7 @@ func (frsc *ReplicaSetController) Run(workers int, stopCh <-chan struct{}) {
|
||||
go wait.Until(frsc.worker, time.Second, stopCh)
|
||||
}
|
||||
|
||||
go func() {
|
||||
select {
|
||||
case <-time.After(time.Minute):
|
||||
frsc.replicaSetBackoff.GC()
|
||||
case <-stopCh:
|
||||
return
|
||||
}
|
||||
}()
|
||||
fedutil.StartBackoffGC(frsc.replicaSetBackoff, stopCh)
|
||||
|
||||
<-stopCh
|
||||
glog.Infof("Shutting down ReplicaSetController")
|
||||
|
@ -179,14 +179,7 @@ func (secretcontroller *SecretController) Run(stopChan <-chan struct{}) {
|
||||
secretcontroller.clusterDeliverer.StartWithHandler(func(_ *util.DelayingDelivererItem) {
|
||||
secretcontroller.reconcileSecretsOnClusterChange()
|
||||
})
|
||||
go func() {
|
||||
select {
|
||||
case <-time.After(time.Minute):
|
||||
secretcontroller.secretBackoff.GC()
|
||||
case <-stopChan:
|
||||
return
|
||||
}
|
||||
}()
|
||||
util.StartBackoffGC(secretcontroller.secretBackoff, stopChan)
|
||||
}
|
||||
|
||||
func getSecretKey(namespace, name string) string {
|
||||
|
36
federation/pkg/federation-controller/util/backoff.go
Normal file
36
federation/pkg/federation-controller/util/backoff.go
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package util
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"k8s.io/kubernetes/pkg/util/flowcontrol"
|
||||
)
|
||||
|
||||
func StartBackoffGC(backoff *flowcontrol.Backoff, stopCh <-chan struct{}) {
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-time.After(time.Minute):
|
||||
backoff.GC()
|
||||
case <-stopCh:
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
Loading…
Reference in New Issue
Block a user