From 9556e356762928704a7f1f7eb798e1031d002965 Mon Sep 17 00:00:00 2001 From: Zongkun Yang Date: Tue, 27 Mar 2018 12:47:48 -0700 Subject: [PATCH] changed channel buffer --- pkg/preparer/orchestrate.go | 11 +++++------ pkg/preparer/orchestrate_test.go | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/preparer/orchestrate.go b/pkg/preparer/orchestrate.go index f53e1e053..844452810 100644 --- a/pkg/preparer/orchestrate.go +++ b/pkg/preparer/orchestrate.go @@ -86,10 +86,7 @@ func (p *Preparer) WatchForPodManifestsForNode(quitAndAck chan struct{}) { quitChan := make(chan struct{}) errChan := make(chan error) - // buffer this with 1 manifest so that we can make sure that the - // consumer is always reading the latest manifest. Before writing to - // this channel, we will attempt to drain it first - podChan := make(chan []consul.ManifestResult, 1) + podChan := make(chan []consul.ManifestResult) go p.store.WatchPods(consul.INTENT_TREE, p.node, quitChan, errChan, podChan) @@ -119,8 +116,10 @@ func (p *Preparer) WatchForPodManifestsForNode(quitAndAck chan struct{}) { podUniqueKey: pair.PodUniqueKey, } if _, ok := podChanMap[workerID]; !ok { - // spin goroutine for this pod - podChanMap[workerID] = make(chan ManifestPair) + // buffer this with 1 manifest so that we can make sure that the + // consumer is always reading the latest manifest. Before writing to + // this channel, we will attempt to drain it first + podChanMap[workerID] = make(chan ManifestPair, 1) quitChanMap[workerID] = make(chan struct{}) go p.handlePods(podChanMap[workerID], quitChanMap[workerID]) } diff --git a/pkg/preparer/orchestrate_test.go b/pkg/preparer/orchestrate_test.go index 99f9e30a7..ececde189 100644 --- a/pkg/preparer/orchestrate_test.go +++ b/pkg/preparer/orchestrate_test.go @@ -1,3 +1,5 @@ +// +build !race + package preparer import (