api: add TypeTmpfs to api/types/mount#26837
Conversation
|
CC @cpuguy83 |
f413b44 to
3321dc7
Compare
|
cc @stevvooe |
container/container_unix.go
Outdated
There was a problem hiding this comment.
We should have these added to container.Mountpoints now that we have a proper "Type" field.... it would also be helpful to have HostConfig.Tmpfs converted into this format like we are doing (daemon side) for stuff in Binds and Volumes.
api/types/mount/mount.go
Outdated
There was a problem hiding this comment.
:) We should just group these into a single comment above the const block describing what they are for rather than having these redundant doc strings.
api/types/mount/mount.go
Outdated
There was a problem hiding this comment.
I think swarmkit is using Mode here.
type Mount_TmpfsOptions struct {
// Size sets the size of the tmpfs, in bytes.
//
// This will be converted to an operating system specific value
// depending on the host. For example, on linux, it will be convered to
// use a 'k', 'm' or 'g' syntax. BSD, though not widely supported with
// docker, uses a straight byte value.
//
// Percentages are not supported.
SizeBytes int64 `protobuf:"varint,1,opt,name=size_bytes,json=sizeBytes,proto3" json:"size_bytes,omitempty"`
// Mode of the tmpfs upon creation
Mode os.FileMode `protobuf:"varint,2,opt,name=mode,proto3,customtype=os.FileMode" json:"mode"`
}There was a problem hiding this comment.
Yes, please no more "whatever goes in here, good luck" fields.
There was a problem hiding this comment.
ok, I'm going to change the struct definition to like this:
// TmpfsOptions defines options specific to mounts of type "tmpfs".
type TmpfsOptions struct {
// Size sets the size of the tmpfs, in bytes.
//
// This will be converted to an operating system specific value
// depending on the host. For example, on linux, it will be convered to
// use a 'k', 'm' or 'g' syntax. BSD, though not widely supported with
// docker, uses a straight byte value.
//
// Percentages are not supported.
SizeBytes int64
// Mode of the tmpfs upon creation
Mode os.FileMode
// RawOptions is the raw string passed to mount(2).
// e.g. "rw,noexec,nosuid,size=65536k"
//
// RawOptions is exclusive to other TmpfsOptions fields.
// If RawOptions has a non-empty value, other fields must have empty values.
//
// RawOptions can contain "ro" or "rw" but needs to be consistent with
// Mount.ReadOnly
RawOptions string `json:",omitempty"`
}I think we need to keep RawOptions for compatibility, WDYT?
There was a problem hiding this comment.
now TmpfsOptions is identical to the corresponding one of Swarmkit
There was a problem hiding this comment.
Could we format these to make them readable?
There was a problem hiding this comment.
Is tmpfs linux only? Windows does have ramdisk.
There was a problem hiding this comment.
AFAIK yes, linux only in the current implementation?
https://github.com/docker/docker/blob/b8265e55508db99aea632033b2f5008f921b11e2/container/container_windows.go#L89-L93
IMO implementation for Windows should be another PR, but I understand we need to design the API with consideration for Windows in this PR.
CC @jhowardmsft
There was a problem hiding this comment.
TestContainersAPICreateMountsTmpfs.
Please follow Go's naming conventions.
There was a problem hiding this comment.
It seems there is some project-local naming convention that encourages Test.*Api.*?
If not, perhaps we need to fix that in separate PR?
$ grep "func (.*Suite) Test.*Api" integration-cli/*.go | wc -l
158
$ grep "func (.*Suite) Test.*API" integration-cli/*.go | wc -l
2There was a problem hiding this comment.
Agreed; better done in a separate PR if we want to change that
There was a problem hiding this comment.
@thaJeztah This is a new test. It should follow our coding standards.
Demonstrations of others not following the standards does not make it okay to not follow the standards.
3321dc7 to
cfd8138
Compare
daemon/volumes.go
Outdated
There was a problem hiding this comment.
forgot to fix this, now fixing..
a7afeda to
3b8527a
Compare
|
Failure in windowsRS1 is trivial, I'll make sure it is skipped on Windows 00:48:59.244 ----------------------------------------------------------------------
00:48:59.245 FAIL: docker_api_containers_test.go:1525: DockerSuite.TestContainersApiCreateMountsValidation
00:48:59.245
00:48:59.245 case 0
00:48:59.245 case 1
00:48:59.245 case 2
00:48:59.245 case 3
00:48:59.245 case 4
00:48:59.245 case 5
00:48:59.245 case 6
00:48:59.245 case 7
00:48:59.245 docker_api_containers_test.go:1711:
00:48:59.245 c.Assert(status, checker.Equals, x.status, check.Commentf("%s\n%v", string(b), cases[i].config))
00:48:59.245 ... obtained int = 400
00:48:59.245 ... expected int = 201
00:48:59.246 ... {"message":"invalid mount config for type \"tmpfs\": Windows does not support tmpfs"}
00:48:59.246
00:48:59.246 {busybox {[{tmpfs c:\foo false <nil> <nil> <nil>}]}}
00:48:59.246
00:48:59.395
00:48:59.395 ---------------------------------------------------------------------- |
3b8527a to
65f23a5
Compare
container/container_unix.go
Outdated
There was a problem hiding this comment.
Why would there be a source here?
There was a problem hiding this comment.
api/types/mount/mount.go
Outdated
There was a problem hiding this comment.
Yes, please no more "whatever goes in here, good luck" fields.
65f23a5 to
d7179c8
Compare
|
updated PR: removed |
d7179c8 to
942c9cb
Compare
api/types/mount/mount.go
Outdated
| // TypeBind BIND | ||
| TypeBind Type = "bind" | ||
| // TypeVolume VOLUME | ||
| TypeBind Type = "bind" |
There was a problem hiding this comment.
Rather than remove documentation, let's actually add it in. You can copy from swarmkit.
api/types/mount/mount.go
Outdated
| type Mount struct { | ||
| Type Type `json:",omitempty"` | ||
| Type Type `json:",omitempty"` | ||
| // Source is not supported in TMPFS (must be an empty value) |
There was a problem hiding this comment.
There is more to Source than just that. This is incomplete.
api/types/mount/mount.go
Outdated
| // Mode of the tmpfs upon creation | ||
| Mode os.FileMode | ||
|
|
||
| UID uint32 |
There was a problem hiding this comment.
How can any of this possibly be supported if we don't have support in swarmkit? https://github.com/docker/swarmkit/blob/master/api/types.proto#L191
There was a problem hiding this comment.
they are for non-swarm containers, and imo they are still needed for compatibility; old tmpfs allowed these options
WDYT?
There was a problem hiding this comment.
These were not supported with tmpfs previously. Do not add them in this PR. You can have a similar comment as I have in swarmkit, but please don't add things that aren't actually supportable.
There was a problem hiding this comment.
It seems supported it in Docker 1.12.2, WDYT?
$ docker run -it --rm --tmpfs /foo:uid=4242,nr_inodes=3 busybox
/ # ls -ld /foo
drwxrwxrwt 2 4242 root 40 Oct 14 05:10 /foo
/ # touch /foo/1
/ # touch /foo/2
/ # touch /foo/3
touch: /foo/3: No space left on deviceThere was a problem hiding this comment.
They are not currently supported for swarmkit. I am not sure what to say about docker run. These options are in no way portable.
There was a problem hiding this comment.
OK, I removed them in the latest commit
volume/volume_unix.go
Outdated
| } | ||
| if opt.INodes != 0 { | ||
| switch os { | ||
| case "linux": |
There was a problem hiding this comment.
Use build tags to do this.
There was a problem hiding this comment.
removed the code itself
volume/volume_unix_test.go
Outdated
| mounttypes "github.com/docker/docker/api/types/mount" | ||
| ) | ||
|
|
||
| func TestRawTmpfsOptions(t *testing.T) { |
volume/volume_unix.go
Outdated
| rawOpts = append(rawOpts, fmt.Sprintf("size=%d%s", size, suffix)) | ||
| } | ||
| if opt.UID != 0 { | ||
| rawOpts = append(rawOpts, fmt.Sprintf("uid=%d", opt.UID)) |
There was a problem hiding this comment.
TODO
Check nil instead of zero
There was a problem hiding this comment.
removed the code itself
api/types/mount/mount.go
Outdated
| GID uint32 | ||
| Blocks int64 | ||
| INodes int64 | ||
| MemoryPolicy string |
There was a problem hiding this comment.
What is the contents of MemoryPolicy?
There was a problem hiding this comment.
I removed it in the latest commit, but it meant mpol for Linux tmpfs
https://linux.die.net/man/8/mount
mpol=[default|prefer:Node|bind:NodeList|interleave|interleave:NodeList]
e1c9452 to
1af22c3
Compare
|
updated PR #26837 (comment) |
cpuguy83
left a comment
There was a problem hiding this comment.
Pretty happy with this, just one minor change and I think we'll be ready to roll.
volume/validate.go
Outdated
There was a problem hiding this comment.
Please use errExtraField instead of fmt.Errorf
|
The fact that Thanks for the solid PR! |
|
ping @AkihiroSuda can you address @cpuguy83's nit (#26837 (comment)), then it looks like we're ready to go |
|
@thaJeztah done |
|
updated docs/reference/api as well |
Signed-off-by: Akihiro Suda <[email protected]>
| - **Options** - key/value map of driver specific options. | ||
| - **TmpfsOptions** – Optional configuration for the `tmpfs` type. | ||
| - **SizeBytes** – The size for the tmpfs mount in bytes. | ||
| - **Mode** – The permission mode for the tmpfs mount in an integer. |
There was a problem hiding this comment.
Not for this PR, but I think we should update the JSON example with some mounts
There was a problem hiding this comment.
(because we currently don't have an example in there it seems)
thaJeztah
left a comment
There was a problem hiding this comment.
docs LGTM, thanks so much @AkihiroSuda!
- What I did
added
TypeTmpfstoapi/types/mount.TODO: migrate Swarmkit and CLI to use the new mount API
- How I did it
- How to verify it
TESTFLAGS='-check.f TestContainersApiCreateMounts' make test-integration-cli- Description for the changelog
api: add TypeTmpfs to api/types/mount
- A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: Akihiro Suda [email protected]