Change severity levels for some checks
* If a check causes upgrade or node replacement to break, severity level is error, else warningimage-warning-sha256
parent
1add3af850
commit
f02cccbb98
|
@ -51,7 +51,7 @@ func (b *barePodCheck) Run(objects *kube.Objects) ([]checks.Diagnostic, error) {
|
||||||
if len(pod.ObjectMeta.OwnerReferences) == 0 {
|
if len(pod.ObjectMeta.OwnerReferences) == 0 {
|
||||||
d := checks.Diagnostic{
|
d := checks.Diagnostic{
|
||||||
Check: b.Name(),
|
Check: b.Name(),
|
||||||
Severity: checks.Error,
|
Severity: checks.Warning,
|
||||||
Message: "Avoid using bare pods in clusters",
|
Message: "Avoid using bare pods in clusters",
|
||||||
Kind: checks.Pod,
|
Kind: checks.Pod,
|
||||||
Object: &pod.ObjectMeta,
|
Object: &pod.ObjectMeta,
|
||||||
|
|
|
@ -66,7 +66,7 @@ func TestBarePodError(t *testing.T) {
|
||||||
objs: initPod(),
|
objs: initPod(),
|
||||||
expected: []checks.Diagnostic{
|
expected: []checks.Diagnostic{
|
||||||
{
|
{
|
||||||
Severity: "error",
|
Severity: "warning",
|
||||||
Check: "bare-pods",
|
Check: "bare-pods",
|
||||||
Kind: checks.Pod,
|
Kind: checks.Pod,
|
||||||
Message: "Avoid using bare pods in clusters",
|
Message: "Avoid using bare pods in clusters",
|
||||||
|
@ -80,7 +80,7 @@ func TestBarePodError(t *testing.T) {
|
||||||
objs: initMultiplePods(),
|
objs: initMultiplePods(),
|
||||||
expected: []checks.Diagnostic{
|
expected: []checks.Diagnostic{
|
||||||
{
|
{
|
||||||
Severity: "error",
|
Severity: "warning",
|
||||||
Check: "bare-pods",
|
Check: "bare-pods",
|
||||||
Kind: checks.Pod,
|
Kind: checks.Pod,
|
||||||
Message: "Avoid using bare pods in clusters",
|
Message: "Avoid using bare pods in clusters",
|
||||||
|
@ -88,7 +88,7 @@ func TestBarePodError(t *testing.T) {
|
||||||
Owners: nil,
|
Owners: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Severity: "error",
|
Severity: "warning",
|
||||||
Check: "bare-pods",
|
Check: "bare-pods",
|
||||||
Kind: checks.Pod,
|
Kind: checks.Pod,
|
||||||
Message: "Avoid using bare pods in clusters",
|
Message: "Avoid using bare pods in clusters",
|
||||||
|
|
|
@ -72,7 +72,7 @@ func (fq *fullyQualifiedImageCheck) checkImage(containers []corev1.Container, po
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d := checks.Diagnostic{
|
d := checks.Diagnostic{
|
||||||
Check: fq.Name(),
|
Check: fq.Name(),
|
||||||
Severity: checks.Error,
|
Severity: checks.Warning,
|
||||||
Message: fmt.Sprintf("Malformed image name for container '%s'", container.Name),
|
Message: fmt.Sprintf("Malformed image name for container '%s'", container.Name),
|
||||||
Kind: checks.Pod,
|
Kind: checks.Pod,
|
||||||
Object: &pod.ObjectMeta,
|
Object: &pod.ObjectMeta,
|
||||||
|
|
|
@ -148,7 +148,7 @@ func TestFullyQualifiedImageWarning(t *testing.T) {
|
||||||
|
|
||||||
func TestMalformedImageError(t *testing.T) {
|
func TestMalformedImageError(t *testing.T) {
|
||||||
const message = "Malformed image name for container 'bar'"
|
const message = "Malformed image name for container 'bar'"
|
||||||
const severity = checks.Error
|
const severity = checks.Warning
|
||||||
const name = "fully-qualified-image"
|
const name = "fully-qualified-image"
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
|
|
@ -56,7 +56,7 @@ func (h *hostPathCheck) Run(objects *kube.Objects) ([]checks.Diagnostic, error)
|
||||||
if volume.VolumeSource.HostPath != nil {
|
if volume.VolumeSource.HostPath != nil {
|
||||||
d := checks.Diagnostic{
|
d := checks.Diagnostic{
|
||||||
Check: h.Name(),
|
Check: h.Name(),
|
||||||
Severity: checks.Error,
|
Severity: checks.Warning,
|
||||||
Message: fmt.Sprintf("Avoid using hostpath for volume '%s'.", volume.Name),
|
Message: fmt.Sprintf("Avoid using hostpath for volume '%s'.", volume.Name),
|
||||||
Kind: checks.Pod,
|
Kind: checks.Pod,
|
||||||
Object: &pod.ObjectMeta,
|
Object: &pod.ObjectMeta,
|
||||||
|
|
|
@ -70,7 +70,7 @@ func TestHostpathVolumeError(t *testing.T) {
|
||||||
expected: []checks.Diagnostic{
|
expected: []checks.Diagnostic{
|
||||||
{
|
{
|
||||||
Check: "hostpath-volume",
|
Check: "hostpath-volume",
|
||||||
Severity: checks.Error,
|
Severity: checks.Warning,
|
||||||
Message: "Avoid using hostpath for volume 'bar'.",
|
Message: "Avoid using hostpath for volume 'bar'.",
|
||||||
Kind: checks.Pod,
|
Kind: checks.Pod,
|
||||||
Object: GetObjectMeta(),
|
Object: GetObjectMeta(),
|
||||||
|
|
|
@ -54,7 +54,7 @@ func (p *podSelectorCheck) Run(objects *kube.Objects) ([]checks.Diagnostic, erro
|
||||||
if _, ok := nodeSelectorMap[corev1.LabelHostname]; ok {
|
if _, ok := nodeSelectorMap[corev1.LabelHostname]; ok {
|
||||||
d := checks.Diagnostic{
|
d := checks.Diagnostic{
|
||||||
Check: p.Name(),
|
Check: p.Name(),
|
||||||
Severity: checks.Error,
|
Severity: checks.Warning,
|
||||||
Message: "Avoid node name label for node selector.",
|
Message: "Avoid node name label for node selector.",
|
||||||
Kind: checks.Pod,
|
Kind: checks.Pod,
|
||||||
Object: &pod.ObjectMeta,
|
Object: &pod.ObjectMeta,
|
||||||
|
|
|
@ -56,7 +56,7 @@ func TestNodeNameError(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "node name used in node selector",
|
name: "node name used in node selector",
|
||||||
objs: invalidPod(),
|
objs: invalidPod(),
|
||||||
expected: errors(invalidPod(), podSelectorCheck.Name()),
|
expected: warnings(invalidPod(), podSelectorCheck.Name()),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,12 +89,12 @@ func invalidPod() *kube.Objects {
|
||||||
return objs
|
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]
|
pod := objs.Pods.Items[0]
|
||||||
diagnostics := []checks.Diagnostic{
|
diagnostics := []checks.Diagnostic{
|
||||||
{
|
{
|
||||||
Check: name,
|
Check: name,
|
||||||
Severity: checks.Error,
|
Severity: checks.Warning,
|
||||||
Message: "Avoid node name label for node selector.",
|
Message: "Avoid node name label for node selector.",
|
||||||
Kind: checks.Pod,
|
Kind: checks.Pod,
|
||||||
Object: &pod.ObjectMeta,
|
Object: &pod.ObjectMeta,
|
||||||
|
|
Loading…
Reference in New Issue