Change default exposed port to 49983 for E2B compatibility#207
Conversation
| mvm_gw_dest_ip = "169.254.68.5" | ||
| mvm_mtu = 1300 | ||
| default_exposed_ports = [8080, 32000] | ||
| default_exposed_ports = [49983] |
There was a problem hiding this comment.
Thanks for working on this issue.
I have a question in mind: Do we need these configurations in three components?
There was a problem hiding this comment.
Yes @chenhengqi, all three need updating because each component uses its own default independently — CubeMaster uses it for template validation, Cubelet for building port mappings, and network-agent for the actual network enforcement. If we only changed one, the others would still use the old ports and wouldn't match. That said, consolidating them into a single file / source of truth would be cleaner.
There was a problem hiding this comment.
For consolidating into a shared constant package tho, I recommend doing it on another PR. (Let me know 😃)
There was a problem hiding this comment.
If CubeMaster already set default exposed port to 49983 on template creation, Cubelet should be able to obtain it through realReq.GetExposedPorts().
There was a problem hiding this comment.
Ah, thats a better workflow than shared constant @chenhengqi, I think for that to work we will need to remove the overrides in cubelet and network-agent tho
There was a problem hiding this comment.
Ah, thats a better workflow than shared constant @chenhengqi, I think for that to work we will need to remove the overrides in cubelet and network-agent tho
Right, I think we should remove those ports from cubelet and network-agent.
There was a problem hiding this comment.
I can try to implement the changes, should I commit in this same pr with the same format?
component: desc
Just do it in this PR.
There was a problem hiding this comment.
Please reorganize your commits. One commit per component.
32f0a42 to
19b0135
Compare
| } | ||
|
|
||
| if reqPorts > 3 { | ||
| if len(realReq.GetExposedPorts()) > 4 { |
There was a problem hiding this comment.
- Old: 2 defaults + 3 customs = 5 total
- New: 1 default + 3 customs = 4 total
The old limit was 2 defaults + 3 custom = 5. Since we're down to 1 default (49983) and CubeMaster still allows max 3 custom ports (countCustomTemplateExposedPorts > 3), I went with 1 + 3 = 4. Happy to bump to 5 if you'd prefer to keep the old ceiling as to be more permissive.
There was a problem hiding this comment.
for the other 2 mentions of cubebot,
-
Will push a new test, this is correct
-
This is consistent with the previous behavior. The old code also didn't dedupe; it counted each occurrence of a non-default port, so [9000, 9000, 9000, 9000] would have hit the > 3 custom limit and been rejected. Cubelet and network-agent both dedupe via maps downstream (portReq in plugin_tap.go, byContainerPort in normalizePortMappings), so duplicates don't cause double mappings — only the count-based validation rejects them.
There was a problem hiding this comment.
pushed test fix for 2) and reorganized commits
There was a problem hiding this comment.
- Old: 2 defaults + 3 customs = 5 total
- New: 1 default + 3 customs = 4 total
The old limit was 2 defaults + 3 custom = 5. Since we're down to 1 default (49983) and CubeMaster still allows max 3 custom ports (countCustomTemplateExposedPorts > 3), I went with 1 + 3 = 4. Happy to bump to 5 if you'd prefer to keep the old ceiling as to be more permissive.
Sounds reasonable. Let's keep it as 4 for now.
|
/cubebot review this pr. |
|
Claude finished @chenhengqi's task in 3m 59s —— View job PR Review: Change default exposed port to 49983
Overall AssessmentThe architectural direction is correct — making CubeMaster the single source of truth for the default exposed port (49983) and removing the redundant defaults from Cubelet and network-agent is a clean improvement. The cleanup is thorough: However, there are a few issues to address: Issues1. Exposed port limit inconsistency (addressing @chenhengqi's In if len(realReq.GetExposedPorts()) > 4 {The old logic allowed 3 custom ports + 2 defaults = 5 total. The new limit of 4 reduces the user-facing budget. Meanwhile, CubeMaster still allows 3 custom ports ( But consider whether the intent is to preserve the total port budget (5 = 4 custom + 1 default) or the custom port budget (3). If the goal is to give users the same number of custom ports as before (3), then 2. Missing test for Cubelet's exposed port limit The exposed port validation in func TestCheckParamExposedPortLimit(t *testing.T) {
// 4 ports should pass
// 5 ports should fail
// port 0 and 65536 should fail
}3. Duplicate port handling removed silently The old code in Minor Nits4. Error message phrasing — 5. Clean removal — The 6. Test coverage in CubeMaster — The new tests 7. network-agent config removal — SummaryThe core change is clean and the architecture is improved. Main items to address:
|
The old defaults (8080, 32000) are not useful for E2B-compatible sandboxes. Replace them with 49983 to match the E2B sandbox protocol. Closes TencentCloud#204 Signed-off-by: turtlemoji <turtlemoji@protonmail.com>
CubeMaster is the single source of truth for default exposed ports. Remove the independent defaults from Cubelet so it only uses ports received in the request. Signed-off-by: turtlemoji <turtlemoji@protonmail.com>
CubeMaster is the single source of truth for default exposed ports. Remove the independent defaults and port seeding from network-agent. Signed-off-by: turtlemoji <turtlemoji@protonmail.com>
19b0135 to
c96e030
Compare
|
@fslongjin Please take a look. |
Summary
The default exposed ports (8080, 32000) are not useful for E2B-compatible sandboxes. This PR replaces them with 49983 across all three affected components.
Changes
defaultTemplateExposedPorts()and add tests verifying the new default and reserved port behaviorDefaultExposedPorts, shippedconfig.toml, and the validation error message to reflect one reserved port instead of twoDefaultConfig()and add a test for the new defaultTest plan
go test ./pkg/templatecenter/ -run TestDefaultTemplateExposedPortsgo test ./pkg/templatecenter/ -run TestCountCustomTemplateExposedPortsTreats49983AsReservedgo test ./network/ -run TestDefaultExposedPortsContainsOnly49983go test ./internal/service/ -run TestDefaultConfigExposedPortsgofmtclean on all changed filesCloses #204