Skip to content

Commit 3ad8fc5

Browse files
craig[bot]DarrylWong
andcommitted
Merge #141933
141933: roachtest: fix iptable dropped packets check r=golgeek,srosenberg a=DarrylWong network/authentication has a regression check to make sure the iptables rule is correctly set up and drops at least one packet. This check previously assumed that no other rules would be found besides the one added in the test and hardcoded the string parsing. Recently, new rules were added for node_exporter, breaking this assumption. This change now fixes the check to filter for only rules on the SQL port. Fixes: #141805 Release note: none Co-authored-by: DarrylWong <[email protected]>
2 parents 4215a94 + a60105b commit 3ad8fc5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/cmd/roachtest/tests/network.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,17 +442,19 @@ func registerNetwork(r registry.Registry) {
442442
}
443443

444444
// iptablesPacketsDropped returns the number of packets dropped to a given node due to an iptables rule.
445+
// TODO(darrylwong): this is mostly just a validation check to make sure we set up the rules correctly.
446+
// We should remove this in favor for the failure injection library which has it's own validation.
445447
func iptablesPacketsDropped(
446448
ctx context.Context, l *logger.Logger, c cluster.Cluster, node option.NodeListOption,
447449
) (int, error) {
448-
res, err := c.RunWithDetailsSingleNode(ctx, l, option.WithNodes(node), "sudo iptables -L -v -n")
450+
// Filter for only rules on the SQL port as roachprod adds firewall rules for node_exporter.
451+
res, err := c.RunWithDetailsSingleNode(ctx, l, option.WithNodes(node), fmt.Sprintf("sudo iptables -L -x -v -n | grep {pgport%s}", node))
449452
if err != nil {
450453
return 0, err
451454
}
452455
rows := strings.Split(res.Stdout, "\n")
453-
// iptables -L outputs rows in the order of: chain, fields, and then values.
454-
// We care about the values so only look at row 2.
455-
values := strings.Fields(rows[2])
456+
// There will be an input and output rule, either works.
457+
values := strings.Fields(rows[0])
456458
if len(values) == 0 {
457459
return 0, errors.Errorf("no configured iptables rules found:\n%s", res.Stdout)
458460
}

0 commit comments

Comments
 (0)