-
Notifications
You must be signed in to change notification settings - Fork 292
allow routing sdk traffic through stable envd.<domain> host #2540
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
Draft
matthewlouisbrockman
wants to merge
6
commits into
main
Choose a base branch
from
feat/enable-envd-connection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+67
−9
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
37dcec5
feat: enable shared envd host routing
matthewlouisbrockman 261d28e
feat: route shared envd host through client proxy
matthewlouisbrockman f8fcc5b
fix: avoid shadowing envd host parameter
matthewlouisbrockman af62891
fix: satisfy shared proxy lint
matthewlouisbrockman 1d6420d
fix: preserve local envd routing through client proxy
matthewlouisbrockman 650ea47
test: remove stale proxy env setup
matthewlouisbrockman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,6 @@ import ( | |
| "google.golang.org/grpc/codes" | ||
| "google.golang.org/grpc/status" | ||
|
|
||
| "github.com/e2b-dev/infra/packages/shared/pkg/env" | ||
| "github.com/e2b-dev/infra/packages/shared/pkg/featureflags" | ||
| proxygrpc "github.com/e2b-dev/infra/packages/shared/pkg/grpc/proxy" | ||
| "github.com/e2b-dev/infra/packages/shared/pkg/logger" | ||
|
|
@@ -63,6 +62,24 @@ func normalizeNodeIP(nodeIP string) (string, error) { | |
| return nodeIP, nil | ||
| } | ||
|
|
||
| func orchestratorSandboxHost(host string, sandboxID string, port uint64) *string { | ||
| hostname := strings.Split(host, ":")[0] | ||
| if hostname == "localhost" { | ||
| orchestratorHost := fmt.Sprintf("%d-%s.localhost", port, sandboxID) | ||
|
|
||
| return &orchestratorHost | ||
| } | ||
|
|
||
| domain, ok := strings.CutPrefix(hostname, "envd.") | ||
| if !ok || domain == "" { | ||
| return nil | ||
|
matthewlouisbrockman marked this conversation as resolved.
|
||
| } | ||
|
|
||
| orchestratorHost := fmt.Sprintf("%d-%s.%s", port, sandboxID, domain) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for envd, we don't need to have the port configurable so I would either fix the port to specific one, or change the general url |
||
|
|
||
| return &orchestratorHost | ||
| } | ||
|
cursor[bot] marked this conversation as resolved.
matthewlouisbrockman marked this conversation as resolved.
|
||
|
|
||
| func catalogResolution(ctx context.Context, sandboxId string, sandboxPort uint64, trafficAccessToken string, envdAccessToken string, c catalog.SandboxesCatalog, pausedChecker PausedSandboxResumer, featureFlags *featureflags.Client) (string, error) { | ||
| s, err := c.GetSandbox(ctx, sandboxId) | ||
| if err != nil { | ||
|
|
@@ -133,7 +150,7 @@ func handlePausedSandbox( | |
| } | ||
|
|
||
| func NewClientProxy(meterProvider metric.MeterProvider, serviceName string, port uint16, catalog catalog.SandboxesCatalog, pausedSandboxResumer PausedSandboxResumer, featureFlagsClient *featureflags.Client) (*reverseproxy.Proxy, error) { | ||
| getTargetFromRequest := reverseproxy.GetTargetFromRequest(env.IsLocal()) | ||
| getTargetFromRequest := reverseproxy.GetTargetFromRequest(reverseproxy.HeaderRoutingEnabled) | ||
| proxy := reverseproxy.New( | ||
| port, | ||
| // Retries that are needed to handle port forwarding delays in sandbox envd are handled by the orchestrator proxy | ||
|
|
@@ -198,6 +215,11 @@ func NewClientProxy(meterProvider metric.MeterProvider, serviceName string, port | |
| SandboxPort: port, | ||
| ConnectionKey: pool.ClientProxyConnectionKey, | ||
| Url: url, | ||
| MaskRequestHost: orchestratorSandboxHost( | ||
| r.Host, | ||
| sandboxId, | ||
| port, | ||
| ), | ||
| }, nil | ||
| }, | ||
| nil, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
lets put the envd subdomain to a const