Refactor the Create/Resume functions to avoid globals/reduce args#1258
Merged
Conversation
Contributor
Author
|
Cursor's comment is true, but intentional. It felt like the right thing to do (the CLIs are used for testing, while the main binary is deployed and configured via env vars), but if that's the wrong move, let me know. |
Contributor
Author
|
oh, the template server shouldn't have the hardcoded value, I'll fix that |
jakubno
requested changes
Sep 30, 2025
Comment on lines
-70
to
-71
| layerExecutor.networkPool, | ||
| layerExecutor.devicePool, |
Member
There was a problem hiding this comment.
I think layer executor doesn't need those anymore
Contributor
Author
There was a problem hiding this comment.
Good catch! Removed them and a bunch of other unused fields.
| // Create sandbox for building template | ||
| userLogger.Debug("Creating base sandbox template layer") | ||
|
|
||
| // TODO: Temporarily set this based on global config, should be removed later (it should be passed as a parameter in build) |
Member
There was a problem hiding this comment.
can you move the TODO? We're still not sending it as part of build
jakubno
requested changes
Oct 1, 2025
| index, | ||
| builder.metrics, | ||
| ) | ||
| baseBuilder := base.New(bc, builder.logger, builder.proxy, builder.templateStorage, builder.artifactRegistry, layerExecutor, index, builder.metrics, builder.sandboxFactory) |
Member
There was a problem hiding this comment.
can we keep it on separate lines? 🙏🏻 it's easier to review
jakubno
approved these changes
Oct 1, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR creates a
Factorystruct, which does a few things:networkPoolanddevicePoolto a central place, so they don't need to be passed intoCreateSandboxandResumeSandboxon every invocation.MetricsWriteFlagNameinto the Factory, simplifying the arguments.ALLOW_SANDBOX_INTERNETenv var into themainfunction, and out of the global scope.Note
Introduce
sandbox.Factoryto encapsulate network/device pools and feature flags, refactoring sandbox create/resume flows and updating builders/servers to use it while removing global config and excess args.sandbox.Factoryholdingnetwork.Pool,nbd.DevicePool,featureflags.Client, and default internet access.sandbox.CreateSandbox/ResumeSandboxtoFactorymethods; eliminate globalconfig.AllowSandboxInternetand per-call pool args.FactoryduringResumeSandbox.server.Newsimplified (no context/err return);ServiceConfiggainsSandboxFactoryand uses it when creating sandboxes.SandboxFactory(env-drivenALLOW_SANDBOX_INTERNET) and passes it to server and template manager.build.Builder, layer executors, and phase builders accept/usesandbox.Factoryinstead of pools; constructors updated accordingly.internal/configAllowSandboxInternet.Written by Cursor Bugbot for commit 5f5caa1. This will update automatically on new commits. Configure here.