Repository navigation
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
/run-security-scan |
alexcos20
left a comment
There was a problem hiding this comment.
AI automated code review (Gemini 3).
Overall risk: low
Summary:
This PR successfully introduces support for custom port mapping (ports) for service deployment (Start and Restart). The interface additions are well-documented, the provider methods appropriately spread the new parameters, and the testing suite is remarkably thorough. The only blocker for merge is a hardcoded node PR version in the CI workflow, which is typical for cross-repo feature testing but must be removed prior to merging.
Comments:
• [ERROR][other] Hardcoding NODE_VERSION: pr-1638 ties the pipeline to an external PR branch. While this is great for cross-repo testing during development, please ensure this is reverted to main or updated to a stable release tag before merging. Otherwise, main branch CI will depend on a volatile/temporary PR branch that could be deleted.
- env:
- NODE_VERSION: pr-1638• [ERROR][other] Same issue as above: remember to revert the NODE_VERSION override for this job as well before merging.
• [INFO][style] Excellent inline documentation for the new ports property. Clearly explaining its precedence over the legacy exposedPorts and its interaction with RESPEC prevents developer confusion.
• [INFO][style] The conditional spread ...(ports !== undefined ? { ports } : {}) properly preserves the difference between undefined (omit/keep current) and [] (explicit empty/clear). Good attention to detail to ensure this matches the behavior established in your unit tests.
• [INFO][style] Great approach to testing expected rejections. By specifically matching the error string against /host port|range/i and subsequently asserting that the container state was unharmed, you've created a highly robust integration test.
Service-on-Demand: forward user-specified host ports (
ports)Summary
Client-SDK mirror of the ocean-node
feat/service-custom-portschange. ocean.js now forwards anoptional
portsfield onserviceStartandserviceRestartso callers can pin a specifichost port for a container port (or omit
hostPortto let the node auto-allocate):All validation and enforcement stay on the node (range/freeness, charge-safety, rejection); the SDK
only passes the field through. Purely additive and backward compatible — existing
exposedPortsand no-ports callers build a byte-identical request.
Semantics (match ocean-node)
hostPortomitted → node auto-allocates from itshostPortRange(today's behaviour).hostPortset → node pins it, rejecting the command if it is out of range or not free.portsis sent alongside the legacyexposedPorts; the node letsportssupersede
exposedPortswhen both are present.portsis forwarded — the SDK deliberately does not sendexposedPortson restart (the node ignores it there, and this prevents a client that echoes astart body into a restart from changing ports by accident). A port change is independent of the
REUSE/RESPEC rule (like
metadata); omittingportskeeps the service's current ports; anexplicit
ports: []is forwarded (replace-with-none), distinct from omitting it.Changes by file
src/@types/Services.tsServicePortRequest { containerPort; hostPort? };ports?added to the sharedServiceContainerSpec(so bothServiceStartParamsandServiceRestartParamsinherit it);requestedHostPorts?: Record<string, number>added toServiceJobfor response parity. Auto-exported via@types/index.ts(export * from './Services.js').src/services/providers/HttpProvider.tsserviceRestartdestructuresportsand conditionally spreads it into the body;serviceStartalready forwards it via the existing...restspread (no change needed).src/services/providers/P2pProvider.tsserviceRestartchange (symmetric with HTTP);serviceStartvia...rest.test/unit/Services.test.tsports forwardingsuite — stubsglobalThis.fetchvia an agent-signature token (no network/auth/encrypt) to capture the request body.test/integration/Services.test.tsportshost port is rejected and the service staysRunning(proves the field reached the node).Type-level doc comments on
ServicePortRequest/ServiceContainerSpec.portsflow into theTypeDoc-generated
docs/on the nextbuild:types(there is no hand-written Service-on-Demandusage snippet to update).
Summary by CodeRabbit