-
Notifications
You must be signed in to change notification settings - Fork 18.8k
image-inspect: remove Config fields that are not part of the image #48457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Keeping this in draft for now; it looks like the image-spec types use |
// FIXME(thaJeztah): this is a copy of dockerOCIImageConfigToContainerConfig in daemon/containerd: https://github.com/moby/moby/blob/6b617699c500522aa6526cfcae4558333911b11f/daemon/containerd/imagespec.go#L107-L128 | ||
func dockerOCIImageConfigToContainerConfig(cfg dockerspec.DockerOCIImageConfig) *container.Config { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was copied from
moby/daemon/containerd/imagespec.go
Lines 107 to 128 in 6b61769
func dockerOCIImageConfigToContainerConfig(cfg imagespec.DockerOCIImageConfig) *container.Config { | |
exposedPorts := make(nat.PortSet, len(cfg.ExposedPorts)) | |
for k, v := range cfg.ExposedPorts { | |
exposedPorts[nat.Port(k)] = v | |
} | |
return &container.Config{ | |
Entrypoint: cfg.Entrypoint, | |
Env: cfg.Env, | |
Cmd: cfg.Cmd, | |
User: cfg.User, | |
WorkingDir: cfg.WorkingDir, | |
ExposedPorts: exposedPorts, | |
Volumes: cfg.Volumes, | |
Labels: cfg.Labels, | |
ArgsEscaped: cfg.ArgsEscaped, //nolint:staticcheck // Ignore SA1019. Need to keep it in image. | |
StopSignal: cfg.StopSignal, | |
Healthcheck: cfg.Healthcheck, | |
OnBuild: cfg.OnBuild, | |
Shell: cfg.Shell, | |
} | |
} |
We should probably look at moving that to an internal/
package so that we can re-use those functions
@@ -53,6 +53,7 @@ func (i *ImageService) ImageInspect(ctx context.Context, refOrID string, _ backe | |||
layers = append(layers, l.String()) | |||
} | |||
|
|||
imgConfig := containerConfigToDockerOCIImageConfig(img.Config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also wondering if we should consider (and if it'd be possible) to change the image-type we store on disk to use the new type so that we don't have to perform conversion (other than when committing a container to an image)
Looks like docker-py may need an update, as I think it's checking for an empty
edit: hm.. not sure now; it's edit2: ah; It's building the first target, which doesn't have |
3df5ef6
to
6feb664
Compare
6feb664
to
c6e7214
Compare
c6e7214
to
4b7dd37
Compare
hack/make/test-docker-py
Outdated
@@ -22,6 +22,9 @@ if [ -n "$TEST_INTEGRATION_USE_SNAPSHOTTER" ]; then | |||
PY_TEST_OPTIONS="$PY_TEST_OPTIONS --deselect=tests/integration/api_build_test.py::BuildTest::test_build_squash" | |||
fi | |||
|
|||
# TODO(thaJeztah) re-enable after https://github.com/docker/docker-py/pull/3336 is in the DOCKER_PY_COMMIT release. | |||
PY_TEST_OPTIONS="$PY_TEST_OPTIONS --deselect=tests/integration/api_build_test.pyy::BuildTest::test_build_container_with_target" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arf;
PY_TEST_OPTIONS="$PY_TEST_OPTIONS --deselect=tests/integration/api_build_test.pyy::BuildTest::test_build_container_with_target" | |
PY_TEST_OPTIONS="$PY_TEST_OPTIONS --deselect=tests/integration/api_build_test.py::BuildTest::test_build_container_with_target" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead of skipping, let's just pull docker-py by commit?
Line 8 in 04d3817
: "${DOCKER_PY_COMMIT:=7.1.0}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there's a bunch of other tests that are also waiting for a new release; didn't want to include all of those in this PR (and ideally, look if we can have a new release of docker-py); let me keep that for a follow-up.
Mostly dusted-off this PR because we kept on forgetting about it 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either way, fixed the typo for now 👍
4b7dd37
to
9da4321
Compare
Looks like test is failing:
|
Heh. Looks like that test piggy-backed on the moby/integration-cli/docker_cli_by_digest_test.go Lines 188 to 189 in f4ffeb8
|
commit af0cdc3 marked these fields as deprecated and to be removed in API v1.47 (which was targeted for v28.0). We shipped v1.47 with the v27.2 release, but did not yet remove the erroneous fields, so the version to deprecate was updated to v1.48 through 3df03d8 This patch removes fields that are not part of the image by replacing the type with the Config struct from the docker image-spec. curl -s --unix-socket /var/run/docker.sock http://localhost/v1.50/images/alpine/json | jq .Config { "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], "Cmd": [ "/bin/sh" ] } curl -s --unix-socket /var/run/docker.sock http://localhost/v1.49/images/alpine/json | jq .Config { "Hostname": "", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], "Cmd": [ "/bin/sh" ], "Image": "", "Volumes": null, "WorkingDir": "", "Entrypoint": null, "OnBuild": null, "Labels": null } Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
9da4321
to
505bd61
Compare
// verify the build was ok | ||
res := inspectField(c, name, "Config.Cmd") | ||
assert.Equal(c, res, `[/bin/echo Hello World]`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it to a sanity check that the build indeed "built" (may even be redundant)
make BIND_DIR=. TEST_FILTER='TestBuildByDigest' test-integration
...
=== RUN TestDockerRegistrySuite/TestBuildByDigest
check_test.go:468: [de4fbab56e382] daemon is not started
--- PASS: TestDockerRegistrySuite (1.80s)
--- PASS: TestDockerRegistrySuite/TestBuildByDigest (1.80s)
relates to:
GET /images/{name}/json
response #47941commit af0cdc3 marked these fields as deprecated and to be removed in API v1.47 (which was targeted for v28.0). We shipped v1.47 with the v27.2 release, but did not yet remove the erroneous fields, so the version to deprecate was updated to v1.48 through 3df03d8
This patch removes fields that are not part of the image by replacing the type with the Config struct from the docker image-spec.
- What I did
- How I did it
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)