Conversation
kentonv
left a comment
There was a problem hiding this comment.
Most applications will have called monitor() themselves, making this call redundant at best and possibly leading to inconsistent state.
The underlying problem is that if an application does not call monitor(), then the running boolean isn't updated when the container exits. This is actually independent of destroy(), but destroy() is one way to cause the inconsistency.
What we actually need to do is make a call to monitor() automatically internally, so that we can keep the running boolean accurate. The JS monitor() method will have to piggy-back on the internal call's result.
To clarify, we should call |
8c5b79f to
7cba1d2
Compare
7cba1d2 to
d6d3d08
Compare
d6d3d08 to
d1ef96f
Compare
d1ef96f to
f9861d7
Compare
f9861d7 to
00733e7
Compare
00733e7 to
bdf8348
Compare
|
@kentonv This is ready for another round of reviews. Would you mind taking a look? |
kentonv
left a comment
There was a problem hiding this comment.
I don't see any tests in this PR nor a PR to the internal codebase modifying the test there. Where is the new functionality tested?
0932785 to
01dfc58
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
5aa78e6 to
b17d89c
Compare
| // The background monitor promise, held to keep it alive. Uses eagerlyEvaluate() | ||
| // to ensure it runs to completion. Held here (rather than via addTask()) to avoid | ||
| // preventing DO hibernation. | ||
| kj::Maybe<IoOwn<kj::Promise<void>>> backgroundMonitor; |
There was a problem hiding this comment.
Eventually, it might be nice to bundle all the IoOwns into a struct so that there's just one IoOwn in use. Non-blocking for this tho.
jasnell
left a comment
There was a problem hiding this comment.
AI Review Summary
Findings posted as inline comments. Two additional items not pinned to diff lines:
-
visitForMemoryInfonot updated: The PR addsmonitorState,monitorKjPromise,monitorJsPromise, andbackgroundMonitorbut doesn't updatevisitForMemoryInfo()to track them. Memory profiling will undercount theContainerobject's true size. -
Missing test coverage for
destroy()+ active background monitor: Ifdestroy()is called while the background monitor is running, the capnp docs say "If a call tomonitor()is waiting whendestroy()is invoked,monitor()will also return (with no error)." This edge case isn't exercised by the test suite.
This review was generated by an AI assistant and may contain inaccuracies. Please verify the findings independently.
b17d89c to
32150f7
Compare
| cmd.set(idx++, "--disable-ipv6"); | ||
| } | ||
| cmd.set(idx++, "--address"); | ||
| cmd.set(idx++, address); |
There was a problem hiding this comment.
this is going to break in some MacOS docker desktops as they dont have v6 enabled altogether. Thats why I decided against creating a network ourselves as it's complicated to accommodate all use-cases,
| // Promise that resolves when the current start() RPC completes. The background | ||
| // monitor chains after this to avoid racing with the start RPC (which creates/ | ||
| // starts the container). Without this, the monitor RPC's Docker /wait could see | ||
| // a stale container from a previous run and return its old exit code. |
There was a problem hiding this comment.
I think this is an impl. detail of the container service. I think it should be up to the container capnp service to hold the monitor inflight if the start is already inflight.
| for (auto config: ipamConfig) { | ||
| auto subnet = kj::str(config.getSubnet()); | ||
| auto gateway = kj::str(config.getGateway()); | ||
| if (subnet.findFirst(':') != kj::none) { |
There was a problem hiding this comment.
Nit: consider checking the findFirst first, then doing to allocation/copy for the subnet and gateway
| // we simply return false while avoiding an unnecessary error. | ||
| if (response.statusCode == 404) { | ||
| co_return InspectResponse{.isRunning = false, .ports = {}}; | ||
| co_return InspectResponse{.isRunning = false, .ports = {}, .hostsPath = kj::none}; |
There was a problem hiding this comment.
| co_return InspectResponse{.isRunning = false, .ports = {}, .hostsPath = kj::none}; | |
| co_return InspectResponse{ | |
| .isRunning = false, | |
| .ports = {}, | |
| .hostsPath = kj::none, | |
| }; |
| auto hostsPath = getHostsPathFromInspectResponse(response.body); | ||
|
|
||
| co_return InspectResponse{ | ||
| .isRunning = running, .ports = kj::mv(portMappings), .hostsPath = kj::mv(hostsPath)}; |
There was a problem hiding this comment.
| .isRunning = running, .ports = kj::mv(portMappings), .hostsPath = kj::mv(hostsPath)}; | |
| .isRunning = running, | |
| .ports = kj::mv(portMappings), | |
| .hostsPath = kj::mv(hostsPath), | |
| }; |
Addresses #4362 from a different perspective
Used AI to generate the tests.