Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions cmd/metal-api/internal/issues/issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,39 @@ func TestFindIssues(t *testing.T) {
}
},
},
{
name: "powersupply failure",
only: []Type{TypePowerSupplyFailure},
machines: func() metal.Machines {
defectPowerSupplyMachine := machineTemplate("power-supply-failure")
defectPowerSupplyMachine.IPMI = metal.IPMI{
PowerSupplies: metal.PowerSupplies{
{Status: metal.PowerSupplyStatus{Health: "NO-OK", State: "Absent"}},
},
}

return metal.Machines{
defectPowerSupplyMachine,
machineTemplate("good"),
}
},
eventContainers: func() metal.ProvisioningEventContainers {
return metal.ProvisioningEventContainers{
eventContainerTemplate("power-supply-failure"),
eventContainerTemplate("good"),
}
},
want: func(machines metal.Machines) MachineIssues {
return MachineIssues{
{
Machine: &machines[0],
Issues: Issues{
toIssue(&issuePowerSupplyFailure{details: "Health:NO-OK State:Absent"}),
},
},
}
},
},
{
name: "liveliness dead",
only: []Type{TypeLivelinessDead},
Expand Down
41 changes: 41 additions & 0 deletions cmd/metal-api/internal/issues/powersupply-failure.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package issues

import (
"fmt"
"strings"

"github.com/metal-stack/metal-api/cmd/metal-api/internal/metal"
)

const (
TypePowerSupplyFailure Type = "powersupply-failure"
)

type (
issuePowerSupplyFailure struct {
details string
}
)

func (i *issuePowerSupplyFailure) Spec() *spec {
return &spec{
Type: TypePowerSupplyFailure,
Severity: SeverityMajor,
Description: "machine has power supply failures",
RefURL: "https://docs.metal-stack.io/stable/installation/troubleshoot/#power-supply-failure",
}
}

func (i *issuePowerSupplyFailure) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
for _, ps := range m.IPMI.PowerSupplies {
if strings.ToLower(ps.Status.Health) != "ok" || strings.ToLower(ps.Status.State) != "enabled" {
i.details = fmt.Sprintf("Health:%s State:%s", ps.Status.Health, ps.Status.State)
return true
}
}
return false
}

func (i *issuePowerSupplyFailure) Details() string {
return i.details
}
3 changes: 3 additions & 0 deletions cmd/metal-api/internal/issues/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func AllIssueTypes() []Type {
TypeASNUniqueness,
TypeNonDistinctBMCIP,
TypeNoEventContainer,
TypePowerSupplyFailure,
}
}

Expand Down Expand Up @@ -52,6 +53,8 @@ func NewIssueFromType(t Type) (issue, error) {
return &issueNonDistinctBMCIP{}, nil
case TypeNoEventContainer:
return &issueNoEventContainer{}, nil
case TypePowerSupplyFailure:
return &issuePowerSupplyFailure{}, nil
default:
return nil, fmt.Errorf("unknown issue type: %s", t)
}
Expand Down