Skip to content

Commit

Permalink
Remove section for executing resetDell periodically
Browse files Browse the repository at this point in the history
Signed-off-by: Tomoki Sugiura <tomoki-sugiura@cybozu.co.jp>
  • Loading branch information
chez-shanpu committed Jan 9, 2024
1 parent 0dfef10 commit 2508c65
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
33 changes: 1 addition & 32 deletions pkg/monitor-hw/cmd/dell.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,15 @@ package cmd

import (
"context"
"os"
"time"

"github.com/cybozu-go/log"
"github.com/cybozu-go/well"
)

func monitorDell(ctx context.Context) error {
if err := initDell(ctx); err != nil {
return err
}
if err := resetDell(ctx); err != nil {
return err
}

env := well.NewEnvironment(ctx)
env.Go(func(ctx context.Context) error {
for {
select {
case <-time.After(time.Duration(opts.resetInterval) * time.Hour):
case <-ctx.Done():
return nil
}

if _, err := os.Stat(opts.noResetFile); err == nil {
// if no-reset file exists, skip reset.
continue
}

if err := resetDell(ctx); err != nil {
log.Error("failed to reset iDRAC", map[string]interface{}{
log.FnError: err,
})
// continue working
}
}
})

env.Stop()
return env.Wait()
return resetDell(ctx)
}

func initDell(ctx context.Context) error {
Expand Down
2 changes: 0 additions & 2 deletions pkg/monitor-hw/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const (
defaultAddress = ":9105"
defaultInterval = 60
defaultResetInterval = 24
defaultNoReset = "/var/lib/setup-hw/no-reset"
)

// rootCmd represents the base command when called without any subcommands
Expand Down Expand Up @@ -126,5 +125,4 @@ func init() {
rootCmd.Flags().StringVar(&opts.listenAddress, "listen", defaultAddress, "listening address and port number")
rootCmd.Flags().IntVar(&opts.interval, "interval", defaultInterval, "interval of collecting metrics in seconds")
rootCmd.Flags().IntVar(&opts.resetInterval, "reset-interval", defaultResetInterval, "interval of resetting iDRAC in hours (dell servers only)")
rootCmd.Flags().StringVar(&opts.noResetFile, "no-reset", defaultNoReset, "path of the no-reset file")
}

0 comments on commit 2508c65

Please sign in to comment.