Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed May 8, 2024
1 parent 584c2de commit d8ad7df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 8 additions & 6 deletions cmd/zetaclientd-supervisor/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"google.golang.org/grpc"
)

// serializedWriter wraps an io.Writer and ensures that writes to it from mulitple goroutines

Check failure on line 25 in cmd/zetaclientd-supervisor/lib.go

View workflow job for this annotation

GitHub Actions / lint

`mulitple` is a misspelling of `multiple` (misspell)
// are serialized
type serializedWriter struct {
upstream io.Writer
lock sync.Mutex
Expand Down Expand Up @@ -56,10 +58,10 @@ type zetaclientdSupervisor struct {
upgradePlanName string
}

func newZetaclientdSupervisor(zetaCoreUrl string, logger zerolog.Logger) (*zetaclientdSupervisor, error) {
func newZetaclientdSupervisor(zetaCoreURL string, logger zerolog.Logger) (*zetaclientdSupervisor, error) {
logger = logger.With().Str("module", "zetaclientdSupervisor").Logger()
conn, err := grpc.Dial(
fmt.Sprintf("%s:9090", zetaCoreUrl),
fmt.Sprintf("%s:9090", zetaCoreURL),
grpc.WithInsecure(),
)
if err != nil {
Expand Down Expand Up @@ -203,21 +205,21 @@ func (s *zetaclientdSupervisor) downloadZetaclientd(ctx context.Context, plan *u
s.logger.Info().Msg("downloading zetaclientd")

binKey := fmt.Sprintf("zetaclientd-%s/%s", runtime.GOOS, runtime.GOARCH)
binUrl, ok := config.Binaries[binKey]
binURL, ok := config.Binaries[binKey]
if !ok {
return fmt.Errorf("no binary found for: %s", binKey)
}
upgradeDir := s.dirForVersion(plan.Name)
err = os.MkdirAll(upgradeDir, 0o770)
err = os.MkdirAll(upgradeDir, 0o750)
if err != nil {
return fmt.Errorf("mkdir %s: %w", upgradeDir, err)
}
upgradePath := path.Join(upgradeDir, "zetaclientd")
// TODO: retry?
// GetFile should validate checksum so long as it was provided in the url
err = getter.GetFile(upgradePath, binUrl, getter.WithContext(ctx), getter.WithUmask(0o750))
err = getter.GetFile(upgradePath, binURL, getter.WithContext(ctx), getter.WithUmask(0o750))
if err != nil {
return fmt.Errorf("get file %s: %w", binUrl, err)
return fmt.Errorf("get file %s: %w", binURL, err)
}

// ensure binary is executable
Expand Down
3 changes: 2 additions & 1 deletion cmd/zetaclientd-supervisor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ func main() {
shouldRestart := true
for shouldRestart {
ctx, cancel := context.WithCancel(ctx)
cmd := exec.CommandContext(ctx, "zetaclientd", os.Args[1:]...)
// pass args from supervisor directly to zetaclientd
cmd := exec.CommandContext(ctx, "zetaclientd", os.Args[1:]...) // #nosec G204
// by default, CommandContext sends SIGKILL. we want more graceful shutdown.
cmd.Cancel = func() error {
return cmd.Process.Signal(syscall.SIGINT)
Expand Down

0 comments on commit d8ad7df

Please sign in to comment.