Browse code

service: support --mount type=bind,bind-nonrecursive

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>

Akihiro Suda authored on 2019/02/23 23:53:28
Showing 3 changed files
... ...
@@ -78,7 +78,8 @@ func containerSpecFromGRPC(c *swarmapi.ContainerSpec) *types.ContainerSpec {
78 78
 
79 79
 		if m.BindOptions != nil {
80 80
 			mount.BindOptions = &mounttypes.BindOptions{
81
-				Propagation: mounttypes.Propagation(strings.ToLower(swarmapi.Mount_BindOptions_MountPropagation_name[int32(m.BindOptions.Propagation)])),
81
+				Propagation:  mounttypes.Propagation(strings.ToLower(swarmapi.Mount_BindOptions_MountPropagation_name[int32(m.BindOptions.Propagation)])),
82
+				NonRecursive: m.BindOptions.NonRecursive,
82 83
 			}
83 84
 		}
84 85
 
... ...
@@ -331,9 +332,11 @@ func containerToGRPC(c *types.ContainerSpec) (*swarmapi.ContainerSpec, error) {
331 331
 			}
332 332
 
333 333
 			if m.BindOptions.NonRecursive {
334
-				// TODO(AkihiroSuda): NonRecursive is unsupported for Swarm-mode now because of mutual vendoring
335
-				// across moby and swarmkit. Will be available soon after the moby PR gets merged.
336
-				return nil, fmt.Errorf("invalid NonRecursive: %q", m.BindOptions.Propagation)
334
+				if mount.BindOptions == nil {
335
+					// the propagation defaults to rprivate
336
+					mount.BindOptions = &swarmapi.Mount_BindOptions{}
337
+				}
338
+				mount.BindOptions.NonRecursive = m.BindOptions.NonRecursive
337 339
 			}
338 340
 		}
339 341
 
... ...
@@ -281,7 +281,9 @@ func convertMount(m api.Mount) enginemount.Mount {
281 281
 	}
282 282
 
283 283
 	if m.BindOptions != nil {
284
-		mount.BindOptions = &enginemount.BindOptions{}
284
+		mount.BindOptions = &enginemount.BindOptions{
285
+			NonRecursive: m.BindOptions.NonRecursive,
286
+		}
285 287
 		switch m.BindOptions.Propagation {
286 288
 		case api.MountPropagationRPrivate:
287 289
 			mount.BindOptions.Propagation = enginemount.PropagationRPrivate
... ...
@@ -17,6 +17,7 @@ keywords: "API, Docker, rcli, REST, documentation"
17 17
 
18 18
 [Docker Engine API v1.41](https://docs.docker.com/engine/api/v1.41/) documentation
19 19
 
20
+* `POST /services/create` and `POST /services/{id}/update` now supports `BindOptions.NonRecursive`.
20 21
 * The `ClusterStore` and `ClusterAdvertise` fields in `GET /info` are deprecated
21 22
   and are now omitted if they contain an empty value. This change is not versioned,
22 23
   and affects all API versions if the daemon has this patch.