Skip to content

Commit 62f6308

Browse files
committed
[tmpnet] Rename NodeProcess to ProcessRuntime
This is intended to be consistent with the addition of KubeRuntime and the name of the runtime configuration (ProcessRuntimeConfig).
1 parent 273c73d commit 62f6308

File tree

3 files changed

+43
-43
lines changed

3 files changed

+43
-43
lines changed

tests/fixture/tmpnet/README.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -57,32 +57,32 @@ repositories.
5757
The functionality in this package is grouped by logical purpose into
5858
the following non-test files:
5959

60-
| Filename | Types | Purpose |
61-
|:----------------------------|:------------|:-----------------------------------------------------------------------|
62-
| flags/ | | Directory defining flags usable with both stdlib flags and spf13/pflag |
63-
| flags/common.go | | Defines type definitions common across other files |
64-
| flags/process_runtime.go | | Defines flags configuring the process node runtime |
65-
| flags/runtime.go | | Defines flags configuring node runtime |
66-
| flags/start_network.go | | Defines flags configuring network start |
67-
| tmpnetctl/ | | Directory containing main entrypoint for tmpnetctl command |
68-
| check_monitoring.go | | Enables checking if logs and metrics were collected |
69-
| defaults.go | | Defines common default configuration |
70-
| detached_process_default.go | | Configures detached processes for darwin and linux |
71-
| detached_process_windows.go | | No-op detached process configuration for windows |
72-
| flags.go | FlagsMap | Simplifies configuration of avalanchego flags |
73-
| genesis.go | | Creates test genesis |
74-
| kube.go | | Library for Kubernetes interaction |
75-
| local_network.go | | Defines configuration for the default local network |
76-
| monitor_processes.go | | Enables collection of logs and metrics from local processes |
77-
| network.go | Network | Orchestrates and configures temporary networks |
78-
| network_config.go | Network | Reads and writes network configuration |
79-
| network_test.go | | Simple test round-tripping Network serialization |
80-
| node.go | Node | Orchestrates and configures nodes |
81-
| node_config.go | Node | Reads and writes node configuration |
82-
| node_process.go | NodeProcess | Orchestrates node processes |
83-
| start_kind_cluster.go | | Starts a local kind cluster |
84-
| subnet.go | Subnet | Orchestrates subnets |
85-
| utils.go | | Defines shared utility functions |
60+
| Filename | Types | Purpose |
61+
|:----------------------------|:---------------|:-----------------------------------------------------------------------|
62+
| flags/ | | Directory defining flags usable with both stdlib flags and spf13/pflag |
63+
| flags/common.go | | Defines type definitions common across other files |
64+
| flags/process_runtime.go | | Defines flags configuring the process node runtime |
65+
| flags/runtime.go | | Defines flags configuring node runtime |
66+
| flags/start_network.go | | Defines flags configuring network start |
67+
| tmpnetctl/ | | Directory containing main entrypoint for tmpnetctl command |
68+
| check_monitoring.go | | Enables checking if logs and metrics were collected |
69+
| defaults.go | | Defines common default configuration |
70+
| detached_process_default.go | | Configures detached processes for darwin and linux |
71+
| detached_process_windows.go | | No-op detached process configuration for windows |
72+
| flags.go | FlagsMap | Simplifies configuration of avalanchego flags |
73+
| genesis.go | | Creates test genesis |
74+
| kube.go | | Library for Kubernetes interaction |
75+
| local_network.go | | Defines configuration for the default local network |
76+
| monitor_processes.go | | Enables collection of logs and metrics from local processes |
77+
| network.go | Network | Orchestrates and configures temporary networks |
78+
| network_config.go | Network | Reads and writes network configuration |
79+
| network_test.go | | Simple test round-tripping Network serialization |
80+
| node.go | Node | Orchestrates and configures nodes |
81+
| node_config.go | Node | Reads and writes node configuration |
82+
| process_runtime.go | ProcessRuntime | Orchestrates node processes |
83+
| start_kind_cluster.go | | Starts a local kind cluster |
84+
| subnet.go | Subnet | Orchestrates subnets |
85+
| utils.go | | Defines shared utility functions |
8686

8787
## Usage
8888

tests/fixture/tmpnet/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func NewNodesOrPanic(count int) []*Node {
119119
// Retrieves the runtime for the node.
120120
func (n *Node) getRuntime() NodeRuntime {
121121
if n.runtime == nil {
122-
n.runtime = &NodeProcess{
122+
n.runtime = &ProcessRuntime{
123123
node: n,
124124
}
125125
}

tests/fixture/tmpnet/node_process.go renamed to tests/fixture/tmpnet/process_runtime.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,20 @@ var (
4444

4545
// Defines local-specific node configuration. Supports setting default
4646
// and node-specific values.
47-
type NodeProcess struct {
47+
type ProcessRuntime struct {
4848
node *Node
4949

5050
// PID of the node process
5151
pid int
5252
}
5353

54-
func (p *NodeProcess) setProcessContext(processContext node.ProcessContext) {
54+
func (p *ProcessRuntime) setProcessContext(processContext node.ProcessContext) {
5555
p.pid = processContext.PID
5656
p.node.URI = processContext.URI
5757
p.node.StakingAddress = processContext.StakingAddress
5858
}
5959

60-
func (p *NodeProcess) readState() error {
60+
func (p *ProcessRuntime) readState() error {
6161
path := p.getProcessContextPath()
6262
bytes, err := os.ReadFile(path)
6363
if errors.Is(err, fs.ErrNotExist) {
@@ -80,7 +80,7 @@ func (p *NodeProcess) readState() error {
8080
// its staking port. The network will start faster with this
8181
// synchronization due to the avoidance of exponential backoff
8282
// if a node tries to connect to a beacon that is not ready.
83-
func (p *NodeProcess) Start(log logging.Logger) error {
83+
func (p *ProcessRuntime) Start(log logging.Logger) error {
8484
// Avoid attempting to start an already running node.
8585
proc, err := p.getProcess()
8686
if err != nil {
@@ -142,7 +142,7 @@ func (p *NodeProcess) Start(log logging.Logger) error {
142142
}
143143

144144
// Signals the node process to stop.
145-
func (p *NodeProcess) InitiateStop() error {
145+
func (p *ProcessRuntime) InitiateStop() error {
146146
proc, err := p.getProcess()
147147
if err != nil {
148148
return fmt.Errorf("failed to retrieve process to stop: %w", err)
@@ -158,7 +158,7 @@ func (p *NodeProcess) InitiateStop() error {
158158
}
159159

160160
// Waits for the node process to stop.
161-
func (p *NodeProcess) WaitForStopped(ctx context.Context) error {
161+
func (p *ProcessRuntime) WaitForStopped(ctx context.Context) error {
162162
ticker := time.NewTicker(defaultNodeTickerInterval)
163163
defer ticker.Stop()
164164
for {
@@ -178,7 +178,7 @@ func (p *NodeProcess) WaitForStopped(ctx context.Context) error {
178178
}
179179
}
180180

181-
func (p *NodeProcess) IsHealthy(ctx context.Context) (bool, error) {
181+
func (p *ProcessRuntime) IsHealthy(ctx context.Context) (bool, error) {
182182
// Check that the node process is running as a precondition for
183183
// checking health. getProcess will also ensure that the node's
184184
// API URI is current.
@@ -197,11 +197,11 @@ func (p *NodeProcess) IsHealthy(ctx context.Context) (bool, error) {
197197
return healthReply.Healthy, nil
198198
}
199199

200-
func (p *NodeProcess) getProcessContextPath() string {
200+
func (p *ProcessRuntime) getProcessContextPath() string {
201201
return filepath.Join(p.node.DataDir, config.DefaultProcessContextFilename)
202202
}
203203

204-
func (p *NodeProcess) waitForProcessContext(ctx context.Context) error {
204+
func (p *ProcessRuntime) waitForProcessContext(ctx context.Context) error {
205205
ticker := time.NewTicker(defaultNodeTickerInterval)
206206
defer ticker.Stop()
207207

@@ -225,7 +225,7 @@ func (p *NodeProcess) waitForProcessContext(ctx context.Context) error {
225225
// Retrieve the node process if it is running. As part of determining
226226
// process liveness, the node's process context will be refreshed if
227227
// live or cleared if not running.
228-
func (p *NodeProcess) getProcess() (*os.Process, error) {
228+
func (p *ProcessRuntime) getProcess() (*os.Process, error) {
229229
// Read the process context to ensure freshness. The node may have
230230
// stopped or been restarted since last read.
231231
if err := p.readState(); err != nil {
@@ -262,7 +262,7 @@ func getProcess(pid int) (*os.Process, error) {
262262
}
263263

264264
// Write monitoring configuration enabling collection of metrics and logs from the node.
265-
func (p *NodeProcess) writeMonitoringConfig() error {
265+
func (p *ProcessRuntime) writeMonitoringConfig() error {
266266
// Ensure labeling that uniquely identifies the node and its network
267267
commonLabels := FlagsMap{
268268
// Explicitly setting an instance label avoids the default
@@ -300,7 +300,7 @@ func (p *NodeProcess) writeMonitoringConfig() error {
300300
}
301301

302302
// Return the path for this node's prometheus configuration.
303-
func (p *NodeProcess) getMonitoringConfigPath(name string) (string, error) {
303+
func (p *ProcessRuntime) getMonitoringConfigPath(name string) (string, error) {
304304
// Ensure a unique filename to allow config files to be added and removed
305305
// by multiple nodes without conflict.
306306
serviceDiscoveryDir, err := getServiceDiscoveryDir(name)
@@ -311,7 +311,7 @@ func (p *NodeProcess) getMonitoringConfigPath(name string) (string, error) {
311311
}
312312

313313
// Ensure the removal of the monitoring configuration files for this node.
314-
func (p *NodeProcess) removeMonitoringConfig() error {
314+
func (p *ProcessRuntime) removeMonitoringConfig() error {
315315
for _, name := range []string{promtailCmd, prometheusCmd} {
316316
configPath, err := p.getMonitoringConfigPath(name)
317317
if err != nil {
@@ -325,7 +325,7 @@ func (p *NodeProcess) removeMonitoringConfig() error {
325325
}
326326

327327
// Write the configuration for a type of monitoring (e.g. prometheus, promtail).
328-
func (p *NodeProcess) writeMonitoringConfigFile(name string, config []FlagsMap) error {
328+
func (p *ProcessRuntime) writeMonitoringConfigFile(name string, config []FlagsMap) error {
329329
configPath, err := p.getMonitoringConfigPath(name)
330330
if err != nil {
331331
return err
@@ -348,11 +348,11 @@ func (p *NodeProcess) writeMonitoringConfigFile(name string, config []FlagsMap)
348348
return nil
349349
}
350350

351-
func (p *NodeProcess) GetLocalURI(_ context.Context) (string, func(), error) {
351+
func (p *ProcessRuntime) GetLocalURI(_ context.Context) (string, func(), error) {
352352
return p.node.URI, func() {}, nil
353353
}
354354

355-
func (p *NodeProcess) GetLocalStakingAddress(_ context.Context) (netip.AddrPort, func(), error) {
355+
func (p *ProcessRuntime) GetLocalStakingAddress(_ context.Context) (netip.AddrPort, func(), error) {
356356
return p.node.StakingAddress, func() {}, nil
357357
}
358358

0 commit comments

Comments
 (0)