Skip to content

Commit

Permalink
Merge pull request #11968 from juanvallejo/jvallejo/update-missing-pr…
Browse files Browse the repository at this point in the history
…obe-severity-to-info

Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed Nov 19, 2016
2 parents 271fff8 + 2ce9162 commit 3b2bbe5
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 32 deletions.
2 changes: 1 addition & 1 deletion pkg/api/graph/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/kubegraph/analysis/podspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
71 changes: 42 additions & 29 deletions pkg/cmd/cli/describe/projectstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/graph/analysis/dc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down

0 comments on commit 3b2bbe5

Please sign in to comment.