Skip to content

Commit

Permalink
append the ingress blocked warning to []ConnlistError (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
shireenf-ibm committed Jul 27, 2023
1 parent 4f6ac1f commit e2a9220
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions pkg/netpol/connlist/connlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,5 +499,6 @@ func (ca *ConnlistAnalyzer) warnBlockedIngress(peerStr string, ingressObjs map[s
warningMsg += " specified workload " + peerStr + " as a backend, but network policies are blocking " +
"ingress connections from an arbitrary in-cluster source to this workload." +
"Connectivity map will not include a possibly allowed connection between the ingress controller and this workload."
ca.errors = append(ca.errors, newIngressAnalyzerConnsBlockedWarning(errors.New(warningMsg)))
ca.logger.Warnf(warningMsg)
}
24 changes: 19 additions & 5 deletions pkg/netpol/connlist/connlist_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package connlist

// connlistGeneratingError - ConnlistError that may arrise while producing the connections list
type connlistGeneratingError struct {
err error
err error
fatal bool
severe bool
}

type resultFormattingError struct {
Expand All @@ -13,6 +15,10 @@ type resourceEvaluationError struct {
origErr error
}

type ingressAnalyzerConnsBlockedWarning struct {
origErr error
}

func (e *resultFormattingError) Error() string {
return e.origErr.Error()
}
Expand All @@ -21,16 +27,20 @@ func (e *resourceEvaluationError) Error() string {
return e.origErr.Error()
}

func (e *ingressAnalyzerConnsBlockedWarning) Error() string {
return e.origErr.Error()
}

// IsFatal returns whether the error is considered fatal (no further processing is possible)
// connlistGeneratingError errors are always fatal
func (e *connlistGeneratingError) IsFatal() bool {
return true
return e.fatal
}

// IsSevere returns whether the error is considered severe
// (further processing is possible, but results may not be useable)
func (e *connlistGeneratingError) IsSevere() bool {
return false
return e.severe
}

func (e *connlistGeneratingError) Location() string {
Expand All @@ -44,9 +54,13 @@ func (e *connlistGeneratingError) Error() error {
// constructors

func newResultFormattingError(err error) *connlistGeneratingError {
return &connlistGeneratingError{&resultFormattingError{err}}
return &connlistGeneratingError{err: &resultFormattingError{err}, fatal: true, severe: false}
}

func newResourceEvaluationError(err error) *connlistGeneratingError {
return &connlistGeneratingError{&resourceEvaluationError{err}}
return &connlistGeneratingError{err: &resourceEvaluationError{err}, fatal: true, severe: false}
}

func newIngressAnalyzerConnsBlockedWarning(err error) *connlistGeneratingError {
return &connlistGeneratingError{err: &ingressAnalyzerConnsBlockedWarning{err}, fatal: false, severe: false}
}

0 comments on commit e2a9220

Please sign in to comment.