Skip to content

Commit

Permalink
test: Show all matched flows on failure
Browse files Browse the repository at this point in the history
Show flows that were matched also when flow validation fails.

Since enabling ephemeral port tracking the flow output does not show
which matches were made when flow validation fails. Restore that
capability by combining the validation results of all match fails,
which are only used if the validation fails. On successful validation
only the flows contributing to the successful match are highlighted.

Signed-off-by: Jarno Rajahalme <[email protected]>
  • Loading branch information
jrajahalme committed Jun 14, 2021
1 parent ae5a0c4 commit df1bbc1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions connectivity/check/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,13 +543,17 @@ retry:
a.flows[pod] = flows

res := FlowRequirementResults{FirstMatch: -1, LastMatch: -1}
resFail := FlowRequirementResults{FirstMatch: -1, LastMatch: -1}
for i, req := range reqs {
offset := 0
var r FlowRequirementResults
for offset < len(flows) {
r = a.matchFlowRequirements(ctx, flows, offset, pod, &req)
// Check if fully matched or no match for the first flow
if !r.NeedMoreFlows || r.FirstMatch == -1 {
if r.Failures > 0 {
resFail.Merge(&r)
}
// Check if successfully fully matched or no match for the first flow
if (!r.NeedMoreFlows && r.Failures == 0) || r.FirstMatch == -1 {
break
}
// Try if some other flow instance would find both first and last required flows
Expand All @@ -563,7 +567,13 @@ retry:
}
}
// Merge results
res.Merge(&r)
if r.Failures > 0 {
// on Failure merge all tries to see what flows matched
res.Merge(&resFail)
} else {
// on Success only merge the successfully matched filters
res.Merge(&r)
}
a.Debugf("Merged flow validation results #%d: %v", i, res)
}
a.flowResults[pod] = res
Expand Down

0 comments on commit df1bbc1

Please sign in to comment.