-
Notifications
You must be signed in to change notification settings - Fork 28
fix(sdk): warn on first explicit-relay retry #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package sdk | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "context" | ||
| "encoding/json" | ||
| "errors" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/rs/zerolog" | ||
| "github.com/rs/zerolog/log" | ||
|
|
||
| "github.com/gosuda/portal-tunnel/v2/types" | ||
| ) | ||
|
|
||
| func TestWaitRetryLogsFirstFailureAtWarn(t *testing.T) { | ||
| var buf bytes.Buffer | ||
| prev := log.Logger | ||
| log.Logger = zerolog.New(&buf) | ||
| t.Cleanup(func() { log.Logger = prev }) | ||
|
|
||
| l := &listener{ | ||
| identity: types.Identity{Address: "0xabc"}, | ||
| retryWait: time.Millisecond, | ||
| } | ||
| if !l.waitRetry(context.Background(), "lease registration", errors.New("boom"), 1, 0) { | ||
| t.Fatal("waitRetry returned false") | ||
| } | ||
|
|
||
| var obj map[string]any | ||
| if err := json.Unmarshal(buf.Bytes(), &obj); err != nil { | ||
| t.Fatalf("decode log json: %v\nraw: %s", err, buf.String()) | ||
| } | ||
| if got, want := obj["level"], "warn"; got != want { | ||
| t.Fatalf("level = %v, want %q", got, want) | ||
| } | ||
| if got, want := obj["message"], "operation failed; retrying"; got != want { | ||
| t.Fatalf("message = %v, want %q", got, want) | ||
| } | ||
| if got, want := obj["operation"], "lease registration"; got != want { | ||
| t.Fatalf("operation = %v, want %q", got, want) | ||
| } | ||
|
Comment on lines
+31
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: printf '%s\n' '--- repository conventions ---'
find /tmp/coderabbit-repo-knowledge/gosuda-portal-tunnel-03e13e8b -maxdepth 2 -type f -name '*.md' -print | sort | while read -r f; do
printf '\n--- %s ---\n' "$f"
head -80 "$f"
done
printf '%s\n' '--- target test ---'
cat -n sdk/listener_retry_test.go
printf '%s\n' '--- related retry and logging definitions ---'
rg -n -C 8 'waitRetry|operation failed; retrying|lease registration|Err\(' sdk --glob '*.go'Repository: gosuda/portal-tunnel Length of output: 38786 🏁 Script executed: printf '%s\n' '--- zerolog dependency version ---'
grep -n 'github.com/rs/zerolog' go.mod go.sum
printf '%s\n' '--- cached zerolog Err implementation and error field contract ---'
modcache="$(go env GOMODCACHE 2>/dev/null || true)"
if [ -n "$modcache" ]; then
find "$modcache" -path '*github.com/rs/zerolog*' -type f \( -name '*.go' -o -name 'README.md' \) -print 2>/dev/null |
head -20
rg -n -C 5 'func \(.*\) Err|ErrorFieldName|errorKey|ErrorField' "$modcache"/github.com/rs/zerolog* 2>/dev/null | head -120
else
echo 'Go module cache unavailable'
fiRepository: gosuda/portal-tunnel Length of output: 14082 Assert the serialized error. The 🤖 Prompt for AI Agents |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: gosuda/portal-tunnel
Length of output: 158
🏁 Script executed:
Repository: gosuda/portal-tunnel
Length of output: 3358
🏁 Script executed:
Repository: gosuda/portal-tunnel
Length of output: 50377
🏁 Script executed:
Repository: gosuda/portal-tunnel
Length of output: 7674
🏁 Script executed:
Repository: gosuda/portal-tunnel
Length of output: 41199
Limit this warning to explicit routes
Exposure.reconcileRelayListenersgives automatic discovery routesRetryCount: 10, andlistener.runsends their first registration failure towaitRetry. SincewaitRetrychecks onlyretries == 1, it also emitsWarnfor automatic routes. Guard this warning withl.route.Explicit().🤖 Prompt for AI Agents