Skip to content
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

[24.0 backport] daemon: daemon.prepareMountPoints(): fix panic if mount is not a volume #45903

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions daemon/mounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func (daemon *Daemon) prepareMountPoints(container *container.Container) error {
if err := daemon.lazyInitializeVolume(container.ID, config); err != nil {
return err
}
if config.Volume == nil {
// FIXME(thaJeztah): should we check for config.Type here as well? (i.e., skip bind-mounts etc)
continue
}
if alive {
log.G(context.TODO()).WithFields(logrus.Fields{
"container": container.ID,
Expand Down
18 changes: 18 additions & 0 deletions integration/daemon/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,24 @@ func testLiveRestoreVolumeReferences(t *testing.T) {
err = c.VolumeRemove(ctx, v.Name, false)
assert.NilError(t, err)
})

// Make sure that we don't panic if the container has bind-mounts
// (which should not be "restored")
// Regression test for https://github.com/moby/moby/issues/45898
t.Run("container with bind-mounts", func(t *testing.T) {
m := mount.Mount{
Type: mount.TypeBind,
Source: os.TempDir(),
Target: "/foo",
}
cID := container.Run(ctx, t, c, container.WithMount(m), container.WithCmd("top"))
defer c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true})

d.Restart(t, "--live-restore", "--iptables=false")

err := c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true})
assert.NilError(t, err)
})
}

func TestDaemonDefaultBridgeWithFixedCidrButNoBip(t *testing.T) {
Expand Down