fix: Ffixes to console
Chart Release / chart (push) Successful in 18s
Server Deploy / deploy (push) Successful in 1m9s

This commit is contained in:
2026-07-31 15:05:21 +01:00
parent 57a9b18102
commit 6f86496f10
6 changed files with 231 additions and 160 deletions
+11 -54
View File
@@ -7,7 +7,6 @@ import (
"crypto/rand"
"encoding/hex"
"errors"
"sync"
)
var (
@@ -25,56 +24,14 @@ func NewID() (string, error) {
return hex.EncodeToString(b), nil
}
type Entry struct {
ProxyID string
InstanceID string
ServerID string
Session *Session
}
type Registry struct {
mu sync.Mutex
entries map[string]*Entry
}
func NewRegistry() *Registry {
return &Registry{entries: make(map[string]*Entry)}
}
var Default = NewRegistry()
func (r *Registry) Add(e *Entry) {
r.mu.Lock()
defer r.mu.Unlock()
r.entries[e.ProxyID] = e
}
// Claim removes and returns the entry. It is single-use: a second claim on the
// same proxy_id gets ErrNotFound. A claim whose instance or server does not
// match leaves the entry in place and gets ErrForbidden.
func (r *Registry) Claim(instanceID, serverID, proxyID string) (*Entry, error) {
r.mu.Lock()
defer r.mu.Unlock()
e, ok := r.entries[proxyID]
if !ok {
return nil, ErrNotFound
}
if e.InstanceID != instanceID || e.ServerID != serverID {
return nil, ErrForbidden
}
delete(r.entries, proxyID)
return e, nil
}
func (r *Registry) Remove(proxyID string) {
r.mu.Lock()
defer r.mu.Unlock()
delete(r.entries, proxyID)
}
func (r *Registry) Len() int {
r.mu.Lock()
defer r.mu.Unlock()
return len(r.entries)
}
// There is deliberately no in-process registry of pending sessions here any
// more. One existed, keyed by proxy_id, on the assumption that the pod which
// bound a listener was the pod that would receive the matching ProxyStream.
// That assumption holds only for a single replica: a ProxyStream is its own
// HTTP/2 request and an L7 proxy routes it independently of the agent's
// command stream, so with N replicas the lookup missed (N-1)/N of the time and
// the console failed with "proxy session not found".
//
// The pending record lives in Redis instead (bus.SetPendingProxy /
// ClaimPendingProxy), and the listener is bound by whichever pod the stream
// actually reaches — see services.ClaimProxyStream.