Leave a record another module's composition now holds, whatever its type, instead of removing it in the node's own apply; a removed module holds nothing back (issue 1944, issue 1945)
This commit is contained in:
@@ -409,6 +409,9 @@ func (a *Agent) heldOut(except string) []delivery.Composed {
|
||||
if h, ok := a.running[m]; ok && h.Phase != delivery.PhaseRemoved {
|
||||
continue
|
||||
}
|
||||
if w := a.wants[m]; w.Present && w.Want.Removed {
|
||||
continue // a module the assigner removed holds nothing back
|
||||
}
|
||||
if w := a.wants[m]; w.Present && !w.Want.Removed && w.Want.FP == fp {
|
||||
waiting[m] = c
|
||||
continue
|
||||
|
||||
@@ -676,3 +676,45 @@ func TestTheNodesOwnApplyHoldsOutAModuleThatMovedToItsOwnComposition(t *testing.
|
||||
t.Fatalf("the others of the node's own apply were %v: systemd-resolved's resources would be removed", names)
|
||||
}
|
||||
}
|
||||
|
||||
// A module the assigner removed holds nothing back, its compositions still in the bucket or not: its resources are its
|
||||
// removal's to take (issue 1945).
|
||||
func TestARemovedModulesCompositionHoldsNothingBack(t *testing.T) {
|
||||
b := newBed(t)
|
||||
fp := fpOf("b")
|
||||
rk, rraw, _ := composition(t, "gone", fp, false, file("gone", "x", "1"))
|
||||
b.comps.before(rk, rraw)
|
||||
gk, err := delivery.WantKey(node, "gone")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
graw, err := delivery.EncodeWant(delivery.Want{Removed: true})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
b.wants.before(gk, graw)
|
||||
nk, nraw, ndig := composition(t, NodeModule, "", false)
|
||||
nwk, _ := delivery.WantNodeKey(node)
|
||||
nwraw, _ := delivery.EncodeNodeWant(delivery.NodeWant{Composed: ndig})
|
||||
b.comps.before(nk, nraw)
|
||||
b.wants.before(nwk, nwraw)
|
||||
stop := b.run()
|
||||
defer stop()
|
||||
eventually(t, "the node's own not applied", func() bool {
|
||||
for _, m := range b.appliedList() {
|
||||
if m == NodeModule {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
for _, others := range b.others {
|
||||
for _, c := range others {
|
||||
if c.Module == "gone" {
|
||||
t.Fatal("a removed module's composition was held out")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user