mirror of
https://github.com/containers/podman.git
synced 2025-06-22 18:08:11 +08:00
Merge pull request #14512 from cdoern/infraInherit
Infra Inheritance patch
This commit is contained in:
@ -542,6 +542,16 @@ func Inherit(infra libpod.Container, s *specgen.SpecGenerator, rt *libpod.Runtim
|
||||
infraConf := infra.Config()
|
||||
infraSpec := infraConf.Spec
|
||||
|
||||
// need to set compatOptions to the currently filled specgenOptions so we do not overwrite
|
||||
compatibleOptions.CapAdd = append(compatibleOptions.CapAdd, s.CapAdd...)
|
||||
compatibleOptions.CapDrop = append(compatibleOptions.CapDrop, s.CapDrop...)
|
||||
compatibleOptions.HostDeviceList = append(compatibleOptions.HostDeviceList, s.HostDeviceList...)
|
||||
compatibleOptions.ImageVolumes = append(compatibleOptions.ImageVolumes, s.ImageVolumes...)
|
||||
compatibleOptions.Mounts = append(compatibleOptions.Mounts, s.Mounts...)
|
||||
compatibleOptions.OverlayVolumes = append(compatibleOptions.OverlayVolumes, s.OverlayVolumes...)
|
||||
compatibleOptions.SelinuxOpts = append(compatibleOptions.SelinuxOpts, s.SelinuxOpts...)
|
||||
compatibleOptions.Volumes = append(compatibleOptions.Volumes, s.Volumes...)
|
||||
|
||||
compatByte, err := json.Marshal(compatibleOptions)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
|
@ -1112,4 +1112,26 @@ ENTRYPOINT ["sleep","99999"]
|
||||
|
||||
})
|
||||
|
||||
It("podman pod create infra inheritance test", func() {
|
||||
volName := "testVol1"
|
||||
volCreate := podmanTest.Podman([]string{"volume", "create", volName})
|
||||
volCreate.WaitWithDefaultTimeout()
|
||||
Expect(volCreate).Should(Exit(0))
|
||||
|
||||
session := podmanTest.Podman([]string{"pod", "create", "-v", volName + ":/vol1"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
|
||||
volName2 := "testVol2"
|
||||
volCreate = podmanTest.Podman([]string{"volume", "create", volName2})
|
||||
volCreate.WaitWithDefaultTimeout()
|
||||
Expect(volCreate).Should(Exit(0))
|
||||
|
||||
session = podmanTest.Podman([]string{"run", "--pod", session.OutputToString(), "-v", volName2 + ":/vol2", ALPINE, "mount"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session.OutputToString()).Should(ContainSubstring("/vol1"))
|
||||
Expect(session.OutputToString()).Should(ContainSubstring("/vol2"))
|
||||
})
|
||||
|
||||
})
|
||||
|
Reference in New Issue
Block a user