Fix mesos plugin-test race

ListWatch returned the internal list of the MockPodsListWatch object, leading
to a race. Fixes travis builds.

Fixes mesosphere/kubernetes-mesos#354
This commit is contained in:
Dr. Stefan Schimanski 2015-06-15 07:47:28 +02:00
parent 5e5c1d1097
commit 615e4f99a7

View File

@ -120,7 +120,11 @@ func NewMockPodsListWatch(initialPodList api.PodList) *MockPodsListWatch {
return lw.fakeWatcher, nil
},
ListFunc: func() (runtime.Object, error) {
return &lw.list, nil
lw.lock.Lock()
defer lw.lock.Unlock()
listCopy, err := api.Scheme.DeepCopy(&lw.list)
return listCopy.(*api.PodList), err
},
}
return &lw