Change severity levels for some checks

* If a check causes upgrade or node replacement to break, severity level is error, else warning
image-warning-sha256
Varsha Varadarajan 2019-09-29 12:13:49 -07:00
parent 1add3af850
commit f02cccbb98
8 changed files with 12 additions and 12 deletions

View File

@ -51,7 +51,7 @@ func (b *barePodCheck) Run(objects *kube.Objects) ([]checks.Diagnostic, error) {
if len(pod.ObjectMeta.OwnerReferences) == 0 {
d := checks.Diagnostic{
Check: b.Name(),
Severity: checks.Error,
Severity: checks.Warning,
Message: "Avoid using bare pods in clusters",
Kind: checks.Pod,
Object: &pod.ObjectMeta,

View File

@ -66,7 +66,7 @@ func TestBarePodError(t *testing.T) {
objs: initPod(),
expected: []checks.Diagnostic{
{
Severity: "error",
Severity: "warning",
Check: "bare-pods",
Kind: checks.Pod,
Message: "Avoid using bare pods in clusters",
@ -80,7 +80,7 @@ func TestBarePodError(t *testing.T) {
objs: initMultiplePods(),
expected: []checks.Diagnostic{
{
Severity: "error",
Severity: "warning",
Check: "bare-pods",
Kind: checks.Pod,
Message: "Avoid using bare pods in clusters",
@ -88,7 +88,7 @@ func TestBarePodError(t *testing.T) {
Owners: nil,
},
{
Severity: "error",
Severity: "warning",
Check: "bare-pods",
Kind: checks.Pod,
Message: "Avoid using bare pods in clusters",

View File

@ -72,7 +72,7 @@ func (fq *fullyQualifiedImageCheck) checkImage(containers []corev1.Container, po
if err != nil {
d := checks.Diagnostic{
Check: fq.Name(),
Severity: checks.Error,
Severity: checks.Warning,
Message: fmt.Sprintf("Malformed image name for container '%s'", container.Name),
Kind: checks.Pod,
Object: &pod.ObjectMeta,

View File

@ -148,7 +148,7 @@ func TestFullyQualifiedImageWarning(t *testing.T) {
func TestMalformedImageError(t *testing.T) {
const message = "Malformed image name for container 'bar'"
const severity = checks.Error
const severity = checks.Warning
const name = "fully-qualified-image"
tests := []struct {

View File

@ -56,7 +56,7 @@ func (h *hostPathCheck) Run(objects *kube.Objects) ([]checks.Diagnostic, error)
if volume.VolumeSource.HostPath != nil {
d := checks.Diagnostic{
Check: h.Name(),
Severity: checks.Error,
Severity: checks.Warning,
Message: fmt.Sprintf("Avoid using hostpath for volume '%s'.", volume.Name),
Kind: checks.Pod,
Object: &pod.ObjectMeta,

View File

@ -70,7 +70,7 @@ func TestHostpathVolumeError(t *testing.T) {
expected: []checks.Diagnostic{
{
Check: "hostpath-volume",
Severity: checks.Error,
Severity: checks.Warning,
Message: "Avoid using hostpath for volume 'bar'.",
Kind: checks.Pod,
Object: GetObjectMeta(),

View File

@ -54,7 +54,7 @@ func (p *podSelectorCheck) Run(objects *kube.Objects) ([]checks.Diagnostic, erro
if _, ok := nodeSelectorMap[corev1.LabelHostname]; ok {
d := checks.Diagnostic{
Check: p.Name(),
Severity: checks.Error,
Severity: checks.Warning,
Message: "Avoid node name label for node selector.",
Kind: checks.Pod,
Object: &pod.ObjectMeta,

View File

@ -56,7 +56,7 @@ func TestNodeNameError(t *testing.T) {
{
name: "node name used in node selector",
objs: invalidPod(),
expected: errors(invalidPod(), podSelectorCheck.Name()),
expected: warnings(invalidPod(), podSelectorCheck.Name()),
},
}
@ -89,12 +89,12 @@ func invalidPod() *kube.Objects {
return objs
}
func errors(objs *kube.Objects, name string) []checks.Diagnostic {
func warnings(objs *kube.Objects, name string) []checks.Diagnostic {
pod := objs.Pods.Items[0]
diagnostics := []checks.Diagnostic{
{
Check: name,
Severity: checks.Error,
Severity: checks.Warning,
Message: "Avoid node name label for node selector.",
Kind: checks.Pod,
Object: &pod.ObjectMeta,