Repository navigation
Conversation
…ildArgs is called again
This branch has not been deployed
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.
Summary
Most
with*methods that take a list or map add to what earlier calls set. Calling one of these three again threw away earlier configuration:withBindMountsassignedhostConfig.Binds, so a second call dropped the first call's mounts. It now appends, likewithExtraHosts,withUlimitsandwithSecurityOpt. This matches Java, whereaddFileSystemBindadds to the container's binds.withResourcesQuotawrote bothMemoryandNanoCpuson every call, and wroteundefinedfor the field that was left out. So.withResourcesQuota({ memory: 0.5 }).withResourcesQuota({ cpu: 1 })lost the memory limit. It now sets only the quotas passed in.GenericContainerBuilder.withBuildArgsreplaced the earlier args. It now merges them by key, where a later value for the same key wins, and it returnsthislike its siblings.Modules pick this up through core, with no module changes. Bind mounts a user adds are no longer dropped when
RedisContainer/ValkeyContainer(withPersistence) orQdrantContainer(withConfigFile) add their own bind instart(). A user'swithBindMountscall also no longer removes the cgroup bind that K3s sets in its constructor.The docs now say which methods add and which replace: one sentence on each of the three methods, and a short note under "Starting a container" that names the methods on each side. The
withBindMountssection also says that mounting the same target twice fails when the container starts.Verification
Each new test fails on
mainand passes with this change:generic-container.test.ts, "should add bind mounts when called more than once". Onmain:expected 'cat: can't open '/tmp/test.txt'…' to contain 'hello world'.generic-container-resources-quota.test.ts, "should only change the quotas given when called more than once". Onmain:expected +0 to deeply equal 536870912.generic-container-dockerfile.test.ts, "should add build arguments when called more than once". Onmain:Failed to build image. The first call'sVERSIONwas dropped, so the build triedFROM node:not-existent.Results with the change:
generic-container.test.tsandgeneric-container-resources-quota.test.tspass.generic-container-dockerfile.test.ts, all tests pass except the existing "should not pull existing image without pull policy". That test listens for anypullevent on the Docker host, and "should use pull policy" in the same file pullsnode:10-alpineconcurrently. The new build adds one more concurrent build, and locally that made the overlap much more frequent (7 of 8 runs, against 1 of 5 onmain). WithCI=true, so vitest'sretry: 3applies, the file passed 11/11 on both runs, with one retry of that test each time. Making the two pull-event tests non-concurrent would fix it; I left that for a separate PR.ollama/ollamapull was stalled on my Docker host. They passed on rerun, and none of their tests add binds that would collide.npm run format,npm run lint,npm run knipandnpm run check-compilesare clean.Not breaking
A single call on a
GenericContainerbehaves as before, and the only type change iswithBuildArgsreturningthis, which is narrower. What changes:K3sContainerbinds/sys/fs/cgroupin its constructor. A user'swithBindMountscall used to replace that bind and now keeps it. A user who binds/sys/fs/cgroupthemselves now gets Docker'sDuplicate mount pointerror.RedisContainer/ValkeyContainerwithwithPersistenceplus a user bind to/data, andQdrantContainerwithwithConfigFileplus a user bind on the config file path, now fail withDuplicate mount point. Before, the module's bind silently replaced the user's.start()a second time on those Redis, Valkey or Qdrant containers adds the module's bind again, and Docker rejects the duplicate. This is the start()-accumulation problem tracked in Makestart()safe to call more than once on the same container #1520.I've labelled this
bug+patchlike the issue, since the replace behaviour was undocumented and silently dropped configuration. The cases above can turn a silently ignored setting into an error, though, so whether this ships aspatchorminoris your call.Closes #1527