mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fix issue where TmpfsOptions are not sent to swarm
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
3d1383f834
commit
a5b3649bfa
2 changed files with 18 additions and 3 deletions
|
@ -64,6 +64,13 @@ func containerSpecFromGRPC(c *swarmapi.ContainerSpec) types.ContainerSpec {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if m.TmpfsOptions != nil {
|
||||
mount.TmpfsOptions = &mounttypes.TmpfsOptions{
|
||||
SizeBytes: m.TmpfsOptions.SizeBytes,
|
||||
Mode: m.TmpfsOptions.Mode,
|
||||
}
|
||||
}
|
||||
containerSpec.Mounts = append(containerSpec.Mounts, mount)
|
||||
}
|
||||
|
||||
|
@ -174,9 +181,7 @@ func containerToGRPC(c types.ContainerSpec) (*swarmapi.ContainerSpec, error) {
|
|||
mount.BindOptions = &swarmapi.Mount_BindOptions{Propagation: swarmapi.Mount_BindOptions_MountPropagation(mountPropagation)}
|
||||
} else if string(m.BindOptions.Propagation) != "" {
|
||||
return nil, fmt.Errorf("invalid MountPropagation: %q", m.BindOptions.Propagation)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if m.VolumeOptions != nil {
|
||||
|
@ -192,6 +197,13 @@ func containerToGRPC(c types.ContainerSpec) (*swarmapi.ContainerSpec, error) {
|
|||
}
|
||||
}
|
||||
|
||||
if m.TmpfsOptions != nil {
|
||||
mount.TmpfsOptions = &swarmapi.Mount_TmpfsOptions{
|
||||
SizeBytes: m.TmpfsOptions.SizeBytes,
|
||||
Mode: m.TmpfsOptions.Mode,
|
||||
}
|
||||
}
|
||||
|
||||
containerSpec.Mounts = append(containerSpec.Mounts, mount)
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretSourceTarget(c *check.C) {
|
|||
|
||||
func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *check.C) {
|
||||
d := s.AddDaemon(c, true, true)
|
||||
out, err := d.Cmd("service", "create", "--mount", "type=tmpfs,target=/foo", "busybox", "sh", "-c", "mount | grep foo; tail -f /dev/null")
|
||||
out, err := d.Cmd("service", "create", "--mount", "type=tmpfs,target=/foo,tmpfs-size=1MB", "busybox", "sh", "-c", "mount | grep foo; tail -f /dev/null")
|
||||
c.Assert(err, checker.IsNil, check.Commentf(out))
|
||||
id := strings.TrimSpace(out)
|
||||
|
||||
|
@ -152,6 +152,8 @@ func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *check.C) {
|
|||
c.Assert(mountConfig[0].Source, checker.Equals, "")
|
||||
c.Assert(mountConfig[0].Target, checker.Equals, "/foo")
|
||||
c.Assert(mountConfig[0].Type, checker.Equals, mount.TypeTmpfs)
|
||||
c.Assert(mountConfig[0].TmpfsOptions, checker.NotNil)
|
||||
c.Assert(mountConfig[0].TmpfsOptions.SizeBytes, checker.Equals, int64(1048576))
|
||||
|
||||
// check container mounts actual
|
||||
out, err = s.nodeCmd(c, task.NodeID, "inspect", "--format", "{{json .Mounts}}", task.Status.ContainerStatus.ContainerID)
|
||||
|
@ -169,4 +171,5 @@ func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *check.C) {
|
|||
out, err = s.nodeCmd(c, task.NodeID, "logs", task.Status.ContainerStatus.ContainerID)
|
||||
c.Assert(err, checker.IsNil, check.Commentf(out))
|
||||
c.Assert(strings.TrimSpace(out), checker.HasPrefix, "tmpfs on /foo type tmpfs")
|
||||
c.Assert(strings.TrimSpace(out), checker.Contains, "size=1024k")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue