Repository navigation
[AIR] CNXT-2686: warn when a pushed image sets WORKDIR - #7867
vinchenzo-db wants to merge 6 commits into
Conversation
AI Runtime does not honor the Docker WORKDIR directive, so commands that rely on relative paths fail at runtime with file-not-found errors, and nothing warned at push time. `air images push` now inspects the source image's Config.WorkingDir and prints a warning telling the user to use absolute paths. The push itself is unchanged. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at 3031cd9. Each finding was verified against the code.
Not ready yet: 1 blocking issue(s), tagged [blocking].
This PR adds a WORKDIR warning to databricks air images push by inspecting the image config after the platform check. Two issues stand out: the "warning" can actually abort the push when the inspect subprocess fails, contradicting the stated non-blocking intent; and images that set WORKDIR / (effectively the default) trigger a misleading warning about relative paths.
An inspect failure now logs a warning instead of aborting, and WORKDIR / (the Docker default) no longer triggers the warning. Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at 42e16c3. Each finding was verified against the code.
No blocking issues found. 1 non-blocking comment(s) below.
This PR adds an informational WORKDIR warning to databricks air images push by inspecting the image config after the platform check. The implementation is correct and well-tested, but the new check spawns a second docker image inspect subprocess on the same image that was just inspected, when a single call with a combined format string would suffice.
Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at d48fc7f. Each finding was verified against the code.
No blocking issues found.
This PR adds a WORKDIR warning to databricks air images push by extending the existing docker image inspect format string to also retrieve Config.WorkingDir, then printing an informational warning when a non-trivial WORKDIR is set. The change is small, well-scoped, and covered by new and updated unit tests. No correctness issues survive verification.
Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
|
Commit: Regression test reportSelected 1 changed tests (limit=20, 0 not selected) 1 tests: regression=1 unreleased=0 coverage=0 failing=0
TestAccept/air/image-push: branch ✅ | main (1ea5591) ❌ | latest (v1.27.0) ❌main (1ea5591): latest (v1.27.0): same output as main (1ea5591) |
There was a problem hiding this comment.
Automated review at 0f620d5. Each finding was verified against the code.
No blocking issues found.
This PR adds an informational warning to databricks air images push when the source image sets a non-default WORKDIR, since AI Runtime ignores it at runtime. The implementation correctly extends the existing docker image inspect format string with a pipe-delimited field and parses it with strings.Cut on the first |. The warning condition (workingDir != "" && workingDir != "/") is sound, the comment on line 209 explains the rationale, and the unit and acceptance tests cover the key cases (unset, /, /app). No correctness issues found.
✅ Integration test reportCommit: 0f620d5
Top 3 slowest tests (at least 2 minutes):
|
The CLI shouldn't state how AI Runtime behaves, since the backend can change that. Say the image sets WORKDIR and that commands should use absolute paths. Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at ec6a35c. Each finding was verified against the code.
No blocking issues found. 2 non-blocking comment(s) below.
This PR makes databricks air images push read Config.WorkingDir from the existing docker image inspect call and print an informational warning when the source image sets a WORKDIR other than /. The push still goes through. The parsing and platform check look correct: the format string always includes |, so strings.Cut splits reliably, and the platform error behaves as before. I have two small points: the new unit test mostly repeats the acceptance coverage, and the comment above the skip condition says more than the code knows.
| if args[0] == "image" && args[1] == "inspect" { | ||
| _, err := io.WriteString(out, "linux/amd64\n") | ||
| _, err := io.WriteString(out, "linux/amd64|\n") | ||
| return err |
There was a problem hiding this comment.
[nice to have] TestRunImagePushWarnsWhenImageSetsWorkingDir checks user-visible stderr by stubbing configureDocker, lookPath and every runCommand call. .agents/rules/testing.md points that kind of test at acceptance tests. Its set and unset cases already appear in acceptance/air/image-push: the new workdir mode shows the warning, and the default mode's golden output has none. Only the / case is new coverage. Could you add a / mode to the fake docker script (e.g. printf 'linux/amd64|/\n') and drop this test, or cut it down to the / case? The same applies to the NotContains("WORKDIR") assertion at line 163.
| if platform != airImagePlatform { | ||
| return fmt.Errorf("source image %s has platform %q; AIR requires %s: use --pull to fetch a compatible image, or rebuild the source for %s", resolved.source, platform, airImagePlatform, airImagePlatform) | ||
| } | ||
| // / is Docker's default WORKDIR and cannot break relative paths. |
There was a problem hiding this comment.
[nit] The condition below skips both an empty WorkingDir (no WORKDIR in the image) and /, but the comment only mentions /. Its claim that / "cannot break relative paths" is about where AI Runtime starts the process, which the PR says the CLI doesn't know. Something like "Skip the warning when WORKDIR is unset or /: docker run starts in / for both, so relative paths are least likely to depend on it" would say what is actually decided.
Changes
databricks air images pushnow readsConfig.WorkingDirfrom the existingdocker image inspectcall (combined format string). When it is set to anything other than/, it prints a warning that the source image setsWORKDIRand that commands and scripts should use absolute paths. The warning makes no claim about how AI Runtime treatsWORKDIR, because the backend owns that behavior and can change it without a CLI release. The push itself is unchanged: the warning is informational and never blocks.Why
In the CUJ PE64 runthrough (Jira CNXT-2686), an image whose scripts relied on relative paths from its
WORKDIRworked underdocker runbut failed on AI Runtime with file-not-found errors. Neitherair images pushnorair runmentioned this, so users only found out from a failed run.Push time is the earliest point where the CLI sees the image config, and the check reuses the inspect call the platform check already makes, so there is no extra Docker invocation. No public AI Runtime docs page covers the runtime working directory yet, so the warning doesn't link one.
Hard-coded values
~/loop/bin/cli-checkflags one line: the existingAIR requires linux/amd64platform error incmd/air/image.go. It is already onmain; this PR only moves it, because the inspect call now returns the platform andWORKDIRtogether. Nothing new is hard-coded.Tests
TestRunImagePushWarnsWhenImageSetsWorkingDir(table: unset,/,/app) checks the warning fires only for a realWORKDIR.TestRunImagePushTagsAndPushesLocalImageasserts the combined inspect format and no warning for an image withoutWORKDIR.acceptance/air/image-pushgained aworkdirfake-docker mode and a step showing the warning while the push proceeds; golden output regenerated.go test ./cmd/air,go test ./acceptance -run TestAccept/air/image-push, andtask check-changelogpass locally.This pull request and its description were written by Isaac.