Skip to content

Commit

Permalink
Merge pull request #505 from jshufro/jms/v2/errcheck
Browse files Browse the repository at this point in the history
Make alerting package stateful and directly error-logging. Fix the rest of the unchecked errors.
  • Loading branch information
jclapis authored Apr 23, 2024
2 parents 9a237d9 + a2c37f1 commit 75f7994
Show file tree
Hide file tree
Showing 23 changed files with 200 additions and 130 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ jobs:
# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0

# For now, Smart Node will enforce everything except errcheck
args: --disable errcheck

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ require (
github.com/prometheus/client_golang v1.19.0
github.com/prysmaticlabs/prysm/v5 v5.0.3
github.com/rivo/tview v0.0.0-20230208211350-7dfff1ce7854 // DO NOT UPGRADE
github.com/rocket-pool/node-manager-core v0.2.1-0.20240417173109-4b54852b003a
github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240418131940-9aa4643f67c7
github.com/rocket-pool/node-manager-core v0.2.1-0.20240421193204-a16d03d086e8
github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240421193935-e15a3e374153
github.com/shirou/gopsutil/v3 v3.24.3
github.com/tyler-smith/go-bip39 v1.1.0
github.com/wealdtech/go-ens/v3 v3.6.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,12 @@ github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd h1:p9K
github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd/go.mod h1:UE9fof8P7iESVtLn1K9CTSkNRYVFHZHlf96RKbU33kA=
github.com/rocket-pool/node-manager-core v0.2.1-0.20240417173109-4b54852b003a h1:hBuBMT4XT1ne/6eUdnE3BIfnMsFmFPF7pIRud0aWod8=
github.com/rocket-pool/node-manager-core v0.2.1-0.20240417173109-4b54852b003a/go.mod h1:KeVUgf+tc7e+fDUzc/FH3COtgGPoAyIV2Tx3jLN4zng=
github.com/rocket-pool/node-manager-core v0.2.1-0.20240421193204-a16d03d086e8 h1:nUHIRbYWKo+FO0zom8lpXAasNUt91iJ6k74e3fD6UvM=
github.com/rocket-pool/node-manager-core v0.2.1-0.20240421193204-a16d03d086e8/go.mod h1:KeVUgf+tc7e+fDUzc/FH3COtgGPoAyIV2Tx3jLN4zng=
github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240418131940-9aa4643f67c7 h1:liWy3ZNMhHmNOlbKfJXZbUgbBaGj4ZyEZJv+0mWaZ+k=
github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240418131940-9aa4643f67c7/go.mod h1:2IMaRByN0wfkLgNa85LA0I9oJ1QKv1nCNoffFdhF714=
github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240421193935-e15a3e374153 h1:BE6SdszUN+emqc7riBJJtbTpKFeNTtt+78PX1iUVS7c=
github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240421193935-e15a3e374153/go.mod h1:2IMaRByN0wfkLgNa85LA0I9oJ1QKv1nCNoffFdhF714=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo=
Expand Down
10 changes: 8 additions & 2 deletions rocketpool-cli/commands/minipool/vanity.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ func runWorker(report bool, stop *bool, targetPrefix *big.Int, nodeAddress []byt
salt.FillBytes(saltBytes[:])
hasher.Write(nodeAddress)
hasher.Write(saltBytes[:])
hasher.Read(nodeSalt[:])
_, err := hasher.Read(nodeSalt[:])
if err != nil {
panic(err)
}
hasher.Reset()

// This block is the fast way to do `crypto.CreateAddress2(minipoolManagerAddress, nodeSalt, initHash)`
Expand All @@ -174,7 +177,10 @@ func runWorker(report bool, stop *bool, targetPrefix *big.Int, nodeAddress []byt
hasher.Write(minipoolManagerAddress.Bytes())
hasher.Write(nodeSalt[:])
hasher.Write(initHash)
hasher.Read(addressResult[:])
_, err = hasher.Read(addressResult[:])
if err != nil {
panic(err)
}
hasher.Reset()

hashInt.SetBytes(addressResult[12:])
Expand Down
9 changes: 7 additions & 2 deletions rocketpool-cli/commands/service/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,13 @@ func configureService(c *cli.Context) error {
suffix := config.GetContainerName(container)
name := cfg.GetDockerArtifactName(suffix)
fmt.Printf("Stopping %s... ", name)
rp.StopContainer(name)
fmt.Print("done!\n")
err := rp.StopContainer(name)
if err != nil {
fmt.Println("error!")
fmt.Fprintf(os.Stderr, "Error stopping container %s: %s\n", name, err.Error())
continue
}
fmt.Println("done!")
}

fmt.Println()
Expand Down
9 changes: 7 additions & 2 deletions rocketpool-cli/commands/service/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package service

import (
"fmt"
"os"
"regexp"
"strings"
"time"
Expand Down Expand Up @@ -40,8 +41,12 @@ func startService(c *cli.Context, ignoreConfigSuggestion bool) error {
if isUpdate && !ignoreConfigSuggestion {
if c.Bool("yes") || utils.Confirm("Smart Node upgrade detected - starting will overwrite certain settings with the latest defaults (such as container versions).\nYou may want to run `service config` first to see what's changed.\n\nWould you like to continue starting the service?") {
cfg.UpdateDefaults()
rp.SaveConfig(cfg)
fmt.Printf("%sUpdated settings successfully.%s\n", terminal.ColorGreen, terminal.ColorReset)
err := rp.SaveConfig(cfg)
if err != nil {
fmt.Fprintf(os.Stderr, "%sError saving settings: %s%s\n", terminal.ColorRed, err.Error(), terminal.ColorReset)
} else {
fmt.Printf("%sUpdated settings successfully.%s\n", terminal.ColorGreen, terminal.ColorReset)
}
} else {
fmt.Println("Cancelled.")
return nil
Expand Down
2 changes: 1 addition & 1 deletion rocketpool-daemon/api/node/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func (c *nodeStatusContext) PrepareData(data *api.NodeStatusData, opts *bind.Tra
}

// Get alerts from Alertmanager
alerts, err := alerting.FetchAlerts(c.cfg)
alerts, err := alerting.NewAlertFetcher(c.cfg).FetchAlerts()
if err != nil {
// no reason to make `rocketpool node status` fail if we can't get alerts
// (this is more likely to happen in native mode than docker where
Expand Down
Loading

0 comments on commit 75f7994

Please sign in to comment.