feat(httpapi): harden control plane and speed up prefix refresh
Очередь job получила lease и fencing, телеметрия и прогресс deploy сохраняются, ревизия пишет manifest входов. Обновление префиксов не переписывает неизменённый снимок, большие наборы идут через COPY, а устаревшая ревизия не попадает в deploy. Бандл ноды кэшируется, prune и постановка job больше не держат горячий путь. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
924f111e48
commit
f8e0520817
197 files changed
+18655
-1416
No files matched your search
@@ -0,0 +1,66 @@
|
||||
package pipeline
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPipelineClientReusesSeparateCDNPool(t *testing.T) {
|
||||
t.Setenv("EVOBGP_CDN_ALLOW_PRIVATE", "1")
|
||||
var connections atomic.Int32
|
||||
server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = io.WriteString(w, "192.0.2.0/24\n") }))
|
||||
server.Config.ConnState = func(_ net.Conn, state http.ConnState) {
|
||||
if state == http.StateNew {
|
||||
connections.Add(1)
|
||||
}
|
||||
}
|
||||
server.StartTLS()
|
||||
defer server.Close()
|
||||
client := NewPipelineHTTPClient()
|
||||
defer client.CloseIdleConnections()
|
||||
// Configure only test trust roots; the normal dial/redirect guards remain.
|
||||
pools := client.Transport.(*pipelineTransport)
|
||||
pools.cdn.(*cdnRoundTripper).transport.TLSClientConfig = server.Client().Transport.(*http.Transport).TLSClientConfig.Clone()
|
||||
for range 3 {
|
||||
req, _ := http.NewRequest(http.MethodGet, server.URL, nil)
|
||||
response, err := UpstreamHTTPDo(context.Background(), client, req)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err = ReadCDNBody(response.Body)
|
||||
_ = response.Body.Close()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if connections.Load() != 1 {
|
||||
t.Fatalf("CDN requests created %d connections", connections.Load())
|
||||
}
|
||||
}
|
||||
|
||||
func TestPipelineClientSeparatesPrivateProfileAndCDN(t *testing.T) {
|
||||
t.Setenv("EVOBGP_CDN_ALLOW_PRIVATE", "0")
|
||||
var calls atomic.Int32
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { calls.Add(1); _, _ = io.WriteString(w, "ok") }))
|
||||
defer server.Close()
|
||||
client := NewPipelineHTTPClient()
|
||||
defer client.CloseIdleConnections()
|
||||
response, err := client.Get(server.URL)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, _ = io.Copy(io.Discard, response.Body)
|
||||
_ = response.Body.Close()
|
||||
req, _ := http.NewRequest(http.MethodGet, server.URL, nil)
|
||||
if _, err = UpstreamHTTPDo(context.Background(), client, req); err == nil {
|
||||
t.Fatal("CDN used trusted profile pool")
|
||||
}
|
||||
if calls.Load() != 1 {
|
||||
t.Fatalf("CDN reached private profile server: %d", calls.Load())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user