Przeglądaj źródła

Merge pull request #38788 from AkihiroSuda/bind-nonrecursive-swarm

service: support --mount type=bind,bind-nonrecursive
Brian Goff 5 lat temu
rodzic
commit
714cba6740

+ 7 - 4
daemon/cluster/convert/container.go

@@ -78,7 +78,8 @@ func containerSpecFromGRPC(c *swarmapi.ContainerSpec) *types.ContainerSpec {
 
 		if m.BindOptions != nil {
 			mount.BindOptions = &mounttypes.BindOptions{
-				Propagation: mounttypes.Propagation(strings.ToLower(swarmapi.Mount_BindOptions_MountPropagation_name[int32(m.BindOptions.Propagation)])),
+				Propagation:  mounttypes.Propagation(strings.ToLower(swarmapi.Mount_BindOptions_MountPropagation_name[int32(m.BindOptions.Propagation)])),
+				NonRecursive: m.BindOptions.NonRecursive,
 			}
 		}
 
@@ -331,9 +332,11 @@ func containerToGRPC(c *types.ContainerSpec) (*swarmapi.ContainerSpec, error) {
 			}
 
 			if m.BindOptions.NonRecursive {
-				// TODO(AkihiroSuda): NonRecursive is unsupported for Swarm-mode now because of mutual vendoring
-				// across moby and swarmkit. Will be available soon after the moby PR gets merged.
-				return nil, fmt.Errorf("invalid NonRecursive: %q", m.BindOptions.Propagation)
+				if mount.BindOptions == nil {
+					// the propagation defaults to rprivate
+					mount.BindOptions = &swarmapi.Mount_BindOptions{}
+				}
+				mount.BindOptions.NonRecursive = m.BindOptions.NonRecursive
 			}
 		}
 

+ 3 - 1
daemon/cluster/executor/container/container.go

@@ -281,7 +281,9 @@ func convertMount(m api.Mount) enginemount.Mount {
 	}
 
 	if m.BindOptions != nil {
-		mount.BindOptions = &enginemount.BindOptions{}
+		mount.BindOptions = &enginemount.BindOptions{
+			NonRecursive: m.BindOptions.NonRecursive,
+		}
 		switch m.BindOptions.Propagation {
 		case api.MountPropagationRPrivate:
 			mount.BindOptions.Propagation = enginemount.PropagationRPrivate

+ 1 - 0
docs/api/version-history.md

@@ -17,6 +17,7 @@ keywords: "API, Docker, rcli, REST, documentation"
 
 [Docker Engine API v1.41](https://docs.docker.com/engine/api/v1.41/) documentation
 
+* `POST /services/create` and `POST /services/{id}/update` now supports `BindOptions.NonRecursive`.
 * The `ClusterStore` and `ClusterAdvertise` fields in `GET /info` are deprecated
   and are now omitted if they contain an empty value. This change is not versioned,
   and affects all API versions if the daemon has this patch.