Skip to content

fix: flaky localdns exporter e2e validation#8454

Open
jingwenw15 wants to merge 1 commit intomainfrom
jingwenwu/localdns-exporter-e2e-fix
Open

fix: flaky localdns exporter e2e validation#8454
jingwenw15 wants to merge 1 commit intomainfrom
jingwenwu/localdns-exporter-e2e-fix

Conversation

@jingwenw15
Copy link
Copy Markdown
Member

@jingwenw15 jingwenw15 commented May 5, 2026

Summary

  • Replace echo "$VAR" | grep/awk/sed pipes with grep/awk/sed <<< "$VAR" here-strings throughout the exporter validation script
  • Capture ss -tln output once into a variable (SS_LISTEN_OUTPUT) instead of calling ss multiple times
  • Replace echo "$METRICS" | grep ... | head -10 with awk one-liners that exit after 10 matches

Why: With set -euo pipefail enabled, echo "$LARGE_VAR" | grep -q ... can fail spuriously. If grep finds its match and exits early, echo receives SIGPIPE and returns a non-zero exit status, which pipefail treats 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.

Copilot AI review requested due to automatic review settings May 5, 2026 17:44
@jingwenw15 jingwenw15 changed the title Fix flaky localdns exporter e2e validation Fix: flaky localdns exporter e2e validation May 5, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 -tln output and reuse it for port checks and listen address detection.
  • Replace echo "$VAR" | grep ... patterns with here-strings (grep ... <<< "$VAR") to avoid SIGPIPE/pipefail failures.
  • Minor refactors to avoid pipelines (e.g., head, grep | sed) when inspecting $METRICS.

Comment thread e2e/localdns/validate-localdns-exporter-metrics.sh
@jingwenw15 jingwenw15 changed the title Fix: flaky localdns exporter e2e validation fix: flaky localdns exporter e2e validation May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants