Skip to content

Commit dd1b701

Browse files
committed
[tmpnet] Update Network.CreateSubnets to require explicit node restart
tmpnet used to have working support for creating subnets after network bootstrap. Subsequently, that code path has degraded due to subnet creation only being performed as part of bootstrap to both speed up suite setup and avoid disruptive node restart during test execution. Rather than maintain the unused ability to create subnets post-bootstrap, Network.CreateSubnets is updated to make explicit that it is the requirement of the caller to restart nodes to reflect the configuration of newly created subnets.
1 parent 70148ed commit dd1b701

File tree

1 file changed

+5
-40
lines changed

1 file changed

+5
-40
lines changed

tests/fixture/tmpnet/network.go

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ func (n *Network) Bootstrap(ctx context.Context, log logging.Logger) error {
458458
}
459459

460460
// Don't restart the node during subnet creation since it will always be restarted afterwards.
461-
if err := n.CreateSubnets(ctx, log, bootstrapNode, false /* restartRequired */); err != nil {
461+
if err := n.CreateSubnets(ctx, log, bootstrapNode); err != nil {
462462
return stacktrace.Wrap(err)
463463
}
464464

@@ -615,9 +615,9 @@ func (n *Network) GetSubnet(name string) *Subnet {
615615
return nil
616616
}
617617

618-
// Ensure that each subnet on the network is created. If restartRequired is false, node restart
619-
// to pick up configuration changes becomes the responsibility of the caller.
620-
func (n *Network) CreateSubnets(ctx context.Context, log logging.Logger, apiNode *Node, restartRequired bool) error {
618+
// Ensure that each subnet on the network is created. The caller is responsible for ensuring node
619+
// restart if required to ensure nodes read subnet configuration post-creation.
620+
func (n *Network) CreateSubnets(ctx context.Context, log logging.Logger, apiNode *Node) error {
621621
createdSubnets := make([]*Subnet, 0, len(n.Subnets))
622622
apiURI := apiNode.GetAccessibleURI()
623623
for _, subnet := range n.Subnets {
@@ -674,41 +674,6 @@ func (n *Network) CreateSubnets(ctx context.Context, log logging.Logger, apiNode
674674
return stacktrace.Wrap(err)
675675
}
676676

677-
reconfiguredNodes := []*Node{}
678-
for _, node := range n.Nodes {
679-
existingTrackedSubnets := node.Flags[config.TrackSubnetsKey]
680-
trackedSubnets := n.TrackedSubnetsForNode(node.NodeID)
681-
if existingTrackedSubnets == trackedSubnets {
682-
continue
683-
}
684-
node.Flags[config.TrackSubnetsKey] = trackedSubnets
685-
reconfiguredNodes = append(reconfiguredNodes, node)
686-
}
687-
688-
// TODO(samliok): remove the restart required parameter, and check if subnet configuration requires
689-
// a restart instead.
690-
if restartRequired {
691-
log.Info("restarting node(s) to enable them to track the new subnet(s)")
692-
693-
runningNodes := make([]*Node, 0, len(reconfiguredNodes))
694-
for _, node := range reconfiguredNodes {
695-
if node.IsRunning() {
696-
runningNodes = append(runningNodes, node)
697-
}
698-
}
699-
700-
if err := restartNodes(ctx, runningNodes); err != nil {
701-
return stacktrace.Wrap(err)
702-
}
703-
704-
if err := WaitForHealthyNodes(ctx, n.log, runningNodes); err != nil {
705-
return stacktrace.Wrap(err)
706-
}
707-
708-
// since we have restarted nodes, refetch the api uri in case it changed
709-
apiURI = apiNode.GetAccessibleURI()
710-
}
711-
712677
// Add validators for the subnet
713678
for _, subnet := range createdSubnets {
714679
log.Info("adding validators for subnet",
@@ -760,7 +725,7 @@ func (n *Network) CreateSubnets(ctx context.Context, log logging.Logger, apiNode
760725
}
761726
}
762727

763-
if !restartRequired || len(validatorsToRestart) == 0 {
728+
if len(validatorsToRestart) == 0 {
764729
return nil
765730
}
766731

0 commit comments

Comments
 (0)