-
Notifications
You must be signed in to change notification settings - Fork 172
Handle internal sandbox events from sandboxes in orchestrator #1108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Handle internal sandbox events from sandboxes in orchestrator #1108
Conversation
… to events domain
* map sandbox IPs to sandbox IDs
…tworking-in-sandbox-for-events-endpoint-e2b-2961
…andbox-events-at-the-orchestrator-level-e2b-2962
…andbox-events-at-the-orchestrator-level-e2b-2962
…tworking-in-sandbox-for-events-endpoint-e2b-2961
… entries in /etc/hosts
…endpoint-e2b-2961)
…andbox-events-at-the-orchestrator-level-e2b-2962
…2' of https://github.com/e2b-dev/infra into handle-sandbox-events-at-the-orchestrator-level-e2b-2962
…andbox-events-at-the-orchestrator-level-e2b-2962
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: IP Extraction Fails on IPv6 Addresses
The IP address extraction from r.RemoteAddr
using strings.Split(addr, ":")[0]
is unreliable. It incorrectly parses IPv6 addresses (e.g., [::1]:port
results in [::1
or [
) and is fragile, as RemoteAddr
's format isn't guaranteed to be ip:port
. This can lead to an incorrect sandboxIP
.
packages/orchestrator/internal/events/sandbox_events_handlers.go#L30-L32
func (h *DefaultSandboxEventHandler) HandlerFunc(w http.ResponseWriter, r *http.Request) { | |
addr := r.RemoteAddr | |
sandboxIP := strings.Split(addr, ":")[0] |
Bug: Redis Client Nil Checks Inconsistent
Several sandboxEventStore
methods, such as GetSandboxID
and DelSandboxIP
, don't check if redisClient
is nil
before use, unlike SetSandboxIP
. This inconsistency could lead to nil pointer panics if the client isn't initialized.
packages/orchestrator/internal/events/sandbox_events_store.go#L54-L67
infra/packages/orchestrator/internal/events/sandbox_events_store.go
Lines 54 to 67 in 4c96bff
func (c *sandboxEventStore) SetSandboxIP(ctx context.Context, sandboxID string, sandboxIP string) error { | |
if c.redisClient == nil { | |
return fmt.Errorf("redisClient is nil") | |
} | |
return c.redisClient.Set(ctx, IPPrefix+sandboxIP, sandboxID, cacheTL).Err() | |
} | |
func (c *sandboxEventStore) GetSandboxID(ctx context.Context, sandboxIP string) (string, error) { | |
return c.redisClient.Get(ctx, IPPrefix+sandboxIP).Result() | |
} | |
func (c *sandboxEventStore) DelSandboxIP(ctx context.Context, sandboxIP string) error { | |
return c.redisClient.Del(ctx, IPPrefix+sandboxIP).Err() | |
} |
Description
Setup networking in sandbox for events endpoint and handle sandbox events at the orchestrator level.
consts.go
file in orchestrator and add the sandbox event IP and portTest