Repository navigation
fix: only rewrite whole Windows reserved device names - #2704
Pranav-IIITM wants to merge 7 commits into
Conversation
FilterReservedNames matched reserved words (aux, com, con, lpt, nul, prn) as substrings and ran on every OS, so valid names were mangled (e.g. "my-company-cache" -> "my-c_o_mpany-cache", "config" -> "c_o_nfig"), including on Linux and macOS where nothing is reserved. This changed Docker cache volume names away from what users requested. Match only the whole base name, case-insensitively, against the actual Windows reserved set (CON, PRN, AUX, NUL, COM1-COM9, LPT1-LPT9), handle names with an extension such as "nul.txt", and skip the transformation entirely on non-Windows platforms. Signed-off-by: Pranav-IIITM <jogdandpranav2007@gmail.com>
|
@jjbustamante PTAL at this PR, when you have time !! |
|
Thanks for working on this!. I'd like us to go one step further though: rather than making the matching more precise, let's delete Why it was introduced
The original concern was real but narrow: with Windows containers, a volume name becomes a directory under the daemon's data root on a Windows host, and Win32 resolves Who it was ever for
That table is also why I'd avoid the What I'd like the PR to do
**My only concern is that, once we release a new pack version, this change will invalidate old cache volumes, so I'll need to notify end-users about it. ** Happy to help if any of this is awkward to unwind, and thanks again; the investment made this much easier to reason about. |
|
Thanks @jjbustamante, that's really helpful context. The history makes it clear that the right fix is to remove the filter rather than refine it, and you're right that the client OS was never the right thing to check, since the volume lives on the daemon. I'll update the PR to:
On the cache invalidation concern, I traced which volumes actually change names. The blast radius is fairly small:
For affected users the result is a single cold build: pack creates a new, correctly named volume and the build works normally. The old mangled volume is left behind until removed. No data is lost and no build fails. Here's a draft for the release notes, if it's useful:
I'll push the changes shortly. Thanks again for the review! |
FilterReservedNames was introduced for Windows containers, where a volume name becomes a directory on a Windows daemon host. The WCOW build workflow has since been removed, so the rewrite no longer protects any supported setup, while it still mangles user-chosen and auto-generated cache volume names (e.g. "my-company-cache" -> "my-c_o_mpany-cache"). Remove the function, its call sites and its tests so volume names are used exactly as given. Signed-off-by: Pranav-IIITM <jogdandpranav2007@gmail.com>
e2ea339 to
cd0574b
Compare
Signed-off-by: Pranav-IIITM <jogdandpranav2007@gmail.com>
|
The latest CI failures look unrelated to this change. When you have a moment, could you re-run the failed jobs?
Thanks! |
|
Looks like the problem is on this test on Windows: === RUN TestBuild/build/#Build/Buildpacks_option/buildpacks_include_URIs/buildpack_is_from_a_registry/all_buildpacks_are_added_to_ephemeral_builder
build_test.go:1798: Expected nil: unlinkat C:\Users\RUNNER~1\AppData\Local\Temp\registry2670797477\bp-1130947187.tar: The process cannot access the file because it is being used by another process.I wonder if, after removing this function, we still have some edge case on Windows we are missing |
@Pranav-IIITM actually, it is a flaky test. I saw the same error in another PR I was working on, and I didn't touch any Go code. I will try to fix it |
|
Thanks for confirming @jjbustamante! I also found the same failure on an unrelated branch back in August (run 31387831260), so it does look like a pre-existing flake. My guess is a layer reader that isn't always closed before the test's |
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>
The merge left the container import mis-indented and kept the paths import, which is unused now that FilterReservedNames is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>
Summary
paths.FilterReservedNamesrewrote valid names because it matched the Windows reserved words (aux,com,con,lpt,nul,prn) as substrings, and it ran on every OS. As a result, ordinary names were mangled — including on Linux and macOS, where no names are reserved — which changed the Docker cache volume names users actually asked for.Before / After
What changed
.), case-insensitively, instead of matching a reserved word anywhere in the string.CON,PRN,AUX,NUL,COM1–COM9,LPT1–LPT9. Barecom/lptare no longer rewritten, since they are not actually reserved.nul.txtbecomesn_u_l.txt.Impact
docker volume lsand via scripting.my-company-cache) is no longer missed.Migration note
Existing incorrectly mangled volumes are not renamed automatically. After upgrading, pack may reference a new, correctly named volume while the old mangled volume remains until it is cleaned up manually.
Testing
go build ./internal/paths/...go vet ./internal/paths/go test ./internal/paths/... ./pkg/cache/...Closes #2703