-
Notifications
You must be signed in to change notification settings - Fork 770
fix: remove existing /workspace from CUDA base image before COPY oper… #2382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -318,6 +318,9 @@ COPY --from=wheel_builder /workspace /workspace | |||||||||||||||||||||||||||
| # Copy Cargo cache to avoid re-downloading dependencies | ||||||||||||||||||||||||||||
| COPY --from=wheel_builder $CARGO_HOME $CARGO_HOME | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # This path exists from the base image, maintained by the CUDA team. Don't need it, so remove it. | ||||||||||||||||||||||||||||
| RUN rm -f /workspace && mkdir -p /workspace | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
Comment on lines
+321
to
+323
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainrm -f will error on directories; position should be before any /workspace usage
Update to a safe conditional and ensure the directory exists: -# This path exists from the base image, maintained by the CUDA team. Don't need it, so remove it.
-RUN rm -f /workspace && mkdir -p /workspace
+# This path sometimes exists in CUDA images as a file/symlink. Ensure it's a real directory.
+RUN if [ -L /workspace ] || [ -f /workspace ]; then rm -f /workspace; fi && mkdir -p /workspaceRecommend moving this block to just before any instruction in this stage that targets /workspace (before COPY/WORKDIR) to avoid ordering hazards. 🏁 Script executed: #!/bin/bash
rg -n --context 2 $'RUN .*rm -f /workspace' container/Dockerfile.tensorrt_llmLength of output: 266 🏁 Script executed: #!/bin/bash
# Show context around the problematic RUN at lines 320-323
sed -n '280,360p' container/Dockerfile.tensorrt_llmLength of output: 2568 Correct
Apply: FROM build AS dev
- WORKDIR /workspace
+ # Ensure /workspace is a real directory (not a symlink or file from the base image)
+ RUN if [ -L /workspace ] || [ -f /workspace ]; then rm -f /workspace; fi && mkdir -p /workspace
+ WORKDIR /workspace
- COPY --from=wheel_builder /workspace /workspace
- COPY --from=wheel_builder $CARGO_HOME $CARGO_HOME
+ # Copy built wheels and Cargo cache from the builder stage
+ COPY --from=wheel_builder /workspace /workspace
+ COPY --from=wheel_builder $CARGO_HOME $CARGO_HOME
- # This path exists from the base image, maintained by the CUDA team. Don't need it, so remove it.
- RUN rm -f /workspace && mkdir -p /workspace
- # Copy rest of the code
- COPY . /workspace
+ # Copy the rest of the source
+ COPY . /workspace📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| # Copy rest of the code | ||||||||||||||||||||||||||||
| COPY . /workspace | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -390,6 +390,9 @@ COPY --from=wheel_builder $NIXL_PREFIX $NIXL_PREFIX | |
| # Copy Cargo cache to avoid re-downloading dependencies | ||
| COPY --from=wheel_builder $CARGO_HOME $CARGO_HOME | ||
|
|
||
| # This path exists from the base image, maintained by the CUDA team. Don't need it, so remove it. | ||
| RUN rm -f /workspace && mkdir -p /workspace | ||
|
|
||
|
Comment on lines
+393
to
+395
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainrm -f on /workspace will fail if it’s already a directory; also placed too late in the stage
Fix the command to only delete when /workspace is a file or symlink, then ensure the path exists: -# This path exists from the base image, maintained by the CUDA team. Don't need it, so remove it.
-RUN rm -f /workspace && mkdir -p /workspace
+# This path sometimes exists in CUDA images as a file/symlink. Ensure it's a real directory.
+RUN if [ -L /workspace ] || [ -f /workspace ]; then rm -f /workspace; fi && mkdir -p /workspaceAdditionally, consider moving this RUN to before the first instruction in this stage that references /workspace (ideally before WORKDIR/COPY to /workspace) so we guarantee correctness regardless of the base image state. You can quickly check all placements with: 🏁 Script executed: #!/bin/bash
rg -n --context 2 $'RUN .*rm -f /workspace' container/Dockerfile.vllmLength of output: 258 🏁 Script executed: #!/bin/bash
# Examine the stage up to the removal command for references to /workspace
echo "=== WORKDIR instructions before line 392 ==="
sed -n '1,392p' container/Dockerfile.vllm | grep -n 'WORKDIR /workspace' || echo "None found"
echo ""
echo "=== COPY instructions targeting /workspace before line 392 ==="
sed -n '1,392p' container/Dockerfile.vllm | grep -n -E 'COPY .* /workspace' || echo "None found"Length of output: 886 🏁 Script executed: #!/bin/bash
# List all stage start lines
echo "=== Stage boundaries ==="
grep -n '^FROM' container/Dockerfile.vllm
# Show context around removal to understand the stage
echo ""
echo "=== Context lines 360-430 ==="
sed -n '360,430p' container/Dockerfile.vllmLength of output: 2743 Use a recursive remove and relocate the cleanup before any COPY in the
Affected file:
Suggested diff: FROM base AS ci_minimum
ENV DYNAMO_HOME=/workspace
ENV CARGO_TARGET_DIR=/workspace/target
WORKDIR /workspace
-# This path exists from the base image, maintained by the CUDA team. Don't need it, so remove it.
-RUN rm -f /workspace && mkdir -p /workspace
+# Clean out any stale mount from the CUDA base image
+RUN rm -rf /workspace && mkdir -p /workspace
# Pull in the built wheels and cache
COPY --from=wheel_builder /workspace /workspace
COPY --from=wheel_builder $NIXL_PREFIX $NIXL_PREFIX
COPY --from=wheel_builder $CARGO_HOME $CARGO_HOME
# Copy the rest of the application source
COPY . /workspace🤖 Prompt for AI Agents |
||
| # Copy rest of the code | ||
| COPY . /workspace | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Same issue: rm -f on a directory fails; and this runs after prior COPYs
Make deletion conditional and always ensure the directory exists:
Also, move this RUN earlier in the stage (before the first WORKDIR/COPY to /workspace) to guarantee correctness across base images.
🏁 Script executed:
Length of output: 260
🏁 Script executed:
Length of output: 6467
Ensure
/workspaceis a real directory before any COPY/WORKDIR to avoidrm -ferrorsThe current
RUN rm -f /workspace && mkdir -p /workspace(container/Dockerfile.sglang:364–366) will always error once/workspaceexists as a directory (e.g., afterWORKDIRorCOPY). To fix:• Move the removal step to immediately after
FROM base AS ci_minimum(before anyWORKDIRorCOPY)• Conditionally remove only a file or symlink, then recreate the directory
Suggested diff in
container/Dockerfile.sglang:This guarantees
/workspaceis a directory (never a broken symlink or file) before you start copying in artifacts.🤖 Prompt for AI Agents