Keep a module's report under a bounded context the client's stop does not cancel (issue 774)
mesh/delivery merged: source.main moved to novox/mesh-catalog@dd458cb155f5
mesh/delivery-group group feat/l3-final merged: every member is merged
mesh/check checking 6c09be4a703e on dd458cb155f5 | novox/mesh-catalog#605 in group feat/l3-final

The test of a node coming back stops the client before the report of zsh is kept; the cancelled Put left s.applied without zsh, so leftModules never removed it (2 of 20 runs failed under -race, also at origin/main). Thorough: report() keeps under context.WithoutCancel with a 5 s bound; the same test now passes 40 of 40.

Claude-Session: https://claude.ai/code/session_01JG73KG7AfSdh6FP8VrBqCn
This commit is contained in:
2026-11-04 00:46:08 +01:00
parent 448f1ef481
commit 6c09be4a70
@@ -970,7 +970,11 @@ func (c *Client) report(ctx context.Context, kvs map[string]jetstream.KeyValue,
logf("[provisioner-client] the report of %s: %v", r.Module, err) logf("[provisioner-client] the report of %s: %v", r.Module, err)
return return
} }
if _, err := kvs[AppliedBucket].Put(ctx, c.Node+"."+r.Module, body); err != nil { // Kept under a context the client's stop does not cancel, bounded: a report made as the client stops is still kept,
// or s.applied would never name the module and a later pass would never remove it (leftModules).
keep, done := context.WithTimeout(context.WithoutCancel(ctx), 5*time.Second)
defer done()
if _, err := kvs[AppliedBucket].Put(keep, c.Node+"."+r.Module, body); err != nil {
logf("[provisioner-client] the report of %s could not be kept: %v", r.Module, err) logf("[provisioner-client] the report of %s could not be kept: %v", r.Module, err)
} else { } else {
s.applied[r.Module] = true s.applied[r.Module] = true