Skip to content

Commit

Permalink
Remove monitor go-routines
Browse files Browse the repository at this point in the history
Signed-off-by: Tomoki Sugiura <[email protected]>
  • Loading branch information
chez-shanpu committed Jan 11, 2024
1 parent 1630fa0 commit 4422922
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
6 changes: 3 additions & 3 deletions pkg/monitor-hw/cmd/dell.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"github.com/cybozu-go/well"
)

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

func initDell(ctx context.Context) error {
func setupDell(ctx context.Context) error {
if err := well.CommandContext(ctx, "/usr/libexec/instsvcdrv-helper", "start").Run(); err != nil {
return err
}
Expand Down
10 changes: 0 additions & 10 deletions pkg/monitor-hw/cmd/qemu.go

This file was deleted.

13 changes: 5 additions & 8 deletions pkg/monitor-hw/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,10 @@ var rootCmd = &cobra.Command{
return err
}

var monitor func(context.Context) error
var client redfish.Client
var ruleGetter redfish.RuleGetter
switch vendor {
case lib.QEMU:
monitor = monitorQEMU
client = redfish.NewMockClient(redfish.DummyRedfishFile)
ruleFile := "qemu.yml"
rule, ok := redfish.Rules[ruleFile]
Expand All @@ -68,7 +66,9 @@ var rootCmd = &cobra.Command{
}

case lib.Dell:
monitor = monitorDell
if err := initDell(cmd.Context()); err != nil {
return err
}
cc := &redfish.ClientConfig{
AddressConfig: ac,
UserConfig: uc,
Expand Down Expand Up @@ -96,15 +96,12 @@ var rootCmd = &cobra.Command{
return errors.New("unsupported vendor hardware")
}

err = startExporter(ruleGetter, client)
if err != nil {
if err := startExporter(ruleGetter, client); err != nil {
return err
}

well.Go(monitor)
well.Stop()
err = well.Wait()
if err != nil && !well.IsSignaled(err) {
if err := well.Wait(); err != nil && !well.IsSignaled(err) {
return err
}
return nil
Expand Down

0 comments on commit 4422922

Please sign in to comment.