Skip to content

Commit

Permalink
fixup: More lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
marun committed Dec 23, 2024
1 parent d2d52ad commit 294e38e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion tests/fixture/tmpnet/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func flagsToEnvVarSlice(flags FlagsMap) []corev1.EnvVar {
return envVars
}

func envVarsToJsonValue(envVars []corev1.EnvVar) []map[string]string {
func envVarsToJSONValue(envVars []corev1.EnvVar) []map[string]string {
jsonValue := make([]map[string]string, len(envVars))
for i, envVar := range envVars {
jsonValue[i] = map[string]string{
Expand Down
8 changes: 2 additions & 6 deletions tests/fixture/tmpnet/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@ func (n *Network) StartNode(ctx context.Context, node *Node) error {
}

// Restart a single node.
func (n *Network) RestartNode(ctx context.Context, log logging.Logger, node *Node) error {
// TODO(marun) This no longer needs to be a method of Network - fold it into the node restart method.
func (*Network) RestartNode(ctx context.Context, log logging.Logger, node *Node) error {
// Ensure the node reuses the same API port across restarts to ensure
// consistent labeling of metrics. Otherwise prometheus's automatic
// addition of the `instance` label (host:port) results in
Expand Down Expand Up @@ -661,11 +662,6 @@ func (n *Network) GetSubnet(name string) *Subnet {
// to pick up configuration changes becomes the responsibility of the caller.
func (n *Network) CreateSubnets(ctx context.Context, log logging.Logger, apiURI string, restartRequired bool) error {
createdSubnets := make([]*Subnet, 0, len(n.Subnets))
apiURI, cancel, err := n.Nodes[0].GetLocalURI(ctx)
if err != nil {
return err
}
defer cancel()
for _, subnet := range n.Subnets {
if len(subnet.ValidatorIDs) == 0 {
return fmt.Errorf("subnet %s needs at least one validator", subnet.SubnetID)
Expand Down
13 changes: 3 additions & 10 deletions tests/fixture/tmpnet/node_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"io"
"net/netip"
"os"
"path/filepath"
"slices"
"strings"
"time"
Expand Down Expand Up @@ -45,10 +44,6 @@ type NodePod struct {
node *Node
}

func (p *NodePod) getPodContextPath() string {
return filepath.Join(p.node.GetDataDir(), "pod.json")
}

func (p *NodePod) setNotRunning() {
p.node.URI = ""
p.node.StakingAddress = netip.AddrPort{}
Expand Down Expand Up @@ -140,7 +135,7 @@ func (p *NodePod) Start(ctx context.Context) error {
return err
}
createdStatefulSet, err := clientset.AppsV1().StatefulSets(runtimeConfig.Namespace).Create(
context.Background(),
ctx,
statefulSet,
metav1.CreateOptions{},
)
Expand Down Expand Up @@ -212,13 +207,11 @@ func (p *NodePod) WaitForStopped(ctx context.Context) error {
case <-ticker.C:
}
}

return nil
}

// Restarts the node
func (p *NodePod) Restart(ctx context.Context) error {
// Save node node to disk
// Save node to disk
if err := p.node.Write(); err != nil {
return err
}
Expand All @@ -244,7 +237,7 @@ func (p *NodePod) Restart(ctx context.Context) error {
patches = append(patches, map[string]any{
"op": "replace",
"path": "/spec/template/spec/containers/0/env",
"value": envVarsToJsonValue(nodeEnv),
"value": envVarsToJSONValue(nodeEnv),
})
}

Expand Down
7 changes: 6 additions & 1 deletion tests/fixture/tmpnet/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"syscall"
"time"

"go.uber.org/zap"

"github.com/ava-labs/avalanchego/api/health"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/crypto/secp256k1"
Expand Down Expand Up @@ -62,7 +64,10 @@ func WaitForHealthy(ctx context.Context, log logging.Logger, node *Node) error {
return fmt.Errorf("%w for node %q", err, node.NodeID)
case err != nil:
// Error is recoverable
// TODO(marun) Log the error to aid in troubleshooting once a logger is available
log.Debug("failed to query node health",
zap.Stringer("nodeID", node.NodeID),
zap.Error(err),
)
continue
case healthy:
return nil
Expand Down

0 comments on commit 294e38e

Please sign in to comment.