From 615e4f99a7d9ecb3e0d3f05d5e5615db7bec3178 Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Mon, 15 Jun 2015 07:47:28 +0200 Subject: [PATCH] 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 --- contrib/mesos/pkg/scheduler/plugin_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contrib/mesos/pkg/scheduler/plugin_test.go b/contrib/mesos/pkg/scheduler/plugin_test.go index 637086b2bd9..91246e40b91 100644 --- a/contrib/mesos/pkg/scheduler/plugin_test.go +++ b/contrib/mesos/pkg/scheduler/plugin_test.go @@ -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