From 81b006ef03eb57545e9a33cb7b4ec9a87d288986 Mon Sep 17 00:00:00 2001 From: "v.chen" Date: Sat, 21 Nov 2026 05:21:24 +0000 Subject: [PATCH 01/10] air: check the source image size against the 20 GB limit before pushing `databricks air images push` now inspects the local image size after the platform check, prints it, and fails before tagging or uploading when it exceeds AI Runtime's 20 GB maximum, with the server's message plus advice to start from a Databricks base image and trim layers (CNXT-2687). Co-authored-by: Isaac --- acceptance/air/image-push/docker | 9 ++++ acceptance/air/image-push/output.txt | 23 ++++++++++ acceptance/air/image-push/script | 4 ++ cmd/air/image.go | 17 +++++++ cmd/air/image_test.go | 69 ++++++++++++++++++++++++++-- 5 files changed, 119 insertions(+), 3 deletions(-) diff --git a/acceptance/air/image-push/docker b/acceptance/air/image-push/docker index 0303d011bdf..847f2833aec 100644 --- a/acceptance/air/image-push/docker +++ b/acceptance/air/image-push/docker @@ -18,6 +18,15 @@ case "$1 $2" in printf 'Docker inspect failed\n' >&2 exit 1 ;; + esac + if [ "$4" = "{{.Size}}" ]; then + case "$DOCKER_TEST_MODE" in + oversized) printf '25300000000\n' ;; + *) printf '7140000000\n' ;; + esac + exit 0 + fi + case "$DOCKER_TEST_MODE" in arm64) printf 'linux/arm64\n' ;; *) printf 'linux/amd64\n' ;; esac diff --git a/acceptance/air/image-push/output.txt b/acceptance/air/image-push/output.txt index 07d4a23b770..85ed025ab6b 100644 --- a/acceptance/air/image-push/output.txt +++ b/acceptance/air/image-push/output.txt @@ -8,6 +8,7 @@ Configured Docker credential helper for [WORKSPACE_ID].container.us-west-2.local Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Using local source image nvidia/cuda:13.4.1 +Source image nvidia/cuda:13.4.1 is 7.1 GB; AI Runtime allows up to 20 GB. Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 Docker push progress @@ -32,6 +33,7 @@ Now you can set `environment.unity_catalog_image = my-catalog.my-schema.cuda:13. === docker commands image ls --quiet nvidia/cuda:13.4.1 image inspect --format {{.Os}}/{{.Architecture}} nvidia/cuda:13.4.1 +image inspect --format {{.Size}} nvidia/cuda:13.4.1 tag nvidia/cuda:13.4.1 [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 push [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 @@ -45,6 +47,7 @@ Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Pulling source image example/image:v1 for linux/amd64 Docker pull progress +Source image example/image:v1 is 7.1 GB; AI Runtime allows up to 20 GB. Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Docker push progress @@ -61,6 +64,7 @@ Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Pulling source image example/image:v1 for linux/amd64 Docker pull progress +Source image example/image:v1 is 7.1 GB; AI Runtime allows up to 20 GB. Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Docker push progress @@ -121,6 +125,18 @@ Pulling source image example/image:v1 for linux/amd64 Docker pull progress Error: source image example/image:v1 has platform "linux/arm64"; AIR requires linux/amd64: use --pull to fetch a compatible image, or rebuild the source for linux/amd64 +=== oversized image must not be pushed + +>>> musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training +Warning: This feature is in Preview. APIs may change, and the workspace must enable the Preview features. +Pushing example/image:v1 as main.training.image:v1 using profile docker-test +Configured Docker credential helper for [WORKSPACE_ID].container.us-west-2.localhost +Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json +Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks +Using local source image example/image:v1 +Source image example/image:v1 is 25.3 GB; AI Runtime allows up to 20 GB. +Error: image size (25.3GB) exceeds maximum allowed size (20GB): start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches + === pull failure must not be pushed >>> musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training --pull @@ -194,15 +210,18 @@ Error: invalid image repository name: catalog.schema.artifact must be 255 charac === all docker commands image ls --quiet nvidia/cuda:13.4.1 image inspect --format {{.Os}}/{{.Architecture}} nvidia/cuda:13.4.1 +image inspect --format {{.Size}} nvidia/cuda:13.4.1 tag nvidia/cuda:13.4.1 [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 push [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 image ls --quiet example/image:v1 pull --platform linux/amd64 example/image:v1 image inspect --format {{.Os}}/{{.Architecture}} example/image:v1 +image inspect --format {{.Size}} example/image:v1 tag example/image:v1 [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 push [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 pull --platform linux/amd64 example/image:v1 image inspect --format {{.Os}}/{{.Architecture}} example/image:v1 +image inspect --format {{.Size}} example/image:v1 tag example/image:v1 [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 push [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 image ls --quiet example/image:v1 @@ -212,6 +231,9 @@ image ls --quiet example/image:v1 image inspect --format {{.Os}}/{{.Architecture}} example/image:v1 pull --platform linux/amd64 example/image:v1 image inspect --format {{.Os}}/{{.Architecture}} example/image:v1 +image ls --quiet example/image:v1 +image inspect --format {{.Os}}/{{.Architecture}} example/image:v1 +image inspect --format {{.Size}} example/image:v1 pull --platform linux/amd64 example/image:v1 === in a Claude Code session the auth docker configure child adds no install hint @@ -225,6 +247,7 @@ Configured Docker credential helper for [WORKSPACE_ID].container.us-west-2.local Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Using local source image example/image:v1 +Source image example/image:v1 is 7.1 GB; AI Runtime allows up to 20 GB. Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Docker push progress diff --git a/acceptance/air/image-push/script b/acceptance/air/image-push/script index a0343b728ab..d425b2d0f68 100644 --- a/acceptance/air/image-push/script +++ b/acceptance/air/image-push/script @@ -43,6 +43,10 @@ trace musterr databricks air images push -p docker-test -s example/image:v1 --ca title "incompatible pulled image must not be pushed" trace musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training --pull +title "oversized image must not be pushed" +export DOCKER_TEST_MODE=oversized +trace musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training + title "pull failure must not be pushed" export DOCKER_TEST_MODE=pull-error trace musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training --pull diff --git a/cmd/air/image.go b/cmd/air/image.go index 68bd8d0e9ca..d05ff7259a7 100644 --- a/cmd/air/image.go +++ b/cmd/air/image.go @@ -9,6 +9,7 @@ import ( "os" "os/exec" "regexp" + "strconv" "strings" "sync" @@ -24,6 +25,8 @@ const ( maxImageRepositoryLength = 255 maxImageTagLength = 128 airImagePlatform = "linux/amd64" + // AI Runtime rejects images over this many decimal gigabytes, the unit Docker reports sizes in. + maxImageSizeGB = 20 ) var ( @@ -206,6 +209,20 @@ func runImagePush(cmd *cobra.Command, opts *imagePushOptions, deps imagePushDeps 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, got, airImagePlatform, airImagePlatform) } + var size bytes.Buffer + if err := deps.runCommand(ctx, nil, &size, cmd.ErrOrStderr(), dockerPath, "image", "inspect", "--format", "{{.Size}}", resolved.source); err != nil { + return fmt.Errorf("inspect size of source image %s: %w", resolved.source, err) + } + sizeBytes, err := strconv.ParseInt(strings.TrimSpace(size.String()), 10, 64) + if err != nil { + return fmt.Errorf("parse size of source image %s: %w", resolved.source, err) + } + sizeGB := float64(sizeBytes) / 1e9 + cmdio.LogString(ctx, fmt.Sprintf("Source image %s is %.1f GB; AI Runtime allows up to %d GB.", resolved.source, sizeGB, maxImageSizeGB)) + if sizeGB > maxImageSizeGB { + return fmt.Errorf("image size (%.1fGB) exceeds maximum allowed size (%dGB): start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches", sizeGB, maxImageSizeGB) + } + cmdio.LogProgress(ctx, "Tagging image as "+target) if err := deps.runCommand(ctx, cmd.InOrStdin(), cmd.ErrOrStderr(), cmd.ErrOrStderr(), dockerPath, "tag", resolved.source, target); err != nil { return fmt.Errorf("tag source image %s: %w", resolved.source, err) diff --git a/cmd/air/image_test.go b/cmd/air/image_test.go index 12e72c1f0cc..5ce3a3208b4 100644 --- a/cmd/air/image_test.go +++ b/cmd/air/image_test.go @@ -56,7 +56,7 @@ func TestRunImagePushTagsAndPushesLocalImage(t *testing.T) { _, err := io.WriteString(out, "image-id\n") return err case "image inspect": - _, err := io.WriteString(out, "linux/amd64\n") + _, err := io.WriteString(out, fakeImageInspect(args[3], "7140000000")) return err } return nil @@ -75,6 +75,7 @@ func TestRunImagePushTagsAndPushesLocalImage(t *testing.T) { assert.Equal(t, []recordedImageCommand{ {executable: "/usr/bin/docker", args: []string{"image", "ls", "--quiet", "nvidia/cuda:13.4.1"}}, {executable: "/usr/bin/docker", args: []string{"image", "inspect", "--format", "{{.Os}}/{{.Architecture}}", "nvidia/cuda:13.4.1"}}, + {executable: "/usr/bin/docker", args: []string{"image", "inspect", "--format", "{{.Size}}", "nvidia/cuda:13.4.1"}}, {executable: "/usr/bin/docker", args: []string{"tag", "nvidia/cuda:13.4.1", target}}, {executable: "/usr/bin/docker", args: []string{"push", target}}, }, commands) @@ -84,9 +85,71 @@ func TestRunImagePushTagsAndPushesLocalImage(t *testing.T) { ) stderrLines := strings.Split(stderr.String(), "\n") assert.Equal(t, "Warning: This feature is in Preview. APIs may change, and the workspace must enable the Preview features.", stderrLines[0]) + assert.Contains(t, stderr.String(), "Source image nvidia/cuda:13.4.1 is 7.1 GB; AI Runtime allows up to 20 GB.") assert.Contains(t, stderr.String(), "Pushed image") } +// fakeImageInspect answers the two docker image inspect formats runImagePush uses. +func fakeImageInspect(format, sizeBytes string) string { + if format == "{{.Size}}" { + return sizeBytes + "\n" + } + return "linux/amd64\n" +} + +func TestRunImagePushRejectsOversizedImage(t *testing.T) { + tests := []struct { + name string + sizeBytes string + wantErr string + }{ + {name: "at limit", sizeBytes: "20000000000"}, + {name: "over limit", sizeBytes: "20000000001", wantErr: "image size (20.0GB) exceeds maximum allowed size (20GB): start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches"}, + {name: "unreadable", sizeBytes: "unknown", wantErr: "parse size of source image example/trainer:v1"}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + cmd, _, stderr := newImagePushTestCommand(t, "workspace") + var commands []recordedImageCommand + deps := imagePushDeps{ + configureDocker: func(context.Context, string) (string, error) { + return "123.container.us-west-2.cloud.databricks.test", nil + }, + lookPath: func(string) (string, error) { return "docker", nil }, + runCommand: func(_ context.Context, _ io.Reader, out, _ io.Writer, executable string, args ...string) error { + commands = append(commands, recordedImageCommand{executable: executable, args: args}) + switch strings.Join(args[:2], " ") { + case "image ls": + _, err := io.WriteString(out, "image-id\n") + return err + case "image inspect": + _, err := io.WriteString(out, fakeImageInspect(args[3], tt.sizeBytes)) + return err + } + return nil + }, + } + + err := runImagePush(cmd, &imagePushOptions{ + source: "example/trainer:v1", + catalog: "main", + schema: "training", + artifact: "trainer", + }, deps) + if tt.wantErr == "" { + require.NoError(t, err) + assert.Contains(t, stderr.String(), "Source image example/trainer:v1 is 20.0 GB; AI Runtime allows up to 20 GB.") + assert.Contains(t, stderr.String(), "Pushed image") + return + } + require.ErrorContains(t, err, tt.wantErr) + for _, command := range commands { + assert.NotContains(t, []string{"tag", "push"}, command.args[0], "oversized image must not be tagged or pushed") + } + }) + } +} + func TestRegistryHostFromDockerConfigureOutput(t *testing.T) { output := `Configured Docker credential helper for 123.container.us-west-2.cloud.databricks.test Updated Docker config: /tmp/docker/config.json @@ -111,7 +174,7 @@ func TestRunImagePushPullsMissingImage(t *testing.T) { runCommand: func(_ context.Context, _ io.Reader, out, _ io.Writer, executable string, args ...string) error { commands = append(commands, recordedImageCommand{executable: executable, args: args}) if args[0] == "image" && args[1] == "inspect" { - _, err := io.WriteString(out, "linux/amd64\n") + _, err := io.WriteString(out, fakeImageInspect(args[3], "7140000000")) return err } return nil @@ -126,7 +189,7 @@ func TestRunImagePushPullsMissingImage(t *testing.T) { }, deps) require.NoError(t, err) - require.Len(t, commands, 5) + require.Len(t, commands, 6) assert.Equal(t, []string{"pull", "--platform", "linux/amd64", "example/image:v1"}, commands[1].args) } From 2955011362efff0431e7cc5920fe72eb3997b765 Mon Sep 17 00:00:00 2001 From: "v.chen" Date: Sat, 21 Nov 2026 05:22:00 +0000 Subject: [PATCH 02/10] air: add changelog fragment for the image size check (#7868) Co-authored-by: Isaac --- .nextchanges/air/images-push-size-limit.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 .nextchanges/air/images-push-size-limit.md diff --git a/.nextchanges/air/images-push-size-limit.md b/.nextchanges/air/images-push-size-limit.md new file mode 100644 index 00000000000..3e3069c3b4c --- /dev/null +++ b/.nextchanges/air/images-push-size-limit.md @@ -0,0 +1 @@ +* Check the source image size in `databricks air images push` before uploading, print it, and fail with the 20 GB limit and advice to start from a Databricks base image and trim layers when the image exceeds it. ([#7868](https://github.com/databricks/cli/pull/7868)) From 60ee76974e85e96aec87bf6e31e4d6889f292ab4 Mon Sep 17 00:00:00 2001 From: "v.chen" Date: Sat, 21 Nov 2026 05:28:07 +0000 Subject: [PATCH 03/10] air: warn instead of failing when the local image exceeds 20 GB Docker reports the uncompressed size while the server measures compressed layers, so an oversized local image may still be accepted: print the size, warn with the limit and advice, and let the push proceed. Co-authored-by: Isaac --- .nextchanges/air/images-push-size-limit.md | 2 +- acceptance/air/image-push/output.txt | 23 +++++++++++------ acceptance/air/image-push/script | 4 +-- cmd/air/image.go | 6 +++-- cmd/air/image_test.go | 30 ++++++++++++---------- 5 files changed, 39 insertions(+), 26 deletions(-) diff --git a/.nextchanges/air/images-push-size-limit.md b/.nextchanges/air/images-push-size-limit.md index 3e3069c3b4c..22e626cee43 100644 --- a/.nextchanges/air/images-push-size-limit.md +++ b/.nextchanges/air/images-push-size-limit.md @@ -1 +1 @@ -* Check the source image size in `databricks air images push` before uploading, print it, and fail with the 20 GB limit and advice to start from a Databricks base image and trim layers when the image exceeds it. ([#7868](https://github.com/databricks/cli/pull/7868)) +* Print the source image size in `databricks air images push` before uploading, and warn with the 20 GB limit and advice to start from a Databricks base image and trim layers when the local image exceeds it. ([#7868](https://github.com/databricks/cli/pull/7868)) diff --git a/acceptance/air/image-push/output.txt b/acceptance/air/image-push/output.txt index 85ed025ab6b..1eb9ba7d244 100644 --- a/acceptance/air/image-push/output.txt +++ b/acceptance/air/image-push/output.txt @@ -8,7 +8,7 @@ Configured Docker credential helper for [WORKSPACE_ID].container.us-west-2.local Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Using local source image nvidia/cuda:13.4.1 -Source image nvidia/cuda:13.4.1 is 7.1 GB; AI Runtime allows up to 20 GB. +Source image nvidia/cuda:13.4.1 is 7.1 GB uncompressed; AI Runtime allows up to 20 GB compressed. Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 Docker push progress @@ -47,7 +47,7 @@ Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Pulling source image example/image:v1 for linux/amd64 Docker pull progress -Source image example/image:v1 is 7.1 GB; AI Runtime allows up to 20 GB. +Source image example/image:v1 is 7.1 GB uncompressed; AI Runtime allows up to 20 GB compressed. Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Docker push progress @@ -64,7 +64,7 @@ Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Pulling source image example/image:v1 for linux/amd64 Docker pull progress -Source image example/image:v1 is 7.1 GB; AI Runtime allows up to 20 GB. +Source image example/image:v1 is 7.1 GB uncompressed; AI Runtime allows up to 20 GB compressed. Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Docker push progress @@ -125,17 +125,22 @@ Pulling source image example/image:v1 for linux/amd64 Docker pull progress Error: source image example/image:v1 has platform "linux/arm64"; AIR requires linux/amd64: use --pull to fetch a compatible image, or rebuild the source for linux/amd64 -=== oversized image must not be pushed +=== oversized image warns but is pushed ->>> musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training +>>> databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training Warning: This feature is in Preview. APIs may change, and the workspace must enable the Preview features. Pushing example/image:v1 as main.training.image:v1 using profile docker-test Configured Docker credential helper for [WORKSPACE_ID].container.us-west-2.localhost Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Using local source image example/image:v1 -Source image example/image:v1 is 25.3 GB; AI Runtime allows up to 20 GB. -Error: image size (25.3GB) exceeds maximum allowed size (20GB): start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches +Source image example/image:v1 is 25.3 GB uncompressed; AI Runtime allows up to 20 GB compressed. +Warning: source image example/image:v1 exceeds 20 GB uncompressed, so the push may be rejected: start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches. +Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 +Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 +Docker push progress +Pushed image. +Now you can set `environment.unity_catalog_image = main.training.image:v1` in your YAML config and create a workload with `databricks air run -f config.yaml`. === pull failure must not be pushed @@ -234,6 +239,8 @@ image inspect --format {{.Os}}/{{.Architecture}} example/image:v1 image ls --quiet example/image:v1 image inspect --format {{.Os}}/{{.Architecture}} example/image:v1 image inspect --format {{.Size}} example/image:v1 +tag example/image:v1 [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 +push [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 pull --platform linux/amd64 example/image:v1 === in a Claude Code session the auth docker configure child adds no install hint @@ -247,7 +254,7 @@ Configured Docker credential helper for [WORKSPACE_ID].container.us-west-2.local Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Using local source image example/image:v1 -Source image example/image:v1 is 7.1 GB; AI Runtime allows up to 20 GB. +Source image example/image:v1 is 7.1 GB uncompressed; AI Runtime allows up to 20 GB compressed. Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Docker push progress diff --git a/acceptance/air/image-push/script b/acceptance/air/image-push/script index d425b2d0f68..3b34ce6c2aa 100644 --- a/acceptance/air/image-push/script +++ b/acceptance/air/image-push/script @@ -43,9 +43,9 @@ trace musterr databricks air images push -p docker-test -s example/image:v1 --ca title "incompatible pulled image must not be pushed" trace musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training --pull -title "oversized image must not be pushed" +title "oversized image warns but is pushed" export DOCKER_TEST_MODE=oversized -trace musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training +trace databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training title "pull failure must not be pushed" export DOCKER_TEST_MODE=pull-error diff --git a/cmd/air/image.go b/cmd/air/image.go index d05ff7259a7..fe9afe9f7e4 100644 --- a/cmd/air/image.go +++ b/cmd/air/image.go @@ -218,9 +218,11 @@ func runImagePush(cmd *cobra.Command, opts *imagePushOptions, deps imagePushDeps return fmt.Errorf("parse size of source image %s: %w", resolved.source, err) } sizeGB := float64(sizeBytes) / 1e9 - cmdio.LogString(ctx, fmt.Sprintf("Source image %s is %.1f GB; AI Runtime allows up to %d GB.", resolved.source, sizeGB, maxImageSizeGB)) + cmdio.LogString(ctx, fmt.Sprintf("Source image %s is %.1f GB uncompressed; AI Runtime allows up to %d GB compressed.", resolved.source, sizeGB, maxImageSizeGB)) + // Docker reports the uncompressed size while the server measures compressed layers, + // so an oversized local image may still be accepted: warn instead of failing. if sizeGB > maxImageSizeGB { - return fmt.Errorf("image size (%.1fGB) exceeds maximum allowed size (%dGB): start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches", sizeGB, maxImageSizeGB) + cmdio.LogString(ctx, fmt.Sprintf("Warning: source image %s exceeds %d GB uncompressed, so the push may be rejected: start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches.", resolved.source, maxImageSizeGB)) } cmdio.LogProgress(ctx, "Tagging image as "+target) diff --git a/cmd/air/image_test.go b/cmd/air/image_test.go index 5ce3a3208b4..719e36c5534 100644 --- a/cmd/air/image_test.go +++ b/cmd/air/image_test.go @@ -85,7 +85,8 @@ func TestRunImagePushTagsAndPushesLocalImage(t *testing.T) { ) stderrLines := strings.Split(stderr.String(), "\n") assert.Equal(t, "Warning: This feature is in Preview. APIs may change, and the workspace must enable the Preview features.", stderrLines[0]) - assert.Contains(t, stderr.String(), "Source image nvidia/cuda:13.4.1 is 7.1 GB; AI Runtime allows up to 20 GB.") + assert.Contains(t, stderr.String(), "Source image nvidia/cuda:13.4.1 is 7.1 GB uncompressed; AI Runtime allows up to 20 GB compressed.") + assert.NotContains(t, stderr.String(), "Warning: source image") assert.Contains(t, stderr.String(), "Pushed image") } @@ -97,27 +98,27 @@ func fakeImageInspect(format, sizeBytes string) string { return "linux/amd64\n" } -func TestRunImagePushRejectsOversizedImage(t *testing.T) { +func TestRunImagePushWarnsAboutOversizedImage(t *testing.T) { + warning := "Warning: source image example/trainer:v1 exceeds 20 GB uncompressed, so the push may be rejected: start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches." tests := []struct { name string sizeBytes string + warn bool wantErr string }{ {name: "at limit", sizeBytes: "20000000000"}, - {name: "over limit", sizeBytes: "20000000001", wantErr: "image size (20.0GB) exceeds maximum allowed size (20GB): start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches"}, + {name: "over limit", sizeBytes: "25300000000", warn: true}, {name: "unreadable", sizeBytes: "unknown", wantErr: "parse size of source image example/trainer:v1"}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cmd, _, stderr := newImagePushTestCommand(t, "workspace") - var commands []recordedImageCommand deps := imagePushDeps{ configureDocker: func(context.Context, string) (string, error) { return "123.container.us-west-2.cloud.databricks.test", nil }, lookPath: func(string) (string, error) { return "docker", nil }, - runCommand: func(_ context.Context, _ io.Reader, out, _ io.Writer, executable string, args ...string) error { - commands = append(commands, recordedImageCommand{executable: executable, args: args}) + runCommand: func(_ context.Context, _ io.Reader, out, _ io.Writer, _ string, args ...string) error { switch strings.Join(args[:2], " ") { case "image ls": _, err := io.WriteString(out, "image-id\n") @@ -136,16 +137,19 @@ func TestRunImagePushRejectsOversizedImage(t *testing.T) { schema: "training", artifact: "trainer", }, deps) - if tt.wantErr == "" { - require.NoError(t, err) - assert.Contains(t, stderr.String(), "Source image example/trainer:v1 is 20.0 GB; AI Runtime allows up to 20 GB.") - assert.Contains(t, stderr.String(), "Pushed image") + if tt.wantErr != "" { + require.ErrorContains(t, err, tt.wantErr) + assert.NotContains(t, stderr.String(), "Pushed image") return } - require.ErrorContains(t, err, tt.wantErr) - for _, command := range commands { - assert.NotContains(t, []string{"tag", "push"}, command.args[0], "oversized image must not be tagged or pushed") + require.NoError(t, err) + if tt.warn { + assert.Contains(t, stderr.String(), "Source image example/trainer:v1 is 25.3 GB uncompressed; AI Runtime allows up to 20 GB compressed.") + assert.Contains(t, stderr.String(), warning) + } else { + assert.NotContains(t, stderr.String(), "Warning: source image") } + assert.Contains(t, stderr.String(), "Pushed image") }) } } From 8d625d41dec10e4f403e2d56a5e55b19c97b7291 Mon Sep 17 00:00:00 2001 From: "v.chen" Date: Sat, 21 Nov 2026 05:37:37 +0000 Subject: [PATCH 04/10] air: read the image size from the existing inspect and keep it advisory Fold {{.Size}} into the platform inspect so no second docker process is spawned, and warn instead of failing when the size cannot be parsed, since the size check never gates the push. Co-authored-by: Isaac --- acceptance/air/image-push/docker | 14 ++------ acceptance/air/image-push/output.txt | 21 +++++------- cmd/air/image.go | 32 ++++++++----------- cmd/air/image_test.go | 48 +++++++++++++--------------- 4 files changed, 47 insertions(+), 68 deletions(-) diff --git a/acceptance/air/image-push/docker b/acceptance/air/image-push/docker index 847f2833aec..974c817e9cb 100644 --- a/acceptance/air/image-push/docker +++ b/acceptance/air/image-push/docker @@ -18,17 +18,9 @@ case "$1 $2" in printf 'Docker inspect failed\n' >&2 exit 1 ;; - esac - if [ "$4" = "{{.Size}}" ]; then - case "$DOCKER_TEST_MODE" in - oversized) printf '25300000000\n' ;; - *) printf '7140000000\n' ;; - esac - exit 0 - fi - case "$DOCKER_TEST_MODE" in - arm64) printf 'linux/arm64\n' ;; - *) printf 'linux/amd64\n' ;; + arm64) printf 'linux/arm64|7140000000\n' ;; + oversized) printf 'linux/amd64|25300000000\n' ;; + *) printf 'linux/amd64|7140000000\n' ;; esac ;; pull\ *) diff --git a/acceptance/air/image-push/output.txt b/acceptance/air/image-push/output.txt index 1eb9ba7d244..b95a9b3f07b 100644 --- a/acceptance/air/image-push/output.txt +++ b/acceptance/air/image-push/output.txt @@ -32,8 +32,7 @@ Now you can set `environment.unity_catalog_image = my-catalog.my-schema.cuda:13. === docker commands image ls --quiet nvidia/cuda:13.4.1 -image inspect --format {{.Os}}/{{.Architecture}} nvidia/cuda:13.4.1 -image inspect --format {{.Size}} nvidia/cuda:13.4.1 +image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} nvidia/cuda:13.4.1 tag nvidia/cuda:13.4.1 [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 push [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 @@ -214,31 +213,27 @@ Error: invalid image repository name: catalog.schema.artifact must be 255 charac === all docker commands image ls --quiet nvidia/cuda:13.4.1 -image inspect --format {{.Os}}/{{.Architecture}} nvidia/cuda:13.4.1 -image inspect --format {{.Size}} nvidia/cuda:13.4.1 +image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} nvidia/cuda:13.4.1 tag nvidia/cuda:13.4.1 [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 push [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 image ls --quiet example/image:v1 pull --platform linux/amd64 example/image:v1 -image inspect --format {{.Os}}/{{.Architecture}} example/image:v1 -image inspect --format {{.Size}} example/image:v1 +image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 tag example/image:v1 [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 push [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 pull --platform linux/amd64 example/image:v1 -image inspect --format {{.Os}}/{{.Architecture}} example/image:v1 -image inspect --format {{.Size}} example/image:v1 +image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 tag example/image:v1 [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 push [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 image ls --quiet example/image:v1 image ls --quiet example/image:v1 -image inspect --format {{.Os}}/{{.Architecture}} example/image:v1 +image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 image ls --quiet example/image:v1 -image inspect --format {{.Os}}/{{.Architecture}} example/image:v1 +image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 pull --platform linux/amd64 example/image:v1 -image inspect --format {{.Os}}/{{.Architecture}} example/image:v1 +image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 image ls --quiet example/image:v1 -image inspect --format {{.Os}}/{{.Architecture}} example/image:v1 -image inspect --format {{.Size}} example/image:v1 +image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 tag example/image:v1 [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 push [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 pull --platform linux/amd64 example/image:v1 diff --git a/cmd/air/image.go b/cmd/air/image.go index fe9afe9f7e4..fc738a7f77c 100644 --- a/cmd/air/image.go +++ b/cmd/air/image.go @@ -201,28 +201,24 @@ func runImagePush(cmd *cobra.Command, opts *imagePushOptions, deps imagePushDeps cmdio.LogString(ctx, "Using local source image "+resolved.source) } - var platform bytes.Buffer - if err := deps.runCommand(ctx, nil, &platform, cmd.ErrOrStderr(), dockerPath, "image", "inspect", "--format", "{{.Os}}/{{.Architecture}}", resolved.source); err != nil { + var inspected bytes.Buffer + if err := deps.runCommand(ctx, nil, &inspected, cmd.ErrOrStderr(), dockerPath, "image", "inspect", "--format", "{{.Os}}/{{.Architecture}}|{{.Size}}", resolved.source); err != nil { return fmt.Errorf("inspect source image %s: %w", resolved.source, err) } - if got := strings.TrimSpace(platform.String()); got != 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, got, airImagePlatform, airImagePlatform) + platform, size, _ := strings.Cut(strings.TrimSpace(inspected.String()), "|") + 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) } - - var size bytes.Buffer - if err := deps.runCommand(ctx, nil, &size, cmd.ErrOrStderr(), dockerPath, "image", "inspect", "--format", "{{.Size}}", resolved.source); err != nil { - return fmt.Errorf("inspect size of source image %s: %w", resolved.source, err) - } - sizeBytes, err := strconv.ParseInt(strings.TrimSpace(size.String()), 10, 64) - if err != nil { - return fmt.Errorf("parse size of source image %s: %w", resolved.source, err) - } - sizeGB := float64(sizeBytes) / 1e9 - cmdio.LogString(ctx, fmt.Sprintf("Source image %s is %.1f GB uncompressed; AI Runtime allows up to %d GB compressed.", resolved.source, sizeGB, maxImageSizeGB)) // Docker reports the uncompressed size while the server measures compressed layers, - // so an oversized local image may still be accepted: warn instead of failing. - if sizeGB > maxImageSizeGB { - cmdio.LogString(ctx, fmt.Sprintf("Warning: source image %s exceeds %d GB uncompressed, so the push may be rejected: start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches.", resolved.source, maxImageSizeGB)) + // so the size is advisory: an oversized or unreadable size never blocks the push. + if sizeBytes, err := strconv.ParseInt(size, 10, 64); err != nil { + cmdio.LogString(ctx, fmt.Sprintf("Warning: could not read the size of source image %s: %v", resolved.source, err)) + } else { + sizeGB := float64(sizeBytes) / 1e9 + cmdio.LogString(ctx, fmt.Sprintf("Source image %s is %.1f GB uncompressed; AI Runtime allows up to %d GB compressed.", resolved.source, sizeGB, maxImageSizeGB)) + if sizeGB > maxImageSizeGB { + cmdio.LogString(ctx, fmt.Sprintf("Warning: source image %s exceeds %d GB uncompressed, so the push may be rejected: start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches.", resolved.source, maxImageSizeGB)) + } } cmdio.LogProgress(ctx, "Tagging image as "+target) diff --git a/cmd/air/image_test.go b/cmd/air/image_test.go index 719e36c5534..26368e7642d 100644 --- a/cmd/air/image_test.go +++ b/cmd/air/image_test.go @@ -56,7 +56,7 @@ func TestRunImagePushTagsAndPushesLocalImage(t *testing.T) { _, err := io.WriteString(out, "image-id\n") return err case "image inspect": - _, err := io.WriteString(out, fakeImageInspect(args[3], "7140000000")) + _, err := io.WriteString(out, fakeImageInspect("7140000000")) return err } return nil @@ -74,8 +74,7 @@ func TestRunImagePushTagsAndPushesLocalImage(t *testing.T) { target := "123.container.us-west-2.cloud.databricks.test/main.training.cuda:13.4.1" assert.Equal(t, []recordedImageCommand{ {executable: "/usr/bin/docker", args: []string{"image", "ls", "--quiet", "nvidia/cuda:13.4.1"}}, - {executable: "/usr/bin/docker", args: []string{"image", "inspect", "--format", "{{.Os}}/{{.Architecture}}", "nvidia/cuda:13.4.1"}}, - {executable: "/usr/bin/docker", args: []string{"image", "inspect", "--format", "{{.Size}}", "nvidia/cuda:13.4.1"}}, + {executable: "/usr/bin/docker", args: []string{"image", "inspect", "--format", "{{.Os}}/{{.Architecture}}|{{.Size}}", "nvidia/cuda:13.4.1"}}, {executable: "/usr/bin/docker", args: []string{"tag", "nvidia/cuda:13.4.1", target}}, {executable: "/usr/bin/docker", args: []string{"push", target}}, }, commands) @@ -90,25 +89,21 @@ func TestRunImagePushTagsAndPushesLocalImage(t *testing.T) { assert.Contains(t, stderr.String(), "Pushed image") } -// fakeImageInspect answers the two docker image inspect formats runImagePush uses. -func fakeImageInspect(format, sizeBytes string) string { - if format == "{{.Size}}" { - return sizeBytes + "\n" - } - return "linux/amd64\n" +// fakeImageInspect answers the docker image inspect format runImagePush uses for a linux/amd64 image. +func fakeImageInspect(sizeBytes string) string { + return "linux/amd64|" + sizeBytes + "\n" } func TestRunImagePushWarnsAboutOversizedImage(t *testing.T) { - warning := "Warning: source image example/trainer:v1 exceeds 20 GB uncompressed, so the push may be rejected: start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches." + oversized := "Warning: source image example/trainer:v1 exceeds 20 GB uncompressed, so the push may be rejected: start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches." tests := []struct { name string sizeBytes string - warn bool - wantErr string + warning string }{ {name: "at limit", sizeBytes: "20000000000"}, - {name: "over limit", sizeBytes: "25300000000", warn: true}, - {name: "unreadable", sizeBytes: "unknown", wantErr: "parse size of source image example/trainer:v1"}, + {name: "over limit", sizeBytes: "25300000000", warning: oversized}, + {name: "unreadable", sizeBytes: "unknown", warning: "Warning: could not read the size of source image example/trainer:v1: strconv.ParseInt: parsing \"unknown\": invalid syntax"}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -124,7 +119,7 @@ func TestRunImagePushWarnsAboutOversizedImage(t *testing.T) { _, err := io.WriteString(out, "image-id\n") return err case "image inspect": - _, err := io.WriteString(out, fakeImageInspect(args[3], tt.sizeBytes)) + _, err := io.WriteString(out, fakeImageInspect(tt.sizeBytes)) return err } return nil @@ -137,17 +132,18 @@ func TestRunImagePushWarnsAboutOversizedImage(t *testing.T) { schema: "training", artifact: "trainer", }, deps) - if tt.wantErr != "" { - require.ErrorContains(t, err, tt.wantErr) - assert.NotContains(t, stderr.String(), "Pushed image") - return - } require.NoError(t, err) - if tt.warn { - assert.Contains(t, stderr.String(), "Source image example/trainer:v1 is 25.3 GB uncompressed; AI Runtime allows up to 20 GB compressed.") - assert.Contains(t, stderr.String(), warning) - } else { + switch tt.warning { + case "": + assert.Contains(t, stderr.String(), "Source image example/trainer:v1 is 20.0 GB uncompressed; AI Runtime allows up to 20 GB compressed.") assert.NotContains(t, stderr.String(), "Warning: source image") + assert.NotContains(t, stderr.String(), "could not read the size") + case oversized: + assert.Contains(t, stderr.String(), "Source image example/trainer:v1 is 25.3 GB uncompressed; AI Runtime allows up to 20 GB compressed.") + assert.Contains(t, stderr.String(), oversized) + default: + assert.Contains(t, stderr.String(), tt.warning) + assert.NotContains(t, stderr.String(), "GB uncompressed;") } assert.Contains(t, stderr.String(), "Pushed image") }) @@ -178,7 +174,7 @@ func TestRunImagePushPullsMissingImage(t *testing.T) { runCommand: func(_ context.Context, _ io.Reader, out, _ io.Writer, executable string, args ...string) error { commands = append(commands, recordedImageCommand{executable: executable, args: args}) if args[0] == "image" && args[1] == "inspect" { - _, err := io.WriteString(out, fakeImageInspect(args[3], "7140000000")) + _, err := io.WriteString(out, fakeImageInspect("7140000000")) return err } return nil @@ -193,7 +189,7 @@ func TestRunImagePushPullsMissingImage(t *testing.T) { }, deps) require.NoError(t, err) - require.Len(t, commands, 6) + require.Len(t, commands, 5) assert.Equal(t, []string{"pull", "--platform", "linux/amd64", "example/image:v1"}, commands[1].args) } From 2c706fcbe48c0c9ef0ab0fb11442716086fecf1c Mon Sep 17 00:00:00 2001 From: "v.chen" Date: Sat, 21 Nov 2026 06:53:43 +0000 Subject: [PATCH 05/10] air: warn about the 30 GB Databricks Artifact Registry image limit AI Runtime no longer limits image size; Databricks Artifact Registry caps images at 30 GB. Update the threshold, messages, tests, golden output and changelog fragment accordingly. Co-authored-by: Isaac --- .nextchanges/air/images-push-size-limit.md | 2 +- acceptance/air/image-push/docker | 2 +- acceptance/air/image-push/output.txt | 12 ++++++------ cmd/air/image.go | 10 +++++----- cmd/air/image_test.go | 12 ++++++------ 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.nextchanges/air/images-push-size-limit.md b/.nextchanges/air/images-push-size-limit.md index 22e626cee43..1280ef485a7 100644 --- a/.nextchanges/air/images-push-size-limit.md +++ b/.nextchanges/air/images-push-size-limit.md @@ -1 +1 @@ -* Print the source image size in `databricks air images push` before uploading, and warn with the 20 GB limit and advice to start from a Databricks base image and trim layers when the local image exceeds it. ([#7868](https://github.com/databricks/cli/pull/7868)) +* Print the source image size in `databricks air images push` before uploading, and warn with the 30 GB Databricks Artifact Registry limit and advice to start from a Databricks base image and trim layers when the local image exceeds it. ([#7868](https://github.com/databricks/cli/pull/7868)) diff --git a/acceptance/air/image-push/docker b/acceptance/air/image-push/docker index 974c817e9cb..22a2c00f5f5 100644 --- a/acceptance/air/image-push/docker +++ b/acceptance/air/image-push/docker @@ -19,7 +19,7 @@ case "$1 $2" in exit 1 ;; arm64) printf 'linux/arm64|7140000000\n' ;; - oversized) printf 'linux/amd64|25300000000\n' ;; + oversized) printf 'linux/amd64|35300000000\n' ;; *) printf 'linux/amd64|7140000000\n' ;; esac ;; diff --git a/acceptance/air/image-push/output.txt b/acceptance/air/image-push/output.txt index b95a9b3f07b..5375db4828e 100644 --- a/acceptance/air/image-push/output.txt +++ b/acceptance/air/image-push/output.txt @@ -8,7 +8,7 @@ Configured Docker credential helper for [WORKSPACE_ID].container.us-west-2.local Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Using local source image nvidia/cuda:13.4.1 -Source image nvidia/cuda:13.4.1 is 7.1 GB uncompressed; AI Runtime allows up to 20 GB compressed. +Source image nvidia/cuda:13.4.1 is 7.1 GB uncompressed; Databricks Artifact Registry caps images at 30 GB compressed. Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 Docker push progress @@ -46,7 +46,7 @@ Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Pulling source image example/image:v1 for linux/amd64 Docker pull progress -Source image example/image:v1 is 7.1 GB uncompressed; AI Runtime allows up to 20 GB compressed. +Source image example/image:v1 is 7.1 GB uncompressed; Databricks Artifact Registry caps images at 30 GB compressed. Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Docker push progress @@ -63,7 +63,7 @@ Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Pulling source image example/image:v1 for linux/amd64 Docker pull progress -Source image example/image:v1 is 7.1 GB uncompressed; AI Runtime allows up to 20 GB compressed. +Source image example/image:v1 is 7.1 GB uncompressed; Databricks Artifact Registry caps images at 30 GB compressed. Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Docker push progress @@ -133,8 +133,8 @@ Configured Docker credential helper for [WORKSPACE_ID].container.us-west-2.local Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Using local source image example/image:v1 -Source image example/image:v1 is 25.3 GB uncompressed; AI Runtime allows up to 20 GB compressed. -Warning: source image example/image:v1 exceeds 20 GB uncompressed, so the push may be rejected: start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches. +Source image example/image:v1 is 35.3 GB uncompressed; Databricks Artifact Registry caps images at 30 GB compressed. +Warning: source image example/image:v1 exceeds 30 GB uncompressed, so Databricks Artifact Registry may reject the push: start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches. Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Docker push progress @@ -249,7 +249,7 @@ Configured Docker credential helper for [WORKSPACE_ID].container.us-west-2.local Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Using local source image example/image:v1 -Source image example/image:v1 is 7.1 GB uncompressed; AI Runtime allows up to 20 GB compressed. +Source image example/image:v1 is 7.1 GB uncompressed; Databricks Artifact Registry caps images at 30 GB compressed. Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Docker push progress diff --git a/cmd/air/image.go b/cmd/air/image.go index fc738a7f77c..aed74658285 100644 --- a/cmd/air/image.go +++ b/cmd/air/image.go @@ -25,8 +25,8 @@ const ( maxImageRepositoryLength = 255 maxImageTagLength = 128 airImagePlatform = "linux/amd64" - // AI Runtime rejects images over this many decimal gigabytes, the unit Docker reports sizes in. - maxImageSizeGB = 20 + // Databricks Artifact Registry caps images at this many decimal gigabytes, the unit Docker reports sizes in. + maxImageSizeGB = 30 ) var ( @@ -209,15 +209,15 @@ func runImagePush(cmd *cobra.Command, opts *imagePushOptions, deps imagePushDeps 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) } - // Docker reports the uncompressed size while the server measures compressed layers, + // Docker reports the uncompressed size while the registry measures compressed layers, // so the size is advisory: an oversized or unreadable size never blocks the push. if sizeBytes, err := strconv.ParseInt(size, 10, 64); err != nil { cmdio.LogString(ctx, fmt.Sprintf("Warning: could not read the size of source image %s: %v", resolved.source, err)) } else { sizeGB := float64(sizeBytes) / 1e9 - cmdio.LogString(ctx, fmt.Sprintf("Source image %s is %.1f GB uncompressed; AI Runtime allows up to %d GB compressed.", resolved.source, sizeGB, maxImageSizeGB)) + cmdio.LogString(ctx, fmt.Sprintf("Source image %s is %.1f GB uncompressed; Databricks Artifact Registry caps images at %d GB compressed.", resolved.source, sizeGB, maxImageSizeGB)) if sizeGB > maxImageSizeGB { - cmdio.LogString(ctx, fmt.Sprintf("Warning: source image %s exceeds %d GB uncompressed, so the push may be rejected: start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches.", resolved.source, maxImageSizeGB)) + cmdio.LogString(ctx, fmt.Sprintf("Warning: source image %s exceeds %d GB uncompressed, so Databricks Artifact Registry may reject the push: start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches.", resolved.source, maxImageSizeGB)) } } diff --git a/cmd/air/image_test.go b/cmd/air/image_test.go index 26368e7642d..a1399805e45 100644 --- a/cmd/air/image_test.go +++ b/cmd/air/image_test.go @@ -84,7 +84,7 @@ func TestRunImagePushTagsAndPushesLocalImage(t *testing.T) { ) stderrLines := strings.Split(stderr.String(), "\n") assert.Equal(t, "Warning: This feature is in Preview. APIs may change, and the workspace must enable the Preview features.", stderrLines[0]) - assert.Contains(t, stderr.String(), "Source image nvidia/cuda:13.4.1 is 7.1 GB uncompressed; AI Runtime allows up to 20 GB compressed.") + assert.Contains(t, stderr.String(), "Source image nvidia/cuda:13.4.1 is 7.1 GB uncompressed; Databricks Artifact Registry caps images at 30 GB compressed.") assert.NotContains(t, stderr.String(), "Warning: source image") assert.Contains(t, stderr.String(), "Pushed image") } @@ -95,14 +95,14 @@ func fakeImageInspect(sizeBytes string) string { } func TestRunImagePushWarnsAboutOversizedImage(t *testing.T) { - oversized := "Warning: source image example/trainer:v1 exceeds 20 GB uncompressed, so the push may be rejected: start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches." + oversized := "Warning: source image example/trainer:v1 exceeds 30 GB uncompressed, so Databricks Artifact Registry may reject the push: start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches." tests := []struct { name string sizeBytes string warning string }{ - {name: "at limit", sizeBytes: "20000000000"}, - {name: "over limit", sizeBytes: "25300000000", warning: oversized}, + {name: "at limit", sizeBytes: "30000000000"}, + {name: "over limit", sizeBytes: "35300000000", warning: oversized}, {name: "unreadable", sizeBytes: "unknown", warning: "Warning: could not read the size of source image example/trainer:v1: strconv.ParseInt: parsing \"unknown\": invalid syntax"}, } for _, tt := range tests { @@ -135,11 +135,11 @@ func TestRunImagePushWarnsAboutOversizedImage(t *testing.T) { require.NoError(t, err) switch tt.warning { case "": - assert.Contains(t, stderr.String(), "Source image example/trainer:v1 is 20.0 GB uncompressed; AI Runtime allows up to 20 GB compressed.") + assert.Contains(t, stderr.String(), "Source image example/trainer:v1 is 30.0 GB uncompressed; Databricks Artifact Registry caps images at 30 GB compressed.") assert.NotContains(t, stderr.String(), "Warning: source image") assert.NotContains(t, stderr.String(), "could not read the size") case oversized: - assert.Contains(t, stderr.String(), "Source image example/trainer:v1 is 25.3 GB uncompressed; AI Runtime allows up to 20 GB compressed.") + assert.Contains(t, stderr.String(), "Source image example/trainer:v1 is 35.3 GB uncompressed; Databricks Artifact Registry caps images at 30 GB compressed.") assert.Contains(t, stderr.String(), oversized) default: assert.Contains(t, stderr.String(), tt.warning) From 5fe384dbc018b21820a23637b205d8fddabf35a3 Mon Sep 17 00:00:00 2001 From: "v.chen" Date: Sat, 21 Nov 2026 07:02:01 +0000 Subject: [PATCH 06/10] air: show the raw inspect value when the image size cannot be read Co-authored-by: Isaac --- cmd/air/image.go | 2 +- cmd/air/image_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/air/image.go b/cmd/air/image.go index aed74658285..b4d7d6cd760 100644 --- a/cmd/air/image.go +++ b/cmd/air/image.go @@ -212,7 +212,7 @@ func runImagePush(cmd *cobra.Command, opts *imagePushOptions, deps imagePushDeps // Docker reports the uncompressed size while the registry measures compressed layers, // so the size is advisory: an oversized or unreadable size never blocks the push. if sizeBytes, err := strconv.ParseInt(size, 10, 64); err != nil { - cmdio.LogString(ctx, fmt.Sprintf("Warning: could not read the size of source image %s: %v", resolved.source, err)) + cmdio.LogString(ctx, fmt.Sprintf("Warning: could not read the size of source image %s (got %q).", resolved.source, size)) } else { sizeGB := float64(sizeBytes) / 1e9 cmdio.LogString(ctx, fmt.Sprintf("Source image %s is %.1f GB uncompressed; Databricks Artifact Registry caps images at %d GB compressed.", resolved.source, sizeGB, maxImageSizeGB)) diff --git a/cmd/air/image_test.go b/cmd/air/image_test.go index a1399805e45..0096d3b29da 100644 --- a/cmd/air/image_test.go +++ b/cmd/air/image_test.go @@ -103,7 +103,7 @@ func TestRunImagePushWarnsAboutOversizedImage(t *testing.T) { }{ {name: "at limit", sizeBytes: "30000000000"}, {name: "over limit", sizeBytes: "35300000000", warning: oversized}, - {name: "unreadable", sizeBytes: "unknown", warning: "Warning: could not read the size of source image example/trainer:v1: strconv.ParseInt: parsing \"unknown\": invalid syntax"}, + {name: "unreadable", sizeBytes: "unknown", warning: "Warning: could not read the size of source image example/trainer:v1 (got \"unknown\")."}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { From 8e98af662ada234209f187347f37251808a52ce4 Mon Sep 17 00:00:00 2001 From: "v.chen" Date: Mon, 23 Nov 2026 17:54:50 +0000 Subject: [PATCH 07/10] air: link the DAR image limits instead of hardcoding a size threshold AI Runtime has no image size limit of its own, and Databricks Artifact Registry sets and may change its own. Print the local image size and the DAR limitations page for the workspace's cloud, with no threshold or warning. Co-authored-by: Isaac --- .nextchanges/air/images-push-size-limit.md | 2 +- acceptance/air/image-push/docker | 1 - acceptance/air/image-push/output.txt | 33 ++++------------- acceptance/air/image-push/script | 4 -- cmd/air/image.go | 25 ++++++++----- cmd/air/image_test.go | 43 ++++++++++++---------- 6 files changed, 48 insertions(+), 60 deletions(-) diff --git a/.nextchanges/air/images-push-size-limit.md b/.nextchanges/air/images-push-size-limit.md index 1280ef485a7..0ec71cf7a15 100644 --- a/.nextchanges/air/images-push-size-limit.md +++ b/.nextchanges/air/images-push-size-limit.md @@ -1 +1 @@ -* Print the source image size in `databricks air images push` before uploading, and warn with the 30 GB Databricks Artifact Registry limit and advice to start from a Databricks base image and trim layers when the local image exceeds it. ([#7868](https://github.com/databricks/cli/pull/7868)) +* Print the source image size in `databricks air images push` before uploading, with a link to the Databricks Artifact Registry image limits. ([#7868](https://github.com/databricks/cli/pull/7868)) diff --git a/acceptance/air/image-push/docker b/acceptance/air/image-push/docker index 22a2c00f5f5..b5b3ddcf91d 100644 --- a/acceptance/air/image-push/docker +++ b/acceptance/air/image-push/docker @@ -19,7 +19,6 @@ case "$1 $2" in exit 1 ;; arm64) printf 'linux/arm64|7140000000\n' ;; - oversized) printf 'linux/amd64|35300000000\n' ;; *) printf 'linux/amd64|7140000000\n' ;; esac ;; diff --git a/acceptance/air/image-push/output.txt b/acceptance/air/image-push/output.txt index 5375db4828e..a0eebf806eb 100644 --- a/acceptance/air/image-push/output.txt +++ b/acceptance/air/image-push/output.txt @@ -8,7 +8,8 @@ Configured Docker credential helper for [WORKSPACE_ID].container.us-west-2.local Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Using local source image nvidia/cuda:13.4.1 -Source image nvidia/cuda:13.4.1 is 7.1 GB uncompressed; Databricks Artifact Registry caps images at 30 GB compressed. +Source image nvidia/cuda:13.4.1 is 7.1 GB uncompressed. +For Databricks Artifact Registry image limits, see https://docs.databricks.com/aws/en/artifact-registry/#limitations Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 Docker push progress @@ -46,7 +47,8 @@ Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Pulling source image example/image:v1 for linux/amd64 Docker pull progress -Source image example/image:v1 is 7.1 GB uncompressed; Databricks Artifact Registry caps images at 30 GB compressed. +Source image example/image:v1 is 7.1 GB uncompressed. +For Databricks Artifact Registry image limits, see https://docs.databricks.com/aws/en/artifact-registry/#limitations Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Docker push progress @@ -63,7 +65,8 @@ Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Pulling source image example/image:v1 for linux/amd64 Docker pull progress -Source image example/image:v1 is 7.1 GB uncompressed; Databricks Artifact Registry caps images at 30 GB compressed. +Source image example/image:v1 is 7.1 GB uncompressed. +For Databricks Artifact Registry image limits, see https://docs.databricks.com/aws/en/artifact-registry/#limitations Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Docker push progress @@ -124,23 +127,6 @@ Pulling source image example/image:v1 for linux/amd64 Docker pull progress Error: source image example/image:v1 has platform "linux/arm64"; AIR requires linux/amd64: use --pull to fetch a compatible image, or rebuild the source for linux/amd64 -=== oversized image warns but is pushed - ->>> databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training -Warning: This feature is in Preview. APIs may change, and the workspace must enable the Preview features. -Pushing example/image:v1 as main.training.image:v1 using profile docker-test -Configured Docker credential helper for [WORKSPACE_ID].container.us-west-2.localhost -Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json -Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks -Using local source image example/image:v1 -Source image example/image:v1 is 35.3 GB uncompressed; Databricks Artifact Registry caps images at 30 GB compressed. -Warning: source image example/image:v1 exceeds 30 GB uncompressed, so Databricks Artifact Registry may reject the push: start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches. -Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 -Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 -Docker push progress -Pushed image. -Now you can set `environment.unity_catalog_image = main.training.image:v1` in your YAML config and create a workload with `databricks air run -f config.yaml`. - === pull failure must not be pushed >>> musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training --pull @@ -232,10 +218,6 @@ image ls --quiet example/image:v1 image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 pull --platform linux/amd64 example/image:v1 image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 -image ls --quiet example/image:v1 -image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 -tag example/image:v1 [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 -push [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 pull --platform linux/amd64 example/image:v1 === in a Claude Code session the auth docker configure child adds no install hint @@ -249,7 +231,8 @@ Configured Docker credential helper for [WORKSPACE_ID].container.us-west-2.local Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Using local source image example/image:v1 -Source image example/image:v1 is 7.1 GB uncompressed; Databricks Artifact Registry caps images at 30 GB compressed. +Source image example/image:v1 is 7.1 GB uncompressed. +For Databricks Artifact Registry image limits, see https://docs.databricks.com/aws/en/artifact-registry/#limitations Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Docker push progress diff --git a/acceptance/air/image-push/script b/acceptance/air/image-push/script index 3b34ce6c2aa..a0343b728ab 100644 --- a/acceptance/air/image-push/script +++ b/acceptance/air/image-push/script @@ -43,10 +43,6 @@ trace musterr databricks air images push -p docker-test -s example/image:v1 --ca title "incompatible pulled image must not be pushed" trace musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training --pull -title "oversized image warns but is pushed" -export DOCKER_TEST_MODE=oversized -trace databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training - title "pull failure must not be pushed" export DOCKER_TEST_MODE=pull-error trace musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training --pull diff --git a/cmd/air/image.go b/cmd/air/image.go index b4d7d6cd760..d167b7e949d 100644 --- a/cmd/air/image.go +++ b/cmd/air/image.go @@ -18,6 +18,7 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" + "github.com/databricks/databricks-sdk-go/config" "github.com/spf13/cobra" ) @@ -25,8 +26,6 @@ const ( maxImageRepositoryLength = 255 maxImageTagLength = 128 airImagePlatform = "linux/amd64" - // Databricks Artifact Registry caps images at this many decimal gigabytes, the unit Docker reports sizes in. - maxImageSizeGB = 30 ) var ( @@ -157,6 +156,18 @@ The destination --artifact ARTIFACT[:TAG] defaults to the source image name and return cmd } +// darLimitationsURL returns the DAR limitations docs for the workspace's cloud. +func darLimitationsURL(cfg *config.Config) string { + switch { + case cfg.IsAzure(): + return "https://learn.microsoft.com/azure/databricks/artifact-registry/#limitations" + case cfg.IsGcp(): + return "https://docs.databricks.com/gcp/en/artifact-registry/#limitations" + default: + return "https://docs.databricks.com/aws/en/artifact-registry/#limitations" + } +} + // runImagePush validates inputs, prepares a compatible source image, and pushes it to DAR. func runImagePush(cmd *cobra.Command, opts *imagePushOptions, deps imagePushDeps) error { ctx := cmd.Context() @@ -209,17 +220,13 @@ func runImagePush(cmd *cobra.Command, opts *imagePushOptions, deps imagePushDeps 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) } - // Docker reports the uncompressed size while the registry measures compressed layers, - // so the size is advisory: an oversized or unreadable size never blocks the push. + // The size is informational: DAR sets and may change its own limits, so the CLI links them instead of enforcing one. if sizeBytes, err := strconv.ParseInt(size, 10, 64); err != nil { cmdio.LogString(ctx, fmt.Sprintf("Warning: could not read the size of source image %s (got %q).", resolved.source, size)) } else { - sizeGB := float64(sizeBytes) / 1e9 - cmdio.LogString(ctx, fmt.Sprintf("Source image %s is %.1f GB uncompressed; Databricks Artifact Registry caps images at %d GB compressed.", resolved.source, sizeGB, maxImageSizeGB)) - if sizeGB > maxImageSizeGB { - cmdio.LogString(ctx, fmt.Sprintf("Warning: source image %s exceeds %d GB uncompressed, so Databricks Artifact Registry may reject the push: start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches.", resolved.source, maxImageSizeGB)) - } + cmdio.LogString(ctx, fmt.Sprintf("Source image %s is %.1f GB uncompressed.", resolved.source, float64(sizeBytes)/1e9)) } + cmdio.LogString(ctx, "For Databricks Artifact Registry image limits, see "+darLimitationsURL(w.Config)) cmdio.LogProgress(ctx, "Tagging image as "+target) if err := deps.runCommand(ctx, cmd.InOrStdin(), cmd.ErrOrStderr(), cmd.ErrOrStderr(), dockerPath, "tag", resolved.source, target); err != nil { diff --git a/cmd/air/image_test.go b/cmd/air/image_test.go index 0096d3b29da..891c47c3e72 100644 --- a/cmd/air/image_test.go +++ b/cmd/air/image_test.go @@ -84,8 +84,7 @@ func TestRunImagePushTagsAndPushesLocalImage(t *testing.T) { ) stderrLines := strings.Split(stderr.String(), "\n") assert.Equal(t, "Warning: This feature is in Preview. APIs may change, and the workspace must enable the Preview features.", stderrLines[0]) - assert.Contains(t, stderr.String(), "Source image nvidia/cuda:13.4.1 is 7.1 GB uncompressed; Databricks Artifact Registry caps images at 30 GB compressed.") - assert.NotContains(t, stderr.String(), "Warning: source image") + assert.Contains(t, stderr.String(), "Source image nvidia/cuda:13.4.1 is 7.1 GB uncompressed.\nFor Databricks Artifact Registry image limits, see https://docs.databricks.com/aws/en/artifact-registry/#limitations\n") assert.Contains(t, stderr.String(), "Pushed image") } @@ -94,16 +93,14 @@ func fakeImageInspect(sizeBytes string) string { return "linux/amd64|" + sizeBytes + "\n" } -func TestRunImagePushWarnsAboutOversizedImage(t *testing.T) { - oversized := "Warning: source image example/trainer:v1 exceeds 30 GB uncompressed, so Databricks Artifact Registry may reject the push: start from a Databricks base image (databricksruntime/air) and trim layers such as model weights and build caches." +func TestRunImagePushReportsImageSize(t *testing.T) { tests := []struct { name string sizeBytes string - warning string + want string }{ - {name: "at limit", sizeBytes: "30000000000"}, - {name: "over limit", sizeBytes: "35300000000", warning: oversized}, - {name: "unreadable", sizeBytes: "unknown", warning: "Warning: could not read the size of source image example/trainer:v1 (got \"unknown\")."}, + {name: "readable", sizeBytes: "35300000000", want: "Source image example/trainer:v1 is 35.3 GB uncompressed."}, + {name: "unreadable", sizeBytes: "unknown", want: "Warning: could not read the size of source image example/trainer:v1 (got \"unknown\")."}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -133,23 +130,29 @@ func TestRunImagePushWarnsAboutOversizedImage(t *testing.T) { artifact: "trainer", }, deps) require.NoError(t, err) - switch tt.warning { - case "": - assert.Contains(t, stderr.String(), "Source image example/trainer:v1 is 30.0 GB uncompressed; Databricks Artifact Registry caps images at 30 GB compressed.") - assert.NotContains(t, stderr.String(), "Warning: source image") - assert.NotContains(t, stderr.String(), "could not read the size") - case oversized: - assert.Contains(t, stderr.String(), "Source image example/trainer:v1 is 35.3 GB uncompressed; Databricks Artifact Registry caps images at 30 GB compressed.") - assert.Contains(t, stderr.String(), oversized) - default: - assert.Contains(t, stderr.String(), tt.warning) - assert.NotContains(t, stderr.String(), "GB uncompressed;") - } + assert.Contains(t, stderr.String(), tt.want) + assert.Contains(t, stderr.String(), "For Databricks Artifact Registry image limits, see ") assert.Contains(t, stderr.String(), "Pushed image") }) } } +func TestDARLimitationsURL(t *testing.T) { + tests := []struct { + host string + want string + }{ + {host: "https://dbc-123.cloud.databricks.com", want: "https://docs.databricks.com/aws/en/artifact-registry/#limitations"}, + {host: "https://adb-123.4.azuredatabricks.net", want: "https://learn.microsoft.com/azure/databricks/artifact-registry/#limitations"}, + {host: "https://123.4.gcp.databricks.com", want: "https://docs.databricks.com/gcp/en/artifact-registry/#limitations"}, + } + for _, tt := range tests { + t.Run(tt.host, func(t *testing.T) { + assert.Equal(t, tt.want, darLimitationsURL(&config.Config{Host: tt.host})) + }) + } +} + func TestRegistryHostFromDockerConfigureOutput(t *testing.T) { output := `Configured Docker credential helper for 123.container.us-west-2.cloud.databricks.test Updated Docker config: /tmp/docker/config.json From fb341d0d7363cc6aa1b0adc0f04c48238fa65bcd Mon Sep 17 00:00:00 2001 From: "v.chen" Date: Mon, 23 Nov 2026 18:06:55 +0000 Subject: [PATCH 08/10] air: tidy the image size line and its tests Print sub-GB images in MB, treat inspect output without a size as an inspect error, select the cloud in TestDARLimitationsURL through the config's Cloud field, and cover the unreadable-size case in the acceptance test instead of repeating golden output in unit tests. Co-authored-by: Isaac --- acceptance/air/image-push/docker | 1 + acceptance/air/image-push/output.txt | 13 ++++++ acceptance/air/image-push/script | 4 ++ cmd/air/image.go | 18 +++++--- cmd/air/image_test.go | 62 ++++++---------------------- 5 files changed, 43 insertions(+), 55 deletions(-) diff --git a/acceptance/air/image-push/docker b/acceptance/air/image-push/docker index b5b3ddcf91d..4f33dceeb6f 100644 --- a/acceptance/air/image-push/docker +++ b/acceptance/air/image-push/docker @@ -19,6 +19,7 @@ case "$1 $2" in exit 1 ;; arm64) printf 'linux/arm64|7140000000\n' ;; + bad-size) printf 'linux/amd64|\n' ;; *) printf 'linux/amd64|7140000000\n' ;; esac ;; diff --git a/acceptance/air/image-push/output.txt b/acceptance/air/image-push/output.txt index a0eebf806eb..be29b6ef35f 100644 --- a/acceptance/air/image-push/output.txt +++ b/acceptance/air/image-push/output.txt @@ -104,6 +104,17 @@ Using local source image example/image:v1 Docker inspect failed Error: inspect source image example/image:v1: exit status 1 +=== unreadable image size must not be pushed + +>>> musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training +Warning: This feature is in Preview. APIs may change, and the workspace must enable the Preview features. +Pushing example/image:v1 as main.training.image:v1 using profile docker-test +Configured Docker credential helper for [WORKSPACE_ID].container.us-west-2.localhost +Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json +Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks +Using local source image example/image:v1 +Error: inspect source image example/image:v1: unexpected output "linux/amd64|" + === incompatible local image must not be pushed >>> musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training @@ -216,6 +227,8 @@ image ls --quiet example/image:v1 image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 image ls --quiet example/image:v1 image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 +image ls --quiet example/image:v1 +image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 pull --platform linux/amd64 example/image:v1 image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 pull --platform linux/amd64 example/image:v1 diff --git a/acceptance/air/image-push/script b/acceptance/air/image-push/script index a0343b728ab..abd6588aee4 100644 --- a/acceptance/air/image-push/script +++ b/acceptance/air/image-push/script @@ -36,6 +36,10 @@ title "inspect failure must not pull" export DOCKER_TEST_MODE=inspect-error trace musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training +title "unreadable image size must not be pushed" +export DOCKER_TEST_MODE=bad-size +trace musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training + title "incompatible local image must not be pushed" export DOCKER_TEST_MODE=arm64 trace musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training diff --git a/cmd/air/image.go b/cmd/air/image.go index d167b7e949d..b511e353a50 100644 --- a/cmd/air/image.go +++ b/cmd/air/image.go @@ -156,6 +156,14 @@ The destination --artifact ARTIFACT[:TAG] defaults to the source image name and return cmd } +// formatImageSize renders a byte count in decimal MB or GB, the units docker images uses. +func formatImageSize(sizeBytes int64) string { + if sizeBytes < 1e9 { + return fmt.Sprintf("%.1f MB", float64(sizeBytes)/1e6) + } + return fmt.Sprintf("%.1f GB", float64(sizeBytes)/1e9) +} + // darLimitationsURL returns the DAR limitations docs for the workspace's cloud. func darLimitationsURL(cfg *config.Config) string { switch { @@ -220,12 +228,12 @@ func runImagePush(cmd *cobra.Command, opts *imagePushOptions, deps imagePushDeps 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) } - // The size is informational: DAR sets and may change its own limits, so the CLI links them instead of enforcing one. - if sizeBytes, err := strconv.ParseInt(size, 10, 64); err != nil { - cmdio.LogString(ctx, fmt.Sprintf("Warning: could not read the size of source image %s (got %q).", resolved.source, size)) - } else { - cmdio.LogString(ctx, fmt.Sprintf("Source image %s is %.1f GB uncompressed.", resolved.source, float64(sizeBytes)/1e9)) + sizeBytes, err := strconv.ParseInt(size, 10, 64) + if err != nil { + return fmt.Errorf("inspect source image %s: unexpected output %q", resolved.source, strings.TrimSpace(inspected.String())) } + // DAR sets and may change its own limits, so the CLI links them instead of enforcing one. + cmdio.LogString(ctx, fmt.Sprintf("Source image %s is %s uncompressed.", resolved.source, formatImageSize(sizeBytes))) cmdio.LogString(ctx, "For Databricks Artifact Registry image limits, see "+darLimitationsURL(w.Config)) cmdio.LogProgress(ctx, "Tagging image as "+target) diff --git a/cmd/air/image_test.go b/cmd/air/image_test.go index 891c47c3e72..4b5821c8f75 100644 --- a/cmd/air/image_test.go +++ b/cmd/air/image_test.go @@ -12,6 +12,7 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go" + "github.com/databricks/databricks-sdk-go/common/environment" "github.com/databricks/databricks-sdk-go/config" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" @@ -84,7 +85,6 @@ func TestRunImagePushTagsAndPushesLocalImage(t *testing.T) { ) stderrLines := strings.Split(stderr.String(), "\n") assert.Equal(t, "Warning: This feature is in Preview. APIs may change, and the workspace must enable the Preview features.", stderrLines[0]) - assert.Contains(t, stderr.String(), "Source image nvidia/cuda:13.4.1 is 7.1 GB uncompressed.\nFor Databricks Artifact Registry image limits, see https://docs.databricks.com/aws/en/artifact-registry/#limitations\n") assert.Contains(t, stderr.String(), "Pushed image") } @@ -93,62 +93,24 @@ func fakeImageInspect(sizeBytes string) string { return "linux/amd64|" + sizeBytes + "\n" } -func TestRunImagePushReportsImageSize(t *testing.T) { - tests := []struct { - name string - sizeBytes string - want string - }{ - {name: "readable", sizeBytes: "35300000000", want: "Source image example/trainer:v1 is 35.3 GB uncompressed."}, - {name: "unreadable", sizeBytes: "unknown", want: "Warning: could not read the size of source image example/trainer:v1 (got \"unknown\")."}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - cmd, _, stderr := newImagePushTestCommand(t, "workspace") - deps := imagePushDeps{ - configureDocker: func(context.Context, string) (string, error) { - return "123.container.us-west-2.cloud.databricks.test", nil - }, - lookPath: func(string) (string, error) { return "docker", nil }, - runCommand: func(_ context.Context, _ io.Reader, out, _ io.Writer, _ string, args ...string) error { - switch strings.Join(args[:2], " ") { - case "image ls": - _, err := io.WriteString(out, "image-id\n") - return err - case "image inspect": - _, err := io.WriteString(out, fakeImageInspect(tt.sizeBytes)) - return err - } - return nil - }, - } - - err := runImagePush(cmd, &imagePushOptions{ - source: "example/trainer:v1", - catalog: "main", - schema: "training", - artifact: "trainer", - }, deps) - require.NoError(t, err) - assert.Contains(t, stderr.String(), tt.want) - assert.Contains(t, stderr.String(), "For Databricks Artifact Registry image limits, see ") - assert.Contains(t, stderr.String(), "Pushed image") - }) - } +func TestFormatImageSize(t *testing.T) { + assert.Equal(t, "7.6 MB", formatImageSize(7_600_000)) + assert.Equal(t, "999.0 MB", formatImageSize(999_000_000)) + assert.Equal(t, "7.1 GB", formatImageSize(7_140_000_000)) } func TestDARLimitationsURL(t *testing.T) { tests := []struct { - host string - want string + cloud environment.Cloud + want string }{ - {host: "https://dbc-123.cloud.databricks.com", want: "https://docs.databricks.com/aws/en/artifact-registry/#limitations"}, - {host: "https://adb-123.4.azuredatabricks.net", want: "https://learn.microsoft.com/azure/databricks/artifact-registry/#limitations"}, - {host: "https://123.4.gcp.databricks.com", want: "https://docs.databricks.com/gcp/en/artifact-registry/#limitations"}, + {cloud: environment.CloudAWS, want: "https://docs.databricks.com/aws/en/artifact-registry/#limitations"}, + {cloud: environment.CloudAzure, want: "https://learn.microsoft.com/azure/databricks/artifact-registry/#limitations"}, + {cloud: environment.CloudGCP, want: "https://docs.databricks.com/gcp/en/artifact-registry/#limitations"}, } for _, tt := range tests { - t.Run(tt.host, func(t *testing.T) { - assert.Equal(t, tt.want, darLimitationsURL(&config.Config{Host: tt.host})) + t.Run(string(tt.cloud), func(t *testing.T) { + assert.Equal(t, tt.want, darLimitationsURL(&config.Config{Cloud: tt.cloud})) }) } } From 04d658133b0e1698c38c73be597aec77907ae262 Mon Sep 17 00:00:00 2001 From: "v.chen" Date: Mon, 23 Nov 2026 21:19:34 +0000 Subject: [PATCH 09/10] air: report the pushed image's compressed size and layer count DAR measures the compressed image (the sum of the manifest's layer sizes), which the local image store doesn't know. After the push, read the pushed manifest with docker manifest inspect --verbose and print its compressed size and layer count with the DAR limitations link. All size output is informational: a size or manifest that can't be read prints a warning and the push still succeeds. Co-authored-by: Isaac --- .nextchanges/air/images-push-size-limit.md | 2 +- acceptance/air/image-push/docker | 7 ++ acceptance/air/image-push/output.txt | 32 ++++++-- acceptance/air/image-push/script | 4 +- cmd/air/image.go | 88 ++++++++++++++++++++-- cmd/air/image_test.go | 49 +++++++++++- 6 files changed, 165 insertions(+), 17 deletions(-) diff --git a/.nextchanges/air/images-push-size-limit.md b/.nextchanges/air/images-push-size-limit.md index 0ec71cf7a15..484b6d4fab8 100644 --- a/.nextchanges/air/images-push-size-limit.md +++ b/.nextchanges/air/images-push-size-limit.md @@ -1 +1 @@ -* Print the source image size in `databricks air images push` before uploading, with a link to the Databricks Artifact Registry image limits. ([#7868](https://github.com/databricks/cli/pull/7868)) +* Print the source image size in `databricks air images push`, and after the push the compressed size and layer count from the pushed manifest, with a link to the Databricks Artifact Registry image limits. ([#7868](https://github.com/databricks/cli/pull/7868)) diff --git a/acceptance/air/image-push/docker b/acceptance/air/image-push/docker index 4f33dceeb6f..4080b408e40 100644 --- a/acceptance/air/image-push/docker +++ b/acceptance/air/image-push/docker @@ -23,6 +23,13 @@ case "$1 $2" in *) printf 'linux/amd64|7140000000\n' ;; esac ;; + "manifest inspect") + if [ "$DOCKER_TEST_MODE" = bad-size ]; then + printf 'no such manifest: %s\n' "$4" >&2 + exit 1 + fi + printf '{"Descriptor":{"platform":{"architecture":"amd64","os":"linux"}},"OCIManifest":{"layers":[{"size":2900000000},{"size":240000000}]}}\n' + ;; pull\ *) if [ "$DOCKER_TEST_MODE" = pull-error ]; then printf 'Docker pull failed\n' >&2 diff --git a/acceptance/air/image-push/output.txt b/acceptance/air/image-push/output.txt index be29b6ef35f..75071a3e839 100644 --- a/acceptance/air/image-push/output.txt +++ b/acceptance/air/image-push/output.txt @@ -9,11 +9,12 @@ Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Using local source image nvidia/cuda:13.4.1 Source image nvidia/cuda:13.4.1 is 7.1 GB uncompressed. -For Databricks Artifact Registry image limits, see https://docs.databricks.com/aws/en/artifact-registry/#limitations Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 Docker push progress Pushed image. +Compressed image size: 3.1 GB in 2 layers. +For Databricks Artifact Registry image limits, see https://docs.databricks.com/aws/en/artifact-registry/#limitations Now you can set `environment.unity_catalog_image = my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04` in your YAML config and create a workload with `databricks air run -f config.yaml`. === inferred region and workspace ID requests @@ -36,6 +37,7 @@ image ls --quiet nvidia/cuda:13.4.1 image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} nvidia/cuda:13.4.1 tag nvidia/cuda:13.4.1 [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 push [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 +manifest inspect --verbose [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 === missing image is pulled for AIR; destination defaults to source @@ -48,11 +50,12 @@ Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-da Pulling source image example/image:v1 for linux/amd64 Docker pull progress Source image example/image:v1 is 7.1 GB uncompressed. -For Databricks Artifact Registry image limits, see https://docs.databricks.com/aws/en/artifact-registry/#limitations Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Docker push progress Pushed image. +Compressed image size: 3.1 GB in 2 layers. +For Databricks Artifact Registry image limits, see https://docs.databricks.com/aws/en/artifact-registry/#limitations Now you can set `environment.unity_catalog_image = main.training.image:v1` in your YAML config and create a workload with `databricks air run -f config.yaml`. === forced pull and JSON output @@ -66,11 +69,12 @@ Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-da Pulling source image example/image:v1 for linux/amd64 Docker pull progress Source image example/image:v1 is 7.1 GB uncompressed. -For Databricks Artifact Registry image limits, see https://docs.databricks.com/aws/en/artifact-registry/#limitations Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Docker push progress Pushed image. +Compressed image size: 3.1 GB in 2 layers. +For Databricks Artifact Registry image limits, see https://docs.databricks.com/aws/en/artifact-registry/#limitations >>> jq -e {v, data} [TEST_TMP_DIR]/home/result.json { @@ -104,16 +108,23 @@ Using local source image example/image:v1 Docker inspect failed Error: inspect source image example/image:v1: exit status 1 -=== unreadable image size must not be pushed +=== unreadable image sizes warn but the image is pushed ->>> musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training +>>> databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training Warning: This feature is in Preview. APIs may change, and the workspace must enable the Preview features. Pushing example/image:v1 as main.training.image:v1 using profile docker-test Configured Docker credential helper for [WORKSPACE_ID].container.us-west-2.localhost Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Using local source image example/image:v1 -Error: inspect source image example/image:v1: unexpected output "linux/amd64|" +Warning: could not read the uncompressed size of source image example/image:v1 (got ""). +Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 +Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 +Docker push progress +Pushed image. +Warning: could not read the compressed size of [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1: no such manifest: [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 +For Databricks Artifact Registry image limits, see https://docs.databricks.com/aws/en/artifact-registry/#limitations +Now you can set `environment.unity_catalog_image = main.training.image:v1` in your YAML config and create a workload with `databricks air run -f config.yaml`. === incompatible local image must not be pushed @@ -213,20 +224,26 @@ image ls --quiet nvidia/cuda:13.4.1 image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} nvidia/cuda:13.4.1 tag nvidia/cuda:13.4.1 [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 push [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 +manifest inspect --verbose [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 image ls --quiet example/image:v1 pull --platform linux/amd64 example/image:v1 image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 tag example/image:v1 [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 push [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 +manifest inspect --verbose [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 pull --platform linux/amd64 example/image:v1 image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 tag example/image:v1 [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 push [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 +manifest inspect --verbose [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 image ls --quiet example/image:v1 image ls --quiet example/image:v1 image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 image ls --quiet example/image:v1 image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 +tag example/image:v1 [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 +push [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 +manifest inspect --verbose [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 image ls --quiet example/image:v1 image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 pull --platform linux/amd64 example/image:v1 @@ -245,11 +262,12 @@ Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Using local source image example/image:v1 Source image example/image:v1 is 7.1 GB uncompressed. -For Databricks Artifact Registry image limits, see https://docs.databricks.com/aws/en/artifact-registry/#limitations Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Docker push progress Pushed image. +Compressed image size: 3.1 GB in 2 layers. +For Databricks Artifact Registry image limits, see https://docs.databricks.com/aws/en/artifact-registry/#limitations Now you can set `environment.unity_catalog_image = main.training.image:v1` in your YAML config and create a workload with `databricks air run -f config.yaml`. >>> musterr databricks air images push -p pat-test -s example/image:v1 --catalog main --schema training diff --git a/acceptance/air/image-push/script b/acceptance/air/image-push/script index abd6588aee4..162ed32a5e7 100644 --- a/acceptance/air/image-push/script +++ b/acceptance/air/image-push/script @@ -36,9 +36,9 @@ title "inspect failure must not pull" export DOCKER_TEST_MODE=inspect-error trace musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training -title "unreadable image size must not be pushed" +title "unreadable image sizes warn but the image is pushed" export DOCKER_TEST_MODE=bad-size -trace musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training +trace databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training title "incompatible local image must not be pushed" export DOCKER_TEST_MODE=arm64 diff --git a/cmd/air/image.go b/cmd/air/image.go index b511e353a50..e1811a960ed 100644 --- a/cmd/air/image.go +++ b/cmd/air/image.go @@ -3,6 +3,7 @@ package aircmd import ( "bytes" "context" + "encoding/json" "errors" "fmt" "io" @@ -164,6 +165,79 @@ func formatImageSize(sizeBytes int64) string { return fmt.Sprintf("%.1f GB", float64(sizeBytes)/1e9) } +// logCompressedImageSize prints the compressed size and layer count from the pushed manifest, +// which is what DAR measures; the local image store only knows the uncompressed size. +func logCompressedImageSize(ctx context.Context, deps imagePushDeps, dockerPath, target string) { + var manifest, errOut bytes.Buffer + if err := deps.runCommand(ctx, nil, &manifest, &errOut, dockerPath, "manifest", "inspect", "--verbose", target); err != nil { + detail, _, _ := strings.Cut(strings.TrimSpace(errOut.String()), "\n") + if detail == "" { + detail = err.Error() + } + cmdio.LogString(ctx, fmt.Sprintf("Warning: could not read the compressed size of %s: %s", target, detail)) + return + } + sizeBytes, layers, err := compressedImageSize(manifest.Bytes()) + if err != nil { + cmdio.LogString(ctx, fmt.Sprintf("Warning: could not read the compressed size of %s: %v", target, err)) + return + } + cmdio.LogString(ctx, fmt.Sprintf("Compressed image size: %s in %d layers.", formatImageSize(sizeBytes), layers)) +} + +type manifestLayers struct { + Layers []struct { + Size int64 `json:"size"` + } `json:"layers"` +} + +type verboseManifest struct { + Descriptor struct { + Platform *struct { + OS string `json:"os"` + Architecture string `json:"architecture"` + } `json:"platform"` + } + SchemaV2Manifest *manifestLayers + OCIManifest *manifestLayers +} + +// compressedImageSize sums the layer sizes in `docker manifest inspect --verbose` output. That +// output is one object for an image manifest and an array for an index, whose linux/amd64 entry is used. +func compressedImageSize(output []byte) (int64, int, error) { + output = bytes.TrimSpace(output) + var entries []verboseManifest + if bytes.HasPrefix(output, []byte("[")) { + if err := json.Unmarshal(output, &entries); err != nil { + return 0, 0, err + } + } else { + var entry verboseManifest + if err := json.Unmarshal(output, &entry); err != nil { + return 0, 0, err + } + entries = []verboseManifest{entry} + } + for _, e := range entries { + if p := e.Descriptor.Platform; p != nil && p.OS+"/"+p.Architecture != airImagePlatform { + continue + } + m := e.OCIManifest + if m == nil { + m = e.SchemaV2Manifest + } + if m == nil || len(m.Layers) == 0 { + continue + } + var sizeBytes int64 + for _, l := range m.Layers { + sizeBytes += l.Size + } + return sizeBytes, len(m.Layers), nil + } + return 0, 0, fmt.Errorf("no %s image manifest with layers", airImagePlatform) +} + // darLimitationsURL returns the DAR limitations docs for the workspace's cloud. func darLimitationsURL(cfg *config.Config) string { switch { @@ -228,13 +302,12 @@ func runImagePush(cmd *cobra.Command, opts *imagePushOptions, deps imagePushDeps 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) } - sizeBytes, err := strconv.ParseInt(size, 10, 64) - if err != nil { - return fmt.Errorf("inspect source image %s: unexpected output %q", resolved.source, strings.TrimSpace(inspected.String())) + // Sizes are informational only: a size that can't be read never blocks the push. + if sizeBytes, err := strconv.ParseInt(size, 10, 64); err == nil { + cmdio.LogString(ctx, fmt.Sprintf("Source image %s is %s uncompressed.", resolved.source, formatImageSize(sizeBytes))) + } else { + cmdio.LogString(ctx, fmt.Sprintf("Warning: could not read the uncompressed size of source image %s (got %q).", resolved.source, size)) } - // DAR sets and may change its own limits, so the CLI links them instead of enforcing one. - cmdio.LogString(ctx, fmt.Sprintf("Source image %s is %s uncompressed.", resolved.source, formatImageSize(sizeBytes))) - cmdio.LogString(ctx, "For Databricks Artifact Registry image limits, see "+darLimitationsURL(w.Config)) cmdio.LogProgress(ctx, "Tagging image as "+target) if err := deps.runCommand(ctx, cmd.InOrStdin(), cmd.ErrOrStderr(), cmd.ErrOrStderr(), dockerPath, "tag", resolved.source, target); err != nil { @@ -246,6 +319,9 @@ func runImagePush(cmd *cobra.Command, opts *imagePushOptions, deps imagePushDeps } cmdio.LogString(ctx, "Pushed image.") + logCompressedImageSize(ctx, deps, dockerPath, target) + // DAR sets and may change its own limits, so the CLI links them instead of enforcing one. + cmdio.LogString(ctx, "For Databricks Artifact Registry image limits, see "+darLimitationsURL(w.Config)) if root.OutputType(cmd) == flags.OutputJSON { return renderEnvelope(ctx, struct { UnityCatalogImage string `json:"unity_catalog_image"` diff --git a/cmd/air/image_test.go b/cmd/air/image_test.go index 4b5821c8f75..96f99f4b676 100644 --- a/cmd/air/image_test.go +++ b/cmd/air/image_test.go @@ -78,6 +78,7 @@ func TestRunImagePushTagsAndPushesLocalImage(t *testing.T) { {executable: "/usr/bin/docker", args: []string{"image", "inspect", "--format", "{{.Os}}/{{.Architecture}}|{{.Size}}", "nvidia/cuda:13.4.1"}}, {executable: "/usr/bin/docker", args: []string{"tag", "nvidia/cuda:13.4.1", target}}, {executable: "/usr/bin/docker", args: []string{"push", target}}, + {executable: "/usr/bin/docker", args: []string{"manifest", "inspect", "--verbose", target}}, }, commands) assert.Equal(t, "Now you can set `environment.unity_catalog_image = main.training.cuda:13.4.1` in your YAML config and create a workload with `databricks air run -f config.yaml`.\n", @@ -99,6 +100,52 @@ func TestFormatImageSize(t *testing.T) { assert.Equal(t, "7.1 GB", formatImageSize(7_140_000_000)) } +func TestCompressedImageSize(t *testing.T) { + tests := []struct { + name string + output string + size int64 + layers int + wantErr string + }{ + { + name: "image manifest", + output: `{"Descriptor":{"platform":{"architecture":"amd64","os":"linux"}},"OCIManifest":{"layers":[{"size":2900000000},{"size":240000000}]}}`, + size: 3_140_000_000, layers: 2, + }, + { + name: "schema2 manifest without platform", + output: `{"Descriptor":{},"SchemaV2Manifest":{"layers":[{"size":7600000}]}}`, + size: 7_600_000, layers: 1, + }, + { + name: "index uses the linux/amd64 entry", + output: `[{"Descriptor":{"platform":{"architecture":"arm64","os":"linux"}},"OCIManifest":{"layers":[{"size":1}]}}, + {"Descriptor":{"platform":{"architecture":"amd64","os":"linux"}},"OCIManifest":{"layers":[{"size":5},{"size":6},{"size":7}]}}, + {"Descriptor":{"platform":{"architecture":"unknown","os":"unknown"}},"OCIManifest":{"layers":[{"size":9}]}}]`, + size: 18, layers: 3, + }, + { + name: "index without linux/amd64", + output: `[{"Descriptor":{"platform":{"architecture":"arm64","os":"linux"}},"OCIManifest":{"layers":[{"size":1}]}}]`, + wantErr: "no linux/amd64 image manifest with layers", + }, + {name: "not JSON", output: "no such manifest", wantErr: "invalid character"}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + size, layers, err := compressedImageSize([]byte(tt.output)) + if tt.wantErr != "" { + assert.ErrorContains(t, err, tt.wantErr) + return + } + require.NoError(t, err) + assert.Equal(t, tt.size, size) + assert.Equal(t, tt.layers, layers) + }) + } +} + func TestDARLimitationsURL(t *testing.T) { tests := []struct { cloud environment.Cloud @@ -154,7 +201,7 @@ func TestRunImagePushPullsMissingImage(t *testing.T) { }, deps) require.NoError(t, err) - require.Len(t, commands, 5) + require.Len(t, commands, 6) assert.Equal(t, []string{"pull", "--platform", "linux/amd64", "example/image:v1"}, commands[1].args) } From 1fcfc1984264ae77f75ba72b5c99cb71fd47ae16 Mon Sep 17 00:00:00 2001 From: "v.chen" Date: Mon, 23 Nov 2026 22:35:12 +0000 Subject: [PATCH 10/10] air: pick the manifest by the inspected platform and link limits on failed pushes Choose the index entry for the platform docker image inspect reported for the source image instead of the AIR platform constant, print the registry limits link when the push fails too, and reword a comment that described registry behavior. Co-authored-by: Isaac --- acceptance/air/image-push/docker | 4 ++++ acceptance/air/image-push/output.txt | 20 ++++++++++++++++++++ acceptance/air/image-push/script | 4 ++++ cmd/air/image.go | 24 +++++++++++++----------- cmd/air/image_test.go | 21 +++++++++++++++------ 5 files changed, 56 insertions(+), 17 deletions(-) diff --git a/acceptance/air/image-push/docker b/acceptance/air/image-push/docker index 4080b408e40..223c47c24e7 100644 --- a/acceptance/air/image-push/docker +++ b/acceptance/air/image-push/docker @@ -41,6 +41,10 @@ case "$1 $2" in exit 0 ;; push\ *) + if [ "$DOCKER_TEST_MODE" = push-error ]; then + printf 'denied: image exceeds the registry size limit\n' >&2 + exit 1 + fi printf 'Docker push progress\n' ;; *) diff --git a/acceptance/air/image-push/output.txt b/acceptance/air/image-push/output.txt index 75071a3e839..e0d72a473c3 100644 --- a/acceptance/air/image-push/output.txt +++ b/acceptance/air/image-push/output.txt @@ -149,6 +149,22 @@ Pulling source image example/image:v1 for linux/amd64 Docker pull progress Error: source image example/image:v1 has platform "linux/arm64"; AIR requires linux/amd64: use --pull to fetch a compatible image, or rebuild the source for linux/amd64 +=== rejected push still links the registry limits + +>>> musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training +Warning: This feature is in Preview. APIs may change, and the workspace must enable the Preview features. +Pushing example/image:v1 as main.training.image:v1 using profile docker-test +Configured Docker credential helper for [WORKSPACE_ID].container.us-west-2.localhost +Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json +Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks +Using local source image example/image:v1 +Source image example/image:v1 is 7.1 GB uncompressed. +Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 +Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 +denied: image exceeds the registry size limit +For Databricks Artifact Registry image limits, see https://docs.databricks.com/aws/en/artifact-registry/#limitations +Error: push image [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1: exit status 1 + === pull failure must not be pushed >>> musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training --pull @@ -248,6 +264,10 @@ image ls --quiet example/image:v1 image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 pull --platform linux/amd64 example/image:v1 image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 +image ls --quiet example/image:v1 +image inspect --format {{.Os}}/{{.Architecture}}|{{.Size}} example/image:v1 +tag example/image:v1 [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 +push [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 pull --platform linux/amd64 example/image:v1 === in a Claude Code session the auth docker configure child adds no install hint diff --git a/acceptance/air/image-push/script b/acceptance/air/image-push/script index 162ed32a5e7..a1a2304f403 100644 --- a/acceptance/air/image-push/script +++ b/acceptance/air/image-push/script @@ -47,6 +47,10 @@ trace musterr databricks air images push -p docker-test -s example/image:v1 --ca title "incompatible pulled image must not be pushed" trace musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training --pull +title "rejected push still links the registry limits" +export DOCKER_TEST_MODE=push-error +trace musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training + title "pull failure must not be pushed" export DOCKER_TEST_MODE=pull-error trace musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training --pull diff --git a/cmd/air/image.go b/cmd/air/image.go index e1811a960ed..de8e0b59e72 100644 --- a/cmd/air/image.go +++ b/cmd/air/image.go @@ -165,9 +165,9 @@ func formatImageSize(sizeBytes int64) string { return fmt.Sprintf("%.1f GB", float64(sizeBytes)/1e9) } -// logCompressedImageSize prints the compressed size and layer count from the pushed manifest, -// which is what DAR measures; the local image store only knows the uncompressed size. -func logCompressedImageSize(ctx context.Context, deps imagePushDeps, dockerPath, target string) { +// logCompressedImageSize prints the compressed size and layer count from the pushed manifest of the +// given platform. The registry stores compressed layers; the local image store only knows the uncompressed size. +func logCompressedImageSize(ctx context.Context, deps imagePushDeps, dockerPath, target, platform string) { var manifest, errOut bytes.Buffer if err := deps.runCommand(ctx, nil, &manifest, &errOut, dockerPath, "manifest", "inspect", "--verbose", target); err != nil { detail, _, _ := strings.Cut(strings.TrimSpace(errOut.String()), "\n") @@ -177,7 +177,7 @@ func logCompressedImageSize(ctx context.Context, deps imagePushDeps, dockerPath, cmdio.LogString(ctx, fmt.Sprintf("Warning: could not read the compressed size of %s: %s", target, detail)) return } - sizeBytes, layers, err := compressedImageSize(manifest.Bytes()) + sizeBytes, layers, err := compressedImageSize(manifest.Bytes(), platform) if err != nil { cmdio.LogString(ctx, fmt.Sprintf("Warning: could not read the compressed size of %s: %v", target, err)) return @@ -203,8 +203,8 @@ type verboseManifest struct { } // compressedImageSize sums the layer sizes in `docker manifest inspect --verbose` output. That -// output is one object for an image manifest and an array for an index, whose linux/amd64 entry is used. -func compressedImageSize(output []byte) (int64, int, error) { +// output is one object for an image manifest and an array for an index, whose entry for platform is used. +func compressedImageSize(output []byte, platform string) (int64, int, error) { output = bytes.TrimSpace(output) var entries []verboseManifest if bytes.HasPrefix(output, []byte("[")) { @@ -219,7 +219,7 @@ func compressedImageSize(output []byte) (int64, int, error) { entries = []verboseManifest{entry} } for _, e := range entries { - if p := e.Descriptor.Platform; p != nil && p.OS+"/"+p.Architecture != airImagePlatform { + if p := e.Descriptor.Platform; p != nil && p.OS+"/"+p.Architecture != platform { continue } m := e.OCIManifest @@ -235,7 +235,7 @@ func compressedImageSize(output []byte) (int64, int, error) { } return sizeBytes, len(m.Layers), nil } - return 0, 0, fmt.Errorf("no %s image manifest with layers", airImagePlatform) + return 0, 0, fmt.Errorf("no %s image manifest with layers", platform) } // darLimitationsURL returns the DAR limitations docs for the workspace's cloud. @@ -313,15 +313,17 @@ func runImagePush(cmd *cobra.Command, opts *imagePushOptions, deps imagePushDeps if err := deps.runCommand(ctx, cmd.InOrStdin(), cmd.ErrOrStderr(), cmd.ErrOrStderr(), dockerPath, "tag", resolved.source, target); err != nil { return fmt.Errorf("tag source image %s: %w", resolved.source, err) } + // DAR sets and may change its own limits, so the CLI links them instead of enforcing one. + limitsLink := "For Databricks Artifact Registry image limits, see " + darLimitationsURL(w.Config) cmdio.LogProgress(ctx, "Pushing image to "+target) if err := deps.runCommand(ctx, cmd.InOrStdin(), cmd.ErrOrStderr(), cmd.ErrOrStderr(), dockerPath, "push", target); err != nil { + cmdio.LogString(ctx, limitsLink) return fmt.Errorf("push image %s: %w", target, err) } cmdio.LogString(ctx, "Pushed image.") - logCompressedImageSize(ctx, deps, dockerPath, target) - // DAR sets and may change its own limits, so the CLI links them instead of enforcing one. - cmdio.LogString(ctx, "For Databricks Artifact Registry image limits, see "+darLimitationsURL(w.Config)) + logCompressedImageSize(ctx, deps, dockerPath, target, platform) + cmdio.LogString(ctx, limitsLink) if root.OutputType(cmd) == flags.OutputJSON { return renderEnvelope(ctx, struct { UnityCatalogImage string `json:"unity_catalog_image"` diff --git a/cmd/air/image_test.go b/cmd/air/image_test.go index 96f99f4b676..ff81a6e592c 100644 --- a/cmd/air/image_test.go +++ b/cmd/air/image_test.go @@ -2,6 +2,7 @@ package aircmd import ( "bytes" + "cmp" "context" "errors" "io" @@ -102,11 +103,12 @@ func TestFormatImageSize(t *testing.T) { func TestCompressedImageSize(t *testing.T) { tests := []struct { - name string - output string - size int64 - layers int - wantErr string + name string + output string + size int64 + layers int + platform string + wantErr string }{ { name: "image manifest", @@ -125,6 +127,13 @@ func TestCompressedImageSize(t *testing.T) { {"Descriptor":{"platform":{"architecture":"unknown","os":"unknown"}},"OCIManifest":{"layers":[{"size":9}]}}]`, size: 18, layers: 3, }, + { + name: "index uses the requested platform", + output: `[{"Descriptor":{"platform":{"architecture":"amd64","os":"linux"}},"OCIManifest":{"layers":[{"size":5}]}}, + {"Descriptor":{"platform":{"architecture":"arm64","os":"linux"}},"OCIManifest":{"layers":[{"size":1},{"size":2}]}}]`, + platform: "linux/arm64", + size: 3, layers: 2, + }, { name: "index without linux/amd64", output: `[{"Descriptor":{"platform":{"architecture":"arm64","os":"linux"}},"OCIManifest":{"layers":[{"size":1}]}}]`, @@ -134,7 +143,7 @@ func TestCompressedImageSize(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - size, layers, err := compressedImageSize([]byte(tt.output)) + size, layers, err := compressedImageSize([]byte(tt.output), cmp.Or(tt.platform, "linux/amd64")) if tt.wantErr != "" { assert.ErrorContains(t, err, tt.wantErr) return