Begin the shadow composer again with a backoff when an input cannot be watched yet, and pin mesh-sdk's fixed head, so a node answers candidates for the whole link (issue 1126, review of L2b round 1)
This commit is contained in:
@@ -355,7 +355,12 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) {
|
||||
sh := NewShadow(senv, func(_ context.Context, a map[string]delivery.CandidateAnswer) { answered <- a })
|
||||
sctx, scancel := context.WithCancel(ctx)
|
||||
defer scancel()
|
||||
go func() { _ = sh.Run(sctx) }()
|
||||
// Review of L2b, round 1, finding 2: the candidates' state is not there when the node starts (a delivery before the
|
||||
// indexer made it): the shadow tries again, and answers once it appears.
|
||||
sb.missing(delivery.PlacementCandidatesBucket, true)
|
||||
go sh.Keep(sctx, func(int) time.Duration { return 5 * time.Millisecond })
|
||||
time.Sleep(30 * time.Millisecond)
|
||||
sb.missing(delivery.PlacementCandidatesBucket, false)
|
||||
sb.made(6)
|
||||
rec, _ := delivery.EncodeHaveNode(delivery.HaveNode{Record: &delivery.NodeRecord{Node: "n1", TunnelKey: "k", SealingKey: "sk", Capabilities: []string{"systemd"}}})
|
||||
tp, _ := delivery.EncodePlacement(trunk)
|
||||
@@ -433,6 +438,17 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) {
|
||||
type patternBus struct {
|
||||
mu sync.Mutex
|
||||
watches []patternWatch
|
||||
absent map[string]bool
|
||||
}
|
||||
|
||||
// missing makes a bucket's watch fail, as one the bus holds no state for, or work again.
|
||||
func (b *patternBus) missing(bucket string, gone bool) {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
if b.absent == nil {
|
||||
b.absent = map[string]bool{}
|
||||
}
|
||||
b.absent[bucket] = gone
|
||||
}
|
||||
|
||||
type patternWatch struct {
|
||||
@@ -445,6 +461,9 @@ func newPatternBus() *patternBus { return &patternBus{} }
|
||||
func (b *patternBus) watch(_ context.Context, bucket, pattern string) (<-chan agent.Update, error) {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
if b.absent[bucket] {
|
||||
return nil, fmt.Errorf("nats: bucket not found")
|
||||
}
|
||||
w := patternWatch{bucket: bucket, pattern: pattern, ch: make(chan agent.Update, 64)}
|
||||
b.watches = append(b.watches, w)
|
||||
return w.ch, nil
|
||||
|
||||
Reference in New Issue
Block a user