Skip to content

Commit 710468f

Browse files
authored
Merge pull request #69 from osg-htc/fix/fasterdata-pacing-dryrun
fix(fasterdata): respect --dry-run for packet pacing; audit checks actual qdisc (v1.3.6)
2 parents 5d7bcb5 + 8235f20 commit 710468f

File tree

3 files changed

+43
-16
lines changed

3 files changed

+43
-16
lines changed

docs/perfsonar/tools_scripts/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Fixed
44

55
- **Critical JSON state save corruption fix**: Fixed invalid JSON generation in `--save-state` that caused `--restore-state` to fail
6+
- **Fix (1.3.6)**: Respect `--dry-run` in packet pacing application and ensure audit logic checks actual qdisc state; prevent `--mode apply --dry-run` from changing system qdisc or sysctl state.
67
- Properly quote non-numeric ring buffer values (e.g., `Mini:`, `push`, `n/a`)
78
- Properly quote non-numeric `nm_mtu` values (e.g., `auto`)
89
- Sanitize ring buffer values to ensure numeric-only or properly quoted strings

docs/perfsonar/tools_scripts/fasterdata-tuning.sh

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
# fasterdata-tuning.sh
33
# --------------------
4-
# Version: 1.3.5
4+
# Version: 1.3.6
55
# Author: Shawn McKee, University of Michigan
66
# Acknowledgements: Supported by IRIS-HEP and OSG-LHC
77
#
@@ -1271,36 +1271,39 @@ iface_apply() {
12711271
iface_packet_pacing_audit() {
12721272
local iface="$1"
12731273
local pacing_rate="$2"
1274-
1274+
12751275
# Only audit packet pacing for DTN nodes
12761276
if [[ "$TARGET_TYPE" != "dtn" ]]; then
12771277
return 0
12781278
fi
1279-
1279+
12801280
# Check current qdisc - fq enables Linux TCP pacing; tbf indicates explicit rate cap
12811281
local current_qdisc
1282-
current_qdisc=$(tc qdisc show dev "$iface" 2>/dev/null | head -n1)
1283-
1284-
# If we're not applying pacing, just report current state
1285-
if [[ $APPLY_PACKET_PACING -eq 0 ]]; then
1286-
# Accept either fq (TCP pacing) or tbf (explicit cap) as "pacing applied"
1287-
if [[ "$current_qdisc" == *" fq"* || "$current_qdisc" == fq* || "$current_qdisc" == *" tbf"* ]]; then
1288-
return 0
1289-
fi
1290-
return 1
1282+
current_qdisc=$(tc qdisc show dev "$iface" 2>/dev/null | head -n1 || echo "")
1283+
1284+
# Accept either fq (TCP pacing) or tbf (explicit cap) as "pacing applied"
1285+
if [[ "$current_qdisc" == *" fq"* || "$current_qdisc" == fq* || "$current_qdisc" == *" tbf"* ]]; then
1286+
return 0
12911287
fi
1292-
1293-
return 0
1288+
1289+
# Not found
1290+
return 1
12941291
}
12951292

12961293
iface_apply_packet_pacing() {
12971294
local iface="$1"
12981295
local pacing_rate="$2"
1299-
1296+
1297+
# Respect DRY_RUN and target type / feature flag
1298+
if [[ $DRY_RUN -eq 1 ]]; then
1299+
log_info "Dry-run: would apply packet pacing to $iface (skipped)"
1300+
return
1301+
fi
1302+
13001303
if [[ "$TARGET_TYPE" != "dtn" ]] || [[ $APPLY_PACKET_PACING -eq 0 ]]; then
13011304
return
13021305
fi
1303-
1306+
13041307
# Decide on tbf vs fq: use tbf if explicitly requested or a cap rate is provided; otherwise fq
13051308
if [[ $USE_TBF_CAP -eq 1 || -n "$TBF_CAP_RATE" ]]; then
13061309
# Determine effective rate: explicit cap wins; else compute fraction of iface speed

tests/test-fasterdata-dryrun.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
# Simple regression test: verify --mode apply --dry-run does not actually apply packet pacing
3+
set -euo pipefail
4+
SCRIPT="$(pwd)/docs/perfsonar/tools_scripts/fasterdata-tuning.sh"
5+
if [[ ! -x "$SCRIPT" ]]; then
6+
echo "Script not found or not executable: $SCRIPT" >&2
7+
exit 1
8+
fi
9+
# Run dry-run apply (may require sudo for access to some commands); expect messages indicating dry-run
10+
OUT=$(sudo "$SCRIPT" --mode apply --target dtn --apply-packet-pacing --dry-run --yes 2>&1 || true)
11+
# Check for dry-run markers
12+
if ! echo "$OUT" | grep -q "Dry-run: would apply packet pacing"; then
13+
echo "FAIL: dry-run did not report packet pacing skip" >&2
14+
echo "Output was:\n$OUT" >&2
15+
exit 2
16+
fi
17+
# Ensure summary does not claim pacing was enabled
18+
if echo "$OUT" | grep -q "Packet pacing: ENABLED"; then
19+
echo "FAIL: dry-run unexpectedly shows Packet pacing ENABLED" >&2
20+
exit 3
21+
fi
22+
# Basic success
23+
echo "PASS: dry-run packet pacing behaved as expected"

0 commit comments

Comments
 (0)