Skip to content

Commit

Permalink
Naming.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 committed Oct 9, 2023
1 parent 500f1f5 commit aca10db
Show file tree
Hide file tree
Showing 19 changed files with 119 additions and 119 deletions.
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/issues/asn-uniqueness.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

const (
IssueTypeASNUniqueness IssueType = "asn-not-unique"
TypeASNUniqueness IssueType = "asn-not-unique"
)

type (
Expand All @@ -20,14 +20,14 @@ type (

func (i *IssueASNUniqueness) Spec() *spec {
return &spec{
Type: IssueTypeASNUniqueness,
Severity: IssueSeverityMinor,
Type: TypeASNUniqueness,
Severity: SeverityMinor,
Description: "The ASN is not unique (only impact on firewalls)",
RefURL: "https://docs.metal-stack.io/stable/installation/troubleshoot/#asn-not-unique",
}
}

func (i *IssueASNUniqueness) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *IssueConfig) bool {
func (i *IssueASNUniqueness) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
var (
machineASNs = map[uint32]metal.Machines{}
overlaps []string
Expand Down
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/issues/bmc-info-outdated.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

const (
IssueTypeBMCInfoOutdated IssueType = "bmc-info-outdated"
TypeBMCInfoOutdated IssueType = "bmc-info-outdated"
)

type (
Expand All @@ -21,7 +21,7 @@ func (i *IssueBMCInfoOutdated) Details() string {
return i.details
}

func (i *IssueBMCInfoOutdated) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *IssueConfig) bool {
func (i *IssueBMCInfoOutdated) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
if m.IPMI.LastUpdated.IsZero() {
i.details = "machine ipmi has never been set"
return true
Expand All @@ -39,8 +39,8 @@ func (i *IssueBMCInfoOutdated) Evaluate(m metal.Machine, ec metal.ProvisioningEv

func (*IssueBMCInfoOutdated) Spec() *spec {
return &spec{
Type: IssueTypeBMCInfoOutdated,
Severity: IssueSeverityMajor,
Type: TypeBMCInfoOutdated,
Severity: SeverityMajor,
Description: "BMC has not been updated from either metal-hammer or metal-bmc",
RefURL: "https://docs.metal-stack.io/stable/installation/troubleshoot/#bmc-info-outdated",
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/issues/bmc-without-ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package issues
import "github.com/metal-stack/metal-api/cmd/metal-api/internal/metal"

const (
IssueTypeBMCWithoutIP IssueType = "bmc-without-ip"
TypeBMCWithoutIP IssueType = "bmc-without-ip"
)

type (
Expand All @@ -12,14 +12,14 @@ type (

func (i *IssueBMCWithoutIP) Spec() *spec {
return &spec{
Type: IssueTypeBMCWithoutIP,
Severity: IssueSeverityMajor,
Type: TypeBMCWithoutIP,
Severity: SeverityMajor,
Description: "BMC has no ip address",
RefURL: "https://docs.metal-stack.io/stable/installation/troubleshoot/#bmc-without-ip",
}
}

func (i *IssueBMCWithoutIP) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *IssueConfig) bool {
func (i *IssueBMCWithoutIP) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
return m.IPMI.Address == ""
}

Expand Down
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/issues/bmc-without-mac.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package issues
import "github.com/metal-stack/metal-api/cmd/metal-api/internal/metal"

const (
IssueTypeBMCWithoutMAC IssueType = "bmc-without-mac"
TypeBMCWithoutMAC IssueType = "bmc-without-mac"
)

type (
Expand All @@ -12,14 +12,14 @@ type (

func (i *IssueBMCWithoutMAC) Spec() *spec {
return &spec{
Type: IssueTypeBMCWithoutMAC,
Severity: IssueSeverityMajor,
Type: TypeBMCWithoutMAC,
Severity: SeverityMajor,
Description: "BMC has no mac address",
RefURL: "https://docs.metal-stack.io/stable/installation/troubleshoot/#bmc-without-mac",
}
}

func (i *IssueBMCWithoutMAC) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *IssueConfig) bool {
func (i *IssueBMCWithoutMAC) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
return m.IPMI.MacAddress == ""
}

Expand Down
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/issues/crash-loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

const (
IssueTypeCrashLoop IssueType = "crashloop"
TypeCrashLoop IssueType = "crashloop"
)

type (
Expand All @@ -15,14 +15,14 @@ type (

func (i *IssueCrashLoop) Spec() *spec {
return &spec{
Type: IssueTypeCrashLoop,
Severity: IssueSeverityMajor,
Type: TypeCrashLoop,
Severity: SeverityMajor,
Description: "machine is in a provisioning crash loop (⭕)",
RefURL: "https://docs.metal-stack.io/stable/installation/troubleshoot/#crashloop",
}
}

func (i *IssueCrashLoop) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *IssueConfig) bool {
func (i *IssueCrashLoop) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
if ec.CrashLoop {
if pointer.FirstOrZero(ec.Events).Event == metal.ProvisioningEventWaiting {
// Machine which are waiting are not considered to have issues
Expand Down
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/issues/failed-machine-reclaim.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

const (
IssueTypeFailedMachineReclaim IssueType = "failed-machine-reclaim"
TypeFailedMachineReclaim IssueType = "failed-machine-reclaim"
)

type (
Expand All @@ -15,14 +15,14 @@ type (

func (i *IssueFailedMachineReclaim) Spec() *spec {
return &spec{
Type: IssueTypeFailedMachineReclaim,
Severity: IssueSeverityCritical,
Type: TypeFailedMachineReclaim,
Severity: SeverityCritical,
Description: "machine phones home but not allocated",
RefURL: "https://docs.metal-stack.io/stable/installation/troubleshoot/#failed-machine-reclaim",
}
}

func (i *IssueFailedMachineReclaim) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *IssueConfig) bool {
func (i *IssueFailedMachineReclaim) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
if ec.FailedMachineReclaim {
return true
}
Expand Down
10 changes: 5 additions & 5 deletions cmd/metal-api/internal/issues/issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

type (
// IssueConfig contains configuration parameters for finding machine issues
IssueConfig struct {
// Config contains configuration parameters for finding machine issues
Config struct {
Machines metal.Machines
EventContainers metal.ProvisioningEventContainers
Severity IssueSeverity
Expand Down Expand Up @@ -43,7 +43,7 @@ type (
issue interface {
// Evaluate decides whether a given machine has the machine issue.
// the third argument contains additional information that may be required for the issue evaluation
Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *IssueConfig) bool
Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool
// Spec returns the issue spec of this issue.
Spec() *spec
// Details returns additional information on the issue after the evaluation.
Expand Down Expand Up @@ -84,7 +84,7 @@ func toIssue(i issue) Issue {
}
}

func FindIssues(c *IssueConfig) (MachineIssuesMap, error) {
func FindIssues(c *Config) (MachineIssuesMap, error) {
if c.LastErrorThreshold == 0 {
c.LastErrorThreshold = DefaultLastErrorThreshold()
}
Expand Down Expand Up @@ -137,7 +137,7 @@ func (mis MachineIssues) Get(id string) *MachineWithIssues {
return nil
}

func (c *IssueConfig) includeIssue(t IssueType) bool {
func (c *Config) includeIssue(t IssueType) bool {
issue, err := NewIssueFromType(t)
if err != nil {
return false
Expand Down
22 changes: 11 additions & 11 deletions cmd/metal-api/internal/issues/issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestFindIssues(t *testing.T) {
},
{
name: "no partition",
only: []IssueType{IssueTypeNoPartition},
only: []IssueType{TypeNoPartition},
machines: func() metal.Machines {
noPartitionMachine := machineTemplate("no-partition")
noPartitionMachine.PartitionID = ""
Expand Down Expand Up @@ -87,7 +87,7 @@ func TestFindIssues(t *testing.T) {
},
{
name: "liveliness dead",
only: []IssueType{IssueTypeLivelinessDead},
only: []IssueType{TypeLivelinessDead},
machines: func() metal.Machines {
return metal.Machines{
machineTemplate("dead"),
Expand Down Expand Up @@ -116,7 +116,7 @@ func TestFindIssues(t *testing.T) {
},
{
name: "liveliness unknown",
only: []IssueType{IssueTypeLivelinessUnknown},
only: []IssueType{TypeLivelinessUnknown},
machines: func() metal.Machines {
return metal.Machines{
machineTemplate("unknown"),
Expand Down Expand Up @@ -145,7 +145,7 @@ func TestFindIssues(t *testing.T) {
},
{
name: "liveliness not available",
only: []IssueType{IssueTypeLivelinessNotAvailable},
only: []IssueType{TypeLivelinessNotAvailable},
machines: func() metal.Machines {
return metal.Machines{
machineTemplate("n/a"),
Expand Down Expand Up @@ -174,7 +174,7 @@ func TestFindIssues(t *testing.T) {
},
{
name: "failed machine reclaim",
only: []IssueType{IssueTypeFailedMachineReclaim},
only: []IssueType{TypeFailedMachineReclaim},
machines: func() metal.Machines {
failedOld := machineTemplate("failed-old")

Expand Down Expand Up @@ -220,7 +220,7 @@ func TestFindIssues(t *testing.T) {
},
{
name: "crashloop",
only: []IssueType{IssueTypeCrashLoop},
only: []IssueType{TypeCrashLoop},
machines: func() metal.Machines {
return metal.Machines{
machineTemplate("good"),
Expand Down Expand Up @@ -282,7 +282,7 @@ func TestFindIssues(t *testing.T) {
// },
{
name: "bmc without mac",
only: []IssueType{IssueTypeBMCWithoutMAC},
only: []IssueType{TypeBMCWithoutMAC},
machines: func() metal.Machines {
noMac := machineTemplate("no-mac")
noMac.IPMI.MacAddress = ""
Expand Down Expand Up @@ -314,7 +314,7 @@ func TestFindIssues(t *testing.T) {
},
{
name: "bmc without ip",
only: []IssueType{IssueTypeBMCWithoutIP},
only: []IssueType{TypeBMCWithoutIP},
machines: func() metal.Machines {
noIP := machineTemplate("no-ip")
noIP.IPMI.Address = ""
Expand Down Expand Up @@ -378,7 +378,7 @@ func TestFindIssues(t *testing.T) {
// },
{
name: "asn shared",
only: []IssueType{IssueTypeASNUniqueness},
only: []IssueType{TypeASNUniqueness},
machines: func() metal.Machines {
shared1 := machineTemplate("shared1")
shared1.Allocation = &metal.MachineAllocation{
Expand Down Expand Up @@ -448,7 +448,7 @@ func TestFindIssues(t *testing.T) {
},
{
name: "non distinct bmc ip",
only: []IssueType{IssueTypeNonDistinctBMCIP},
only: []IssueType{TypeNonDistinctBMCIP},
machines: func() metal.Machines {
bmc1 := machineTemplate("bmc1")
bmc1.IPMI.Address = "127.0.0.1"
Expand Down Expand Up @@ -496,7 +496,7 @@ func TestFindIssues(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
ms := tt.machines()

got, err := FindIssues(&IssueConfig{
got, err := FindIssues(&Config{
Machines: ms,
EventContainers: tt.eventContainers(),
Only: tt.only,
Expand Down
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/issues/last-event-error.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

const (
IssueTypeLastEventError IssueType = "last-event-error"
TypeLastEventError IssueType = "last-event-error"
)

type (
Expand All @@ -23,14 +23,14 @@ func DefaultLastErrorThreshold() time.Duration {

func (i *IssueLastEventError) Spec() *spec {
return &spec{
Type: IssueTypeLastEventError,
Severity: IssueSeverityMinor,
Type: TypeLastEventError,
Severity: SeverityMinor,
Description: "the machine had an error during the provisioning lifecycle",
RefURL: "https://docs.metal-stack.io/stable/installation/troubleshoot/#last-event-error",
}
}

func (i *IssueLastEventError) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *IssueConfig) bool {
func (i *IssueLastEventError) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
if c.LastErrorThreshold == 0 {
return false
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/issues/liveliness-dead.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package issues
import "github.com/metal-stack/metal-api/cmd/metal-api/internal/metal"

const (
IssueTypeLivelinessDead IssueType = "liveliness-dead"
TypeLivelinessDead IssueType = "liveliness-dead"
)

type (
Expand All @@ -12,14 +12,14 @@ type (

func (i *IssueLivelinessDead) Spec() *spec {
return &spec{
Type: IssueTypeLivelinessDead,
Severity: IssueSeverityMajor,
Type: TypeLivelinessDead,
Severity: SeverityMajor,
Description: "the machine is not sending events anymore",
RefURL: "https://docs.metal-stack.io/stable/installation/troubleshoot/#liveliness-dead",
}
}

func (i *IssueLivelinessDead) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *IssueConfig) bool {
func (i *IssueLivelinessDead) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
return ec.Liveliness.Is(string(metal.MachineLivelinessDead))
}

Expand Down
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/issues/liveliness-not-available.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package issues
import "github.com/metal-stack/metal-api/cmd/metal-api/internal/metal"

const (
IssueTypeLivelinessNotAvailable IssueType = "liveliness-not-available"
TypeLivelinessNotAvailable IssueType = "liveliness-not-available"
)

type (
Expand All @@ -12,13 +12,13 @@ type (

func (i *IssueLivelinessNotAvailable) Spec() *spec {
return &spec{
Type: IssueTypeLivelinessNotAvailable,
Severity: IssueSeverityMinor,
Type: TypeLivelinessNotAvailable,
Severity: SeverityMinor,
Description: "the machine liveliness is not available",
}
}

func (i *IssueLivelinessNotAvailable) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *IssueConfig) bool {
func (i *IssueLivelinessNotAvailable) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
allowed := map[metal.MachineLiveliness]bool{
metal.MachineLivelinessAlive: true,
metal.MachineLivelinessDead: true,
Expand Down
Loading

0 comments on commit aca10db

Please sign in to comment.