Repository navigation
feat(aibridge/x/proxy): integrate key-pool failover - #30400
Conversation
91a8821 to
d6b4039
Compare
51b2a5a to
130b4d6
Compare
d6b4039 to
96696d2
Compare
96696d2 to
9cc031c
Compare
130b4d6 to
3ff8e29
Compare
9cc031c to
ee4f79b
Compare
09b6387 to
ac1c059
Compare
ee4f79b to
265559d
Compare
ac1c059 to
4ba3638
Compare
265559d to
3821aa8
Compare
4ba3638 to
d2aa796
Compare
0aeb5f3 to
9b66ac7
Compare
79fd51e to
954a876
Compare
9b66ac7 to
5a06934
Compare
954a876 to
b9607ea
Compare
5a06934 to
a87c0f9
Compare
b9607ea to
786fb3c
Compare
a87c0f9 to
4af3458
Compare
786fb3c to
3845123
Compare
4af3458 to
530802e
Compare
3845123 to
e88bcd6
Compare
75e465f to
f8c9dff
Compare
16d2763 to
4056e73
Compare
1d2e4a9 to
b257f3b
Compare
9072753 to
b832964
Compare
b257f3b to
ae29002
Compare
b832964 to
94fdf97
Compare
ae29002 to
cdf0a37
Compare
2ebdb01 to
9c81f2b
Compare
66e9067 to
8e7b20b
Compare
| pr.Out.Header = prepareForwardingHeaders(pr.Out.Header, cred) | ||
| }, | ||
| Transport: h.transport, | ||
| Transport: keypool.NewKeyFailoverTransport(h.transport, h.failover), |
There was a problem hiding this comment.
I don't think we can reuse this as is for bridged routes. It picks keys with walker.Next() and never updates the request's *CentralizedPool, so cred.Hint() stays <failover key> and the interception won't record which key served the request. That's fine for passthrough because those requests aren't recorded. Could newProxy pass the request's credential to the failover transport, so it records the key it picks?
There was a problem hiding this comment.
Using the credential would also let newProxy skip key failover for BYOK credentials. Right now the transport checks the auth headers again with IsBYOK, even though we've already resolved the credential 🤔
There was a problem hiding this comment.
Recording hint is solved later in stack: https://github.com/coder/coder/pull/29726/changes#diff-fd84ed5f2d4fee4567d1827c1838f33705be295054c9ee169a00b7df4b893ed0R302-R314
It is a bit of a hack so I created followup issue to fix it properly. Checking BYOK again is a bit of a waste but should be working?
I'd rather use transport (with hack for now) then write another custom key loop.
cdf0a37 to
7014fc9
Compare
8e7b20b to
ba22df7
Compare
| func TestForwardingProviderCredentials(t *testing.T) { | ||
| t.Parallel() | ||
| // The pool enables failover, which BYOK requests must skip. | ||
| pool := newTestPool(t, "pool-secret-key") |
There was a problem hiding this comment.
nit: both parallel subtests share this pool and check its state, so anything one subtest does to the pool can make the other fail. Should each subtest create its own pool?
There was a problem hiding this comment.
Agree, in theory one test case could break another. Changed so pool is created per test case.
Forwarded requests go through the provider's key failover transport. The provider transport wrapper is installed beneath key failover, as passthrough does, so Claude Platform requests carry the required workspace header for BYOK and pooled credentials.
ba22df7 to
2a5c99b
Compare
Route centralized provider requests through the existing key-pool failover transport. Retries replay a consumed request prefix and continue the still-open source, discard rejected attempt responses, and preserve client bytes and headers. BYOK requests do not fall back to pooled credentials.
Generated by Coder Agents on behalf of @pawbana.