sip/pkg/vbmh/errors.go
Drew Walters 2a5dacae95 Add infra service type validation to SIP CR
Each infrastructure service in the SIPCluster custom resource should be
a descendant of a key that is a valid service type; however, errors in
the name of an infrastructure service type are only logged as info;
processing of the SIP CR continues even when an infrastructure service
type is invalid.

This change introduces up-front validation by adding a new field to the
infrastructure service config, serviceType. When a serviceType is
invalid, SIP will not begin processing the CR because the Kubernetes API
server will reject the SIPCluster resource. The key under which an
infrastructure service resides is now treated as an arbitrary value.

Signed-off-by: Drew Walters <andrew.walters@att.com>
Change-Id: I082dac7eae6893decfca12227caf0ea50bc1fa30
2021-02-01 21:13:48 +00:00

58 lines
1.6 KiB
Go

package vbmh
import (
"fmt"
metal3 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
airshipv1 "sipcluster/pkg/api/v1"
)
// ErrorConstraintNotFound is returned when wrong AuthType is provided
type ErrorConstraintNotFound struct {
}
func (e ErrorConstraintNotFound) Error() string {
return "Invalid or Not found Schedulign Constraint"
}
type ErrorUnableToFullySchedule struct {
TargetNode airshipv1.VMRoles
TargetFlavor string
}
func (e ErrorUnableToFullySchedule) Error() string {
return fmt.Sprintf("Unable to complete a schedule with a target of %v nodes, with a flavor of %v",
e.TargetNode, e.TargetFlavor)
}
type ErrorHostIPNotFound struct {
HostName string
ServiceType airshipv1.InfraService
IPInterface string
Message string
}
func (e ErrorHostIPNotFound) Error() string {
return fmt.Sprintf("Unable to identify the vBMH Host %v IP address on interface %v required by "+
"Infrastructure Service %v %s", e.HostName, e.IPInterface, e.ServiceType, e.Message)
}
// ErrorUknownSpreadTopology is returned when wrong AuthType is provided
type ErrorUknownSpreadTopology struct {
Topology airshipv1.SpreadTopology
}
func (e ErrorUknownSpreadTopology) Error() string {
return fmt.Sprintf("Uknown spread topology '%s'", e.Topology)
}
// ErrorNetworkDataNotFound is returned when NetworkData metadata is missing from BMH
type ErrorNetworkDataNotFound struct {
BMH metal3.BareMetalHost
}
func (e ErrorNetworkDataNotFound) Error() string {
return fmt.Sprintf("vBMH Host %v does not define NetworkData, but is required for scheduling.", e.BMH)
}