Merge pull request #45912 from corhere/backport-23.0/fix-volume-npe
This commit is contained in:
commit
5f99559987
2 changed files with 22 additions and 0 deletions
|
@ -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,
|
||||
|
|
|
@ -452,6 +452,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) {
|
||||
|
|
Loading…
Reference in a new issue