Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
arturrez committed Jun 26, 2024
1 parent bbc5152 commit 101a289
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
20 changes: 8 additions & 12 deletions examples/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"time"

"github.com/ava-labs/avalanche-tooling-sdk-go/avalanche"
"github.com/ava-labs/avalanche-tooling-sdk-go/node"
)

Expand All @@ -33,7 +34,7 @@ func main() {
CloudParams: cp,
Count: 2,
Roles: []node.SupportedRole{node.Validator},
NetworkID: "fuji",
Network: avalanche.FujiNetwork(),
AvalancheGoVersion: avalanchegoVersion,
AvalancheCliVersion: avalancheCliVersion,
UseStaticIP: false,
Expand All @@ -59,7 +60,7 @@ func main() {
} else {
fmt.Println(string(output))
}
// sleep for 10 seconds allowing avalancghego container to start
// sleep for 10 seconds allowing AvalancheGo container to start
time.Sleep(10 * time.Second)
// check if avalanchego is running
if output, err := h.Commandf(nil, sshCommandTimeout, "docker ps"); err != nil {
Expand All @@ -68,24 +69,19 @@ func main() {
fmt.Println(string(output))
}
}
fmt.Println("About to create a monitoring node")
// Create a monitoring node
monitoringHosts, err := node.CreateNodes(ctx,
&node.NodeParams{
CloudParams: cp,
Count: 1,
Roles: []node.SupportedRole{node.Monitor},
NetworkID: "",
AvalancheGoVersion: "",
AvalancheCliVersion: "",
UseStaticIP: false,
CloudParams: cp,
Count: 1,
Roles: []node.SupportedRole{node.Monitor},
UseStaticIP: false,
})
if err != nil {
panic(err)
}
fmt.Println("Monitoring host SSH shell ready to execute commands")
// Register nodes with monitoring host
if err := monitoringHosts[0].RegisterWithMonitoring(hosts, ""); err != nil {
if err := monitoringHosts[0].MonitorNodes(hosts, ""); err != nil {
panic(err)
}
}
5 changes: 3 additions & 2 deletions node/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"sync"

"github.com/ava-labs/avalanche-tooling-sdk-go/avalanche"
awsAPI "github.com/ava-labs/avalanche-tooling-sdk-go/cloud/aws"
gcpAPI "github.com/ava-labs/avalanche-tooling-sdk-go/cloud/gcp"
"github.com/ava-labs/avalanche-tooling-sdk-go/constants"
Expand All @@ -19,7 +20,7 @@ type NodeParams struct {
CloudParams *CloudParams
Count int
Roles []SupportedRole
NetworkID string
Network avalanche.Network
AvalancheGoVersion string
AvalancheCliVersion string
UseStaticIP bool
Expand Down Expand Up @@ -235,7 +236,7 @@ func provisionAvagoHost(node Node, nodeParams *NodeParams) error {
if err := node.RunSSHSetupPromtailConfig("127.0.0.1", constants.AvalanchegoLokiPort, node.NodeID, "", ""); err != nil {
return err
}
if err := node.ComposeSSHSetupNode(nodeParams.NetworkID, nodeParams.AvalancheGoVersion, withMonitoring); err != nil {
if err := node.ComposeSSHSetupNode(nodeParams.Network.HRP(), nodeParams.AvalancheGoVersion, withMonitoring); err != nil {
return err
}
if err := node.StartDockerCompose(constants.SSHScriptTimeout); err != nil {
Expand Down
3 changes: 1 addition & 2 deletions node/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func (h *Node) RunSSHSetupMonitoringFolders() error {
}

// RegisterWithMonitoring registers the node with the monitoring service
func (h *Node) RegisterWithMonitoring(targets []Node, chainID string) error {
func (h *Node) MonitorNodes(targets []Node, chainID string) error {
// necessary checks
if !isMonitoringNode(*h) {
return fmt.Errorf("%s is not a monitoring node", h.NodeID)
Expand Down Expand Up @@ -333,7 +333,6 @@ func (h *Node) RegisterWithMonitoring(targets []Node, chainID string) error {
return err
}
if err := h.RunSSHCopyMonitoringDashboards(tmpdir); err != nil {

Check failure on line 335 in node/ssh.go

View workflow job for this annotation

GitHub Actions / Lint

SA9003: empty branch (staticcheck)

}
avalancheGoPorts, machinePorts, ltPorts := getPrometheusTargets(targets)
h.Logger.Infof("avalancheGoPorts: %v, machinePorts: %v, ltPorts: %v", avalancheGoPorts, machinePorts, ltPorts)
Expand Down

0 comments on commit 101a289

Please sign in to comment.