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
@@ -107,14 +107,14 @@ func LookupWithResolver(
|
||||
if addr, err := netip.ParseAddr(raw); err == nil {
|
||||
out.QueryKind = KindIP
|
||||
out.Normalized = addr.String()
|
||||
if err := lookupIP(st, tenantID, addr, out, commByID, ""); err != nil {
|
||||
if err := lookupIP(ctx, st, tenantID, addr, out, commByID, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else if pfx, err := netip.ParsePrefix(raw); err == nil {
|
||||
masked := pfx.Masked()
|
||||
out.QueryKind = KindCIDR
|
||||
out.Normalized = masked.String()
|
||||
if err := lookupCIDR(st, tenantID, masked, out, commByID); err != nil {
|
||||
if err := lookupCIDR(ctx, st, tenantID, masked, out, commByID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
@@ -124,7 +124,7 @@ func LookupWithResolver(
|
||||
}
|
||||
out.QueryKind = KindDomain
|
||||
out.Normalized = fqdn
|
||||
if err := lookupDomain(st, tenantID, fqdn, out, commByID); err != nil {
|
||||
if err := lookupDomain(ctx, st, tenantID, fqdn, out, commByID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if resolve == nil {
|
||||
@@ -178,7 +178,7 @@ func lookupResolvedIPs(
|
||||
out.ResolvedIPs = make([]string, 0, len(ips))
|
||||
for _, ip := range ips {
|
||||
out.ResolvedIPs = append(out.ResolvedIPs, ip.String())
|
||||
if err := lookupIP(st, tenantID, ip, out, commByID, ip.String()); err != nil {
|
||||
if err := lookupIP(ctx, st, tenantID, ip, out, commByID, ip.String()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -186,6 +186,7 @@ func lookupResolvedIPs(
|
||||
}
|
||||
|
||||
func lookupIP(
|
||||
ctx context.Context,
|
||||
st store.Backend,
|
||||
tenantID string,
|
||||
addr netip.Addr,
|
||||
@@ -227,7 +228,7 @@ func lookupIP(
|
||||
}
|
||||
}
|
||||
|
||||
snap, ok, err := st.GetModulePrefixSnapshot(tenantID, mod.ID)
|
||||
snap, ok, err := st.GetModulePrefixSnapshot(ctx, tenantID, mod.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -269,6 +270,7 @@ func prefixCoversQuery(listPfx, query netip.Prefix) bool {
|
||||
}
|
||||
|
||||
func lookupCIDR(
|
||||
ctx context.Context,
|
||||
st store.Backend,
|
||||
tenantID string,
|
||||
query netip.Prefix,
|
||||
@@ -308,7 +310,7 @@ func lookupCIDR(
|
||||
}
|
||||
}
|
||||
|
||||
snap, ok, err := st.GetModulePrefixSnapshot(tenantID, mod.ID)
|
||||
snap, ok, err := st.GetModulePrefixSnapshot(ctx, tenantID, mod.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -338,7 +340,7 @@ func lookupCIDR(
|
||||
return nil
|
||||
}
|
||||
|
||||
func lookupDomain(st store.Backend, tenantID, fqdn string, out *Result, commByID map[string]*store.Community) error {
|
||||
func lookupDomain(ctx context.Context, st store.Backend, tenantID, fqdn string, out *Result, commByID map[string]*store.Community) error {
|
||||
matchedModuleIDs := make(map[string]*store.Module)
|
||||
|
||||
for _, mod := range st.ListModules(tenantID) {
|
||||
@@ -372,7 +374,7 @@ func lookupDomain(st store.Backend, tenantID, fqdn string, out *Result, commByID
|
||||
}
|
||||
|
||||
for mid, mod := range matchedModuleIDs {
|
||||
snap, ok, err := st.GetModulePrefixSnapshot(tenantID, mid)
|
||||
snap, ok, err := st.GetModulePrefixSnapshot(ctx, tenantID, mid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func TestLookupIPEntryAndSnapshot(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := m.SetModulePrefixSnapshot(tenant, modIP, "hash1", []store.PrefixRow{
|
||||
if err := m.SetModulePrefixSnapshot(context.Background(), tenant, modIP, "hash1", []store.PrefixRow{
|
||||
{Prefix: "203.0.113.0/24", CommunityID: &cid, Source: "ip_range"},
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -129,7 +129,7 @@ func TestLookupDomainEntryAndSnapshot(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := m.SetModulePrefixSnapshot(tenant, mod.ID, "hash-d", []store.PrefixRow{
|
||||
if err := m.SetModulePrefixSnapshot(context.Background(), tenant, mod.ID, "hash-d", []store.PrefixRow{
|
||||
{Prefix: "198.51.100.1/32", CommunityID: &cid, Source: "domain"},
|
||||
{Prefix: "203.0.113.9/32", CommunityID: &cid, Source: "other"},
|
||||
}); err != nil {
|
||||
@@ -183,7 +183,7 @@ func TestLookupDomainResolvedIPAgainstRanges(t *testing.T) {
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := m.SetModulePrefixSnapshot(tenant, modIP, "hash-r", []store.PrefixRow{
|
||||
if err := m.SetModulePrefixSnapshot(context.Background(), tenant, modIP, "hash-r", []store.PrefixRow{
|
||||
{Prefix: "203.0.113.0/24", CommunityID: &cid, Source: "ip_range"},
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -234,7 +234,7 @@ func TestLookupCIDREntryAndSnapshot(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := m.SetModulePrefixSnapshot(tenant, modIP, "hash-cidr", []store.PrefixRow{
|
||||
if err := m.SetModulePrefixSnapshot(context.Background(), tenant, modIP, "hash-cidr", []store.PrefixRow{
|
||||
{Prefix: "203.0.113.0/24", CommunityID: &cid, Source: "ip_range"},
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in new issue
Block a user