Skip to content

feat: native gRPC multi-backend failover (internal CI) - #2

Open
songzhendong wants to merge 5 commits into
masterfrom
feature/python-multi-backend
Open

feat: native gRPC multi-backend failover (internal CI)#2
songzhendong wants to merge 5 commits into
masterfrom
feature/python-multi-backend

Conversation

@songzhendong

Copy link
Copy Markdown
Owner

Summary

  • Add shared gRPC target builder for comma-separated SW_AGENT_COLLECTOR_BACKEND_SERVICES (single host:port, multi IPv4/IPv6 to ipv4:/ipv6: + pick_first).
  • Wire sync/aio reporters to one long-lived channel; auth failures throttle-log only (no backend rotate); disable HTTP proxy; omit keepalive options.
  • Unit tests for parse/target/auth handling; Configuration.md regenerated.

Test plan

  • Fork CI green
  • Unit: python -m unittest tests.unit.test_grpc_channel
  • Manual: point agent at ip1:11800,ip2:11800, stop active OAP, confirm failover

Internal fork CI only — not for apache upstream visibility.

@songzhendong
songzhendong force-pushed the feature/python-multi-backend branch 2 times, most recently from 2220f37 to a662eb9 Compare August 25, 2026 02:57
One channel for the process lifetime with C-core pick_first over
comma-separated collector addresses (Node native failover analogue).
Single address stays plain host:port; multi uses ipv4:/ipv6: (mixed
families via IPv4-mapped). Multi hostnames expand once at channel build.
pick_first shuffleAddressList is on; target / default_authority stay in
config order.

Channel options: HTTP proxy off, no keepalive, reconnect backoff capped
at 30s, service_config retries only reportInstanceProperties. Skip
reports until READY. Unary and sync streaming RPCs use a deadline (10s
floor, always > queue window); aio client-streaming collect omits
timeout because generators await empty queues. Failed send batches are
counted as drops. Instance properties errors do not block keepAlive.
Replacing a protocol closes the previous channel (sync close; aio await
aclose on the agent loop). Timed shutdown flush so atexit cannot hang.

Includes unit coverage and a multi-OAP gRPC failover E2E case.
@songzhendong
songzhendong force-pushed the feature/python-multi-backend branch 2 times, most recently from d9105a4 to d6d11de Compare August 29, 2026 14:51
…own, RPC margin)

Skip sw_grpc instrumentation for agent collector channels via thread-local
scope; move throttled reporter logs off grpc_channel so GRPC_ENABLE_FORK_SUPPORT
is set before import grpc; cancel only background tasks on async shutdown;
widen sync RPC deadline vs queue batch window.
Run async cleanup on the asyncio.run root after _finished is set so
protocol aclose() completes before Runner teardown. Preserve the first
Queue.get attempt when SW_AGENT_QUEUE_TIMEOUT=0. Add regression tests.
Wait on both the shutdown event and background tasks so failures like
__command_dispatch() are retrieved and logged instead of being ignored.
Retrieve outcomes from already-done tasks during shutdown cancellation.
… failures

Supervisor treats early success/cancel as errors; cleanup only logs real
exceptions and skips already-handled outcomes so clean shutdown stays silent.
Assign the outcome marker directly to satisfy flake8 B010.
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.

1 participant