Skip to content

Commit

Permalink
error type in string
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <[email protected]>
  • Loading branch information
gyuho committed Aug 17, 2024
1 parent 4ac8dba commit 87f09d5
Show file tree
Hide file tree
Showing 29 changed files with 39 additions and 54 deletions.
5 changes: 2 additions & 3 deletions components/accelerator/nvidia/clock-speed/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package clockspeed
import (
"context"
"database/sql"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -61,7 +60,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
return []components.State{
{
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand All @@ -85,7 +84,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
cs = append(cs, components.State{
Name: Name,
Healthy: false,
Error: errors.New(e),
Error: e,
Reason: "nvidia-smi query failed with " + e,
ExtraInfo: map[string]string{
nvidia_query.StateKeySMIExists: fmt.Sprintf("%v", allOutput.SMIExists),
Expand Down
5 changes: 2 additions & 3 deletions components/accelerator/nvidia/clock/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package clock
import (
"context"
"database/sql"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -61,7 +60,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
return []components.State{
{
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand All @@ -85,7 +84,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
cs = append(cs, components.State{
Name: Name,
Healthy: false,
Error: errors.New(e),
Error: e,
Reason: "nvidia-smi query failed with " + e,
ExtraInfo: map[string]string{
nvidia_query.StateKeySMIExists: fmt.Sprintf("%v", allOutput.SMIExists),
Expand Down
1 change: 0 additions & 1 deletion components/accelerator/nvidia/clock/component_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ func (o *Output) States() ([]components.State, error) {
{
Name: StateNameHWSlowdown,
Healthy: true,
Error: nil,
Reason: rm,
ExtraInfo: map[string]string{
StateKeyHWSlowdownData: string(b),
Expand Down
5 changes: 2 additions & 3 deletions components/accelerator/nvidia/ecc/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package ecc
import (
"context"
"database/sql"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -61,7 +60,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
return []components.State{
{
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand All @@ -85,7 +84,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
cs = append(cs, components.State{
Name: Name,
Healthy: false,
Error: errors.New(e),
Error: e,
Reason: "nvidia-smi query failed with " + e,
ExtraInfo: map[string]string{
nvidia_query.StateKeySMIExists: fmt.Sprintf("%v", allOutput.SMIExists),
Expand Down
5 changes: 2 additions & 3 deletions components/accelerator/nvidia/error/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package error

import (
"context"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -56,7 +55,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
return []components.State{
{
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand All @@ -80,7 +79,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
cs = append(cs, components.State{
Name: Name,
Healthy: false,
Error: errors.New(e),
Error: e,
Reason: "nvidia-smi query failed with " + e,
ExtraInfo: map[string]string{
nvidia_query.StateKeySMIExists: fmt.Sprintf("%v", allOutput.SMIExists),
Expand Down
5 changes: 2 additions & 3 deletions components/accelerator/nvidia/fabric-manager/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package fabricmanager

import (
"context"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -72,7 +71,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
return []components.State{
{
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand Down Expand Up @@ -105,7 +104,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
cs = append(cs, components.State{
Name: Name,
Healthy: false,
Error: errors.New(e),
Error: e,
Reason: "fabric manager query failed with " + e,
ExtraInfo: map[string]string{
nvidia_query.StateKeyFabricManagerExists: fmt.Sprintf("%v", allOutput.FabricManagerExists),
Expand Down
2 changes: 1 addition & 1 deletion components/accelerator/nvidia/infiniband/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
return []components.State{
{
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand Down
5 changes: 2 additions & 3 deletions components/accelerator/nvidia/info/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package info

import (
"context"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -56,7 +55,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
return []components.State{
{
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand All @@ -80,7 +79,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
cs = append(cs, components.State{
Name: Name,
Healthy: false,
Error: errors.New(e),
Error: e,
Reason: "nvidia-smi query failed with " + e,
ExtraInfo: map[string]string{
nvidia_query.StateKeySMIExists: fmt.Sprintf("%v", allOutput.SMIExists),
Expand Down
5 changes: 2 additions & 3 deletions components/accelerator/nvidia/memory/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package memory
import (
"context"
"database/sql"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -61,7 +60,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
return []components.State{
{
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand All @@ -85,7 +84,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
cs = append(cs, components.State{
Name: Name,
Healthy: false,
Error: errors.New(e),
Error: e,
Reason: "nvidia-smi query failed with " + e,
ExtraInfo: map[string]string{
nvidia_query.StateKeySMIExists: fmt.Sprintf("%v", allOutput.SMIExists),
Expand Down
2 changes: 1 addition & 1 deletion components/accelerator/nvidia/nvlink/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
return []components.State{
{
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand Down
5 changes: 2 additions & 3 deletions components/accelerator/nvidia/peermem/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package peermem

import (
"context"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -55,7 +54,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
return []components.State{
{
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand All @@ -79,7 +78,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
cs = append(cs, components.State{
Name: Name,
Healthy: false,
Error: errors.New(e),
Error: e,
Reason: "lsmod peermem query failed with " + e,
})
}
Expand Down
5 changes: 2 additions & 3 deletions components/accelerator/nvidia/power/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package power
import (
"context"
"database/sql"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -61,7 +60,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
return []components.State{
{
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand All @@ -85,7 +84,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
cs = append(cs, components.State{
Name: Name,
Healthy: false,
Error: errors.New(e),
Error: e,
Reason: "nvidia-smi query failed with " + e,
ExtraInfo: map[string]string{
nvidia_query.StateKeySMIExists: fmt.Sprintf("%v", allOutput.SMIExists),
Expand Down
5 changes: 2 additions & 3 deletions components/accelerator/nvidia/processes/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package processes
import (
"context"
"database/sql"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -61,7 +60,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
return []components.State{
{
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand All @@ -85,7 +84,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
cs = append(cs, components.State{
Name: Name,
Healthy: false,
Error: errors.New(e),
Error: e,
Reason: "nvidia-smi query failed with " + e,
ExtraInfo: map[string]string{
nvidia_query.StateKeySMIExists: fmt.Sprintf("%v", allOutput.SMIExists),
Expand Down
5 changes: 2 additions & 3 deletions components/accelerator/nvidia/temperature/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package temperature
import (
"context"
"database/sql"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -61,7 +60,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
return []components.State{
{
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand All @@ -85,7 +84,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
cs = append(cs, components.State{
Name: Name,
Healthy: false,
Error: errors.New(e),
Error: e,
Reason: "nvidia-smi query failed with " + e,
ExtraInfo: map[string]string{
nvidia_query.StateKeySMIExists: fmt.Sprintf("%v", allOutput.SMIExists),
Expand Down
5 changes: 2 additions & 3 deletions components/accelerator/nvidia/utilization/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package utilization
import (
"context"
"database/sql"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -61,7 +60,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
return []components.State{
{
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand All @@ -85,7 +84,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
cs = append(cs, components.State{
Name: Name,
Healthy: false,
Error: errors.New(e),
Error: e,
Reason: "nvidia-smi query failed with " + e,
ExtraInfo: map[string]string{
nvidia_query.StateKeySMIExists: fmt.Sprintf("%v", allOutput.SMIExists),
Expand Down
2 changes: 1 addition & 1 deletion components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type State struct {
Name string `json:"name,omitempty"`
Healthy bool `json:"healthy,omitempty"`
Reason string `json:"reason,omitempty"` // a detailed and processed reason on why the component is not healthy
Error error `json:"error,omitempty"` // the unprocessed error returned from the component
Error string `json:"error,omitempty"` // the unprocessed error returned from the component
ExtraInfo map[string]string `json:"extra_info,omitempty"` // any extra information the component may want to expose
}

Expand Down
2 changes: 1 addition & 1 deletion components/containerd/pod/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
{
Name: Name,
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand Down
2 changes: 1 addition & 1 deletion components/cpu/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
{
Name: Name,
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand Down
2 changes: 1 addition & 1 deletion components/disk/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
{
Name: Name,
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand Down
2 changes: 1 addition & 1 deletion components/docker/container/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
{
Name: Name,
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand Down
2 changes: 1 addition & 1 deletion components/fd/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
{
Name: Name,
Healthy: false,
Error: last.Error,
Error: last.Error.Error(),
Reason: "last query failed",
},
}, nil
Expand Down
Loading

0 comments on commit 87f09d5

Please sign in to comment.