services/mounttable: Mount should delete children
A Mount() call on a node that has children should delete the children.
Otherwise, the children are effectively leaked until all the servers are
unmounted from the node, and at that point the old children will start
showing up again.
This is a common scenario with nested mounttables:
mt1 -> mt2 -> {server1, server2, etc}
If mt2 is restarted, or down for a while, the servers will mount
themselves in mt1 as "<mt2's name>/{server1, server2, etc}". When mt2
comes back, it will reclaim <mt2's name>. Before this change, the nodes
for server1, server2, etc would remain in mt1. With this change, these
nodes will be deleted.
Change-Id: I8147c25bdf9be11205e7a3c53dd0981de8e40805
diff --git a/services/mounttable/mounttablelib/mounttable_test.go b/services/mounttable/mounttablelib/mounttable_test.go
index 6dbc804..06d12f2 100644
--- a/services/mounttable/mounttablelib/mounttable_test.go
+++ b/services/mounttable/mounttablelib/mounttable_test.go
@@ -713,6 +713,16 @@
t.Errorf("Unexpected number of servers. Got %d, expected %d", got, expected)
}
}
+
+ // Mount on an existing intermediate node.
+ doMount(t, rootCtx, estr, "1/2/3/4/5/6/7/8/9a/10", naming.JoinAddressName(estr, ""), true)
+ doMount(t, rootCtx, estr, "1/2/3/4/5", naming.JoinAddressName(estr, ""), true)
+ if expected, got := int64(6), nodeCount(t, rootCtx, estr); got != expected {
+ t.Errorf("Unexpected number of nodes. Got %d, expected %d", got, expected)
+ }
+ if expected, got := int64(1), serverCount(t, rootCtx, estr); got != expected {
+ t.Errorf("Unexpected number of servers. Got %d, expected %d", got, expected)
+ }
}
func initTest() (rootCtx *context.T, aliceCtx *context.T, bobCtx *context.T, shutdown v23.Shutdown) {