Merge pull request #34817 from gmarek/podgc

Automatic merge from submit-queue

PodGCController waits for informer sync before doing anything.
This commit is contained in:
Kubernetes Submit Queue 2016-10-15 01:32:05 -07:00 committed by GitHub
commit 560c46574e
2 changed files with 16 additions and 0 deletions

View File

@ -112,6 +112,10 @@ func (gcc *PodGCController) Run(stop <-chan struct{}) {
}
func (gcc *PodGCController) gc() {
if !gcc.podController.HasSynced() || !gcc.nodeController.HasSynced() {
glog.V(2).Infof("PodGCController is waiting for informer sync...")
return
}
pods, err := gcc.podStore.List(labels.Everything())
if err != nil {
glog.Errorf("Error while listing all Pods: %v", err)

View File

@ -28,6 +28,14 @@ import (
"k8s.io/kubernetes/pkg/util/sets"
)
type FakeController struct{}
func (*FakeController) Run(<-chan struct{}) {}
func (*FakeController) HasSynced() bool {
return true
}
func TestGCTerminated(t *testing.T) {
type nameToPhase struct {
name string
@ -111,6 +119,8 @@ func TestGCTerminated(t *testing.T) {
ObjectMeta: api.ObjectMeta{Name: "node"},
})
gcc.nodeStore = cache.StoreToNodeLister{Store: store}
gcc.podController = &FakeController{}
gcc.nodeController = &FakeController{}
gcc.gc()
@ -181,6 +191,8 @@ func TestGCOrphaned(t *testing.T) {
store := cache.NewStore(cache.MetaNamespaceKeyFunc)
gcc.nodeStore = cache.StoreToNodeLister{Store: store}
gcc.podController = &FakeController{}
gcc.nodeController = &FakeController{}
gcc.gc()