fix: flaky localdns exporter e2e validation#8454
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes flakiness in the LocalDNS exporter E2E validation script by avoiding pipefail-related false negatives when grepping large metrics payloads.
Changes:
- Cache
ss -tlnoutput and reuse it for port checks and listen address detection. - Replace
echo "$VAR" | grep ...patterns with here-strings (grep ... <<< "$VAR") to avoid SIGPIPE/pipefailfailures. - Minor refactors to avoid pipelines (e.g.,
head,grep | sed) when inspecting$METRICS.
|
The here-string conversion is a sound fix for the pipefail/SIGPIPE rationale in the inline comment — Two small suggestions:
|
|
stop re-review |
a01b4a8 to
61f3245
Compare
61f3245 to
563b6ee
Compare
Summary
echo "$VAR" | grep/awk/sedpipes withgrep/awk/sed <<< "$VAR"here-strings throughout the exporter validation scriptss -tlnoutput once into a variable (SS_LISTEN_OUTPUT) instead of callingssmultiple timesecho "$METRICS" | grep ... | head -10withawkone-liners that exit after 10 matchesWhy: With
set -euo pipefailenabled,echo "$LARGE_VAR" | grep -q ...can fail spuriously. Ifgrepfinds its match and exits early,echoreceives SIGPIPE and returns a non-zero exit status, whichpipefailtreats as a command failure. Here-strings (<<<) avoid the pipe entirely — the shell passes the variable directly to the command's stdin via a temporary file, so there is no writer process to receive SIGPIPE.This was the root cause of intermittent test failures in the exporter e2e where metrics were present but the validation still failed.