diff --git a/pkg/api/graph/interfaces.go b/pkg/api/graph/interfaces.go index d59c00269bf3..a70dbbaf0239 100644 --- a/pkg/api/graph/interfaces.go +++ b/pkg/api/graph/interfaces.go @@ -28,7 +28,7 @@ type Severity string const ( // InfoSeverity is interesting - // TODO: Consider what to do with this once we revisit the graph api - currently not used. + // Currently used in missing probe markers InfoSeverity Severity = "info" // WarningSeverity is probably wrong, but we aren't certain WarningSeverity Severity = "warning" diff --git a/pkg/api/kubegraph/analysis/podspec.go b/pkg/api/kubegraph/analysis/podspec.go index 86ceae695199..29b433846f3c 100644 --- a/pkg/api/kubegraph/analysis/podspec.go +++ b/pkg/api/kubegraph/analysis/podspec.go @@ -100,7 +100,7 @@ func FindMissingLivenessProbes(g osgraph.Graph, f osgraph.Namer, setProbeCommand Node: podSpecNode, RelatedNodes: []graph.Node{topLevelNode}, - Severity: osgraph.WarningSeverity, + Severity: osgraph.InfoSeverity, Key: MissingLivenessProbeWarning, Message: fmt.Sprintf("%s has no liveness probe to verify pods are still running.", topLevelString), diff --git a/pkg/cmd/cli/describe/projectstatus.go b/pkg/cmd/cli/describe/projectstatus.go index 8de152d0d87c..3e4970d26ebe 100644 --- a/pkg/cmd/cli/describe/projectstatus.go +++ b/pkg/cmd/cli/describe/projectstatus.go @@ -282,44 +282,31 @@ func (d *ProjectStatusDescriber) Describe(namespace, name string) (string, error errorSuggestions := 0 if len(errorMarkers) > 0 { fmt.Fprintln(out, "Errors:") - for _, marker := range errorMarkers { - fmt.Fprintln(out, indent+"* "+marker.Message) - if len(marker.Suggestion) > 0 { - errorSuggestions++ - if d.Suggest { - switch s := marker.Suggestion.String(); { - case strings.Contains(s, "\n"): - fmt.Fprintln(out) - for _, line := range strings.Split(s, "\n") { - fmt.Fprintln(out, indent+" "+line) - } - case len(s) > 0: - fmt.Fprintln(out, indent+" try: "+s) - } - } - } - } + errorSuggestions += printMarkerSuggestions(errorMarkers, d.Suggest, out, indent) } warningMarkers := allMarkers.BySeverity(osgraph.WarningSeverity) if len(warningMarkers) > 0 { if d.Suggest { + // add linebreak between Errors list and Warnings list + if len(errorMarkers) > 0 { + fmt.Fprintln(out) + } fmt.Fprintln(out, "Warnings:") } - for _, marker := range warningMarkers { - if d.Suggest { - fmt.Fprintln(out, indent+"* "+marker.Message) - switch s := marker.Suggestion.String(); { - case strings.Contains(s, "\n"): - fmt.Fprintln(out) - for _, line := range strings.Split(s, "\n") { - fmt.Fprintln(out, indent+" "+line) - } - case len(s) > 0: - fmt.Fprintln(out, indent+" try: "+s) - } + printMarkerSuggestions(warningMarkers, d.Suggest, out, indent) + } + + infoMarkers := allMarkers.BySeverity(osgraph.InfoSeverity) + if len(infoMarkers) > 0 { + if d.Suggest { + // add linebreak between Warnings list and Info List + if len(warningMarkers) > 0 || len(errorMarkers) > 0 { + fmt.Fprintln(out) } + fmt.Fprintln(out, "Info:") } + printMarkerSuggestions(infoMarkers, d.Suggest, out, indent) } // We print errors by default and warnings if -v is used. If we get none, @@ -362,6 +349,32 @@ func (d *ProjectStatusDescriber) Describe(namespace, name string) (string, error }) } +// printMarkerSuggestions prints a formatted list of marker suggestions +// and returns the amount of suggestions printed +func printMarkerSuggestions(markers []osgraph.Marker, suggest bool, out *tabwriter.Writer, indent string) int { + suggestionAmount := 0 + for _, marker := range markers { + if len(marker.Suggestion) > 0 { + suggestionAmount++ + } + if len(marker.Suggestion) > 0 || len(marker.Message) > 0 { + if suggest { + fmt.Fprintln(out, indent+"* "+marker.Message) + switch s := marker.Suggestion.String(); { + case strings.Contains(s, "\n"): + fmt.Fprintln(out) + for _, line := range strings.Split(s, "\n") { + fmt.Fprintln(out, indent+" "+line) + } + case len(s) > 0: + fmt.Fprintln(out, indent+" try: "+s) + } + } + } + } + return suggestionAmount +} + func createForbiddenMarkers(forbiddenResources sets.String) []osgraph.Marker { markers := []osgraph.Marker{} for forbiddenResource := range forbiddenResources { diff --git a/pkg/deploy/graph/analysis/dc.go b/pkg/deploy/graph/analysis/dc.go index d28454d366de..5e81fb8d2e39 100644 --- a/pkg/deploy/graph/analysis/dc.go +++ b/pkg/deploy/graph/analysis/dc.go @@ -118,7 +118,7 @@ Node: // All of the containers in the deployment config lack a readiness probe markers = append(markers, osgraph.Marker{ Node: uncastDcNode, - Severity: osgraph.WarningSeverity, + Severity: osgraph.InfoSeverity, Key: MissingReadinessProbeWarning, Message: fmt.Sprintf("%s has no readiness probe to verify pods are ready to accept traffic or ensure deployment is successful.", f.ResourceName(dcNode)),