Skip to content

Conversation

@laurazard
Copy link
Member

@laurazard laurazard commented Feb 1, 2024

- What I did

Added a test for, and fixed a panic at:

moby/plugin/fetch_linux.go

Lines 202 to 203 in 71fa3ab

tn := reference.TagNameOnly(ref)
tagged := tn.(reference.Tagged)

when doing something like:

docker plugin install vieux/sshfs@sha256:1d3c3e42c12138da5ef7873b97f7f32cf99fb6edde75fa4f0bcf9ed277855811

By checking if the cast is safe, and only printing the tag if there is a tag to print.

- How I did it
With tag:

 docker plugin install vieux/sshfs
Plugin "vieux/sshfs" is requesting the following privileges:
 - network: [host]
 - mount: [/var/lib/docker/plugins/]
 - mount: []
 - device: [/dev/fuse]
 - capabilities: [CAP_SYS_ADMIN]
Do you grant the above permissions? [y/N] y
latest: Pulling from vieux/sshfs
Digest: sha256:1d3c3e42c12138da5ef7873b97f7f32cf99fb6edde75fa4f0bcf9ed277855811
52d435ada6a4: Complete
Installed plugin vieux/sshfs

With digest:

 docker plugin install vieux/sshfs@sha256:1d3c3e42c12138da5ef7873b97f7f32cf99fb6edde75fa4f0bcf9ed277855811
Plugin "vieux/sshfs@sha256:1d3c3e42c12138da5ef7873b97f7f32cf99fb6edde75fa4f0bcf9ed277855811" is requesting the following privileges:
 - network: [host]
 - mount: [/var/lib/docker/plugins/]
 - mount: []
 - device: [/dev/fuse]
 - capabilities: [CAP_SYS_ADMIN]
Do you grant the above permissions? [y/N] y
Pulling from vieux/sshfs
Digest: sha256:1d3c3e42c12138da5ef7873b97f7f32cf99fb6edde75fa4f0bcf9ed277855811
52d435ada6a4: Complete
Installed plugin vieux/sshfs@sha256:1d3c3e42c12138da5ef7873b97f7f32cf99fb6edde75fa4f0bcf9ed277855811

- How to verify it

$ make DOCKER_GRAPHDRIVER=overlayfs TEST_FILTER=TestPluginInstall TEST_IGNORE_CGROUP_CHECK=1 test-integration

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

Screenshot 2024-02-01 at 20 02 48

@krissetto krissetto mentioned this pull request Feb 1, 2024
@laurazard laurazard force-pushed the plugin-install-digest branch 2 times, most recently from ef368e2 to 58609d3 Compare February 1, 2024 23:00
Adds a test case for installing a plugin from a remote in the form
of `plugin-content-trust@sha256:d98f2f8061...`, which is currently
causing the daemon to panic, as we found while running the CLI e2e
tests:

```
docker plugin install registry:5000/plugin-content-trust@sha256:d98f2f806144bf4ba62d4ecaf78fec2f2fe350df5a001f6e3b491c393326aedb
```

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
@laurazard laurazard force-pushed the plugin-install-digest branch from 58609d3 to 82dda18 Compare February 1, 2024 23:04
@laurazard laurazard self-assigned this Feb 1, 2024
@laurazard laurazard marked this pull request as ready for review February 2, 2024 00:10
@laurazard laurazard requested a review from cpuguy83 as a code owner February 2, 2024 00:10
@laurazard laurazard changed the title wip: fix install plugin with digest tag plugins: fix panic when fetching by digest Feb 2, 2024
@laurazard laurazard changed the title plugins: fix panic when fetching by digest plugins: Fix panic when fetching by digest Feb 2, 2024
Only print the tag when the received reference has a tag, if
we can't cast the received tag to a `reference.Tagged` then
skip printing the tag as it's likely a digest.

Fixes panic when trying to install a plugin from a reference
with a digest such as
`vieux/sshfs@sha256:1d3c3e42c12138da5ef7873b97f7f32cf99fb6edde75fa4f0bcf9ed277855811`

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
@laurazard laurazard force-pushed the plugin-install-digest branch from c03800a to 74d51e8 Compare February 4, 2024 20:40
@laurazard laurazard requested a review from thaJeztah February 5, 2024 02:25
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants