-
Notifications
You must be signed in to change notification settings - Fork 743
[tmpnet] Avoid serializing the node data directory #3881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -768,16 +757,13 @@ func (n *Network) GetNodeURIs() []NodeURI { | |||
// collecting the bootstrap details for restarting a node). | |||
// For consumption outside of avalanchego. Needs to be kept exported. | |||
func (n *Network) GetBootstrapIPsAndIDs(skippedNode *Node) ([]string, []string, error) { | |||
// Collect staking addresses of non-ephemeral nodes for use in bootstrapping a node | |||
nodes, err := ReadNodes(n, false /* includeEphemeral */) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's much value in forcing a read here. The network can always be reloaded to achieve a similar result.
d07f5ad
to
ddeec15
Compare
tests/fixture/tmpnet/node_config.go
Outdated
func (n *Node) readConfig() error { | ||
bytes, err := os.ReadFile(n.getConfigPath()) | ||
func (n *Node) readConfig(dataDir string) error { | ||
configPath := getNodeConfigPath(dataDir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When read, the node is provided the path where it is stored
ddeec15
to
4795146
Compare
// Construct a unique data dir to ensure the two nodes' data will be stored | ||
// separately. Usually the dir name is the node ID but in this one case the nodes have | ||
// the same node ID. | ||
node2.DataDir = filepath.Join(network.Dir, node1.DataDir+"second") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not for this test, the node data dir could always be computed as [network dir]/[node id]
@@ -133,10 +133,9 @@ func NewEthClient(tc tests.TestContext, nodeURI tmpnet.NodeURI) ethclient.Client | |||
} | |||
|
|||
// Adds an ephemeral node intended to be used by a single test. | |||
func AddEphemeralNode(tc tests.TestContext, network *tmpnet.Network, flags tmpnet.FlagsMap) *tmpnet.Node { | |||
func AddEphemeralNode(tc tests.TestContext, network *tmpnet.Network, node *tmpnet.Node) *tmpnet.Node { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The need to be able to set the DataDir suggested accepting a node instead of a FlagsMap here.
@@ -240,13 +240,6 @@ func (n *Network) EnsureDefaultConfig(log logging.Logger) error { | |||
n.PrimaryChainConfigs[alias].SetDefaults(chainConfig) | |||
} | |||
|
|||
// Ensure nodes are configured |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discovered during testing that this configuration is duplicative - it's already being done on network bootstrap, node start, and node read
} | ||
flags.SetDefault(config.PluginDirKey, processConfig.PluginDir) | ||
|
||
flags.SetDefault(config.DataDirKey, node.DataDir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The kube runtime will set its own data dir since it uses a different filesystem
b5d8d9d
to
d320e14
Compare
DefaultFlags FlagsMap `json:",omitempty"` | ||
DefaultRuntimeConfig NodeRuntimeConfig `json:",omitempty"` | ||
PreFundedKeys []*secp256k1.PrivateKey `json:",omitempty"` | ||
UUID string `json:"uuid,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewing the serialized json, realized that fields should all be in lowerCamelCase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (3)
tests/e2e/helpers.go:136
- [nitpick] The AddEphemeralNode function signature now takes a node pointer rather than flags. Consider updating its documentation comment to reflect this change for clarity.
func AddEphemeralNode(tc tests.TestContext, network *tmpnet.Network, node *tmpnet.Node) *tmpnet.Node {
tests/fixture/tmpnet/network.go:550
- Ensure that node.DataDir is always properly initialized before this check, as the removal of GetDataDir may lead to unintended empty values in some cases.
if len(node.DataDir) == 0 {
tests/e2e/faultinjection/duplicate_node_id.go:43
- [nitpick] Since duplicate node IDs require an explicitly modified DataDir, consider adding an inline comment to explain the rationale behind manually overriding the DataDir for clarity.
node2.DataDir = node1.DataDir + "-second"
0ccb028
to
d736aec
Compare
ca83ff8
to
465cd68
Compare
d736aec
to
af712ec
Compare
465cd68
to
f0440ce
Compare
af712ec
to
196fd09
Compare
f0440ce
to
1c1ab28
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code all LGTM.
Just one high level understanding question on the intended usage: Previously, a Node
's data directory was included in its Flags
, which would get serialized when Write
was called for a given Network
, and now that's not the case. How does that simplify the CLI's usage of tmpnet? Is it that networks/nodes can be restarted using different data directories than before?
Yes, CLI supports moving the directory of an existing network to a different location, so including the data dir meant that CLI needed to support rewriting those paths. With this change, that rewriting is no longer necessary. Edit: A side-effect of the change is better separation between node flags for the process runtime and the kube runtime since they will use different data dirs. Updated the description to reflect this. |
This is intended to simplify usage by CLI.
1c1ab28
to
3b43707
Compare
PR Chain: tmpnet+kube
This PR chain enables tmpnet to deploy temporary networks to Kubernetes. Early PRs refactor tmpnet to support the addition in #3615 of a new tmpnet node runtime for kube.
Why this should be merged
This is intended to simplify usage by CLI. It also moves responsibility for setting the data dir to the runtime since the dir will differ between the node (local fs) and kube runtimes (pvc).
How this was tested
CI, local testing of tmpnetctl
Need to be documented in RELEASES.md?
N/A
TODO