mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Properly identify ingress network created with older swarm
- otherwise docker network prune will remove it Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
parent
01af41ed99
commit
93763f11ee
2 changed files with 14 additions and 3 deletions
|
@ -29,7 +29,7 @@ func networkFromGRPC(n *swarmapi.Network) types.Network {
|
|||
IPv6Enabled: n.Spec.Ipv6Enabled,
|
||||
Internal: n.Spec.Internal,
|
||||
Attachable: n.Spec.Attachable,
|
||||
Ingress: n.Spec.Ingress,
|
||||
Ingress: IsIngressNetwork(n),
|
||||
IPAMOptions: ipamFromGRPC(n.Spec.IPAM),
|
||||
Scope: netconst.SwarmScope,
|
||||
},
|
||||
|
@ -165,7 +165,7 @@ func BasicNetworkFromGRPC(n swarmapi.Network) basictypes.NetworkResource {
|
|||
IPAM: ipam,
|
||||
Internal: spec.Internal,
|
||||
Attachable: spec.Attachable,
|
||||
Ingress: spec.Ingress,
|
||||
Ingress: IsIngressNetwork(&n),
|
||||
Labels: n.Spec.Annotations.Labels,
|
||||
}
|
||||
|
||||
|
@ -225,3 +225,13 @@ func BasicNetworkCreateToGRPC(create basictypes.NetworkCreateRequest) swarmapi.N
|
|||
}
|
||||
return ns
|
||||
}
|
||||
|
||||
// IsIngressNetwork check if the swarm network is an ingress network
|
||||
func IsIngressNetwork(n *swarmapi.Network) bool {
|
||||
if n.Spec.Ingress {
|
||||
return true
|
||||
}
|
||||
// Check if legacy defined ingress network
|
||||
_, ok := n.Spec.Annotations.Labels["com.docker.swarm.internal"]
|
||||
return ok && n.Spec.Annotations.Name == "ingress"
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
enginemount "github.com/docker/docker/api/types/mount"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
volumetypes "github.com/docker/docker/api/types/volume"
|
||||
"github.com/docker/docker/daemon/cluster/convert"
|
||||
executorpkg "github.com/docker/docker/daemon/cluster/executor"
|
||||
clustertypes "github.com/docker/docker/daemon/cluster/provider"
|
||||
"github.com/docker/go-connections/nat"
|
||||
|
@ -590,7 +591,7 @@ func (c *containerConfig) networkCreateRequest(name string) (clustertypes.Networ
|
|||
Labels: na.Network.Spec.Annotations.Labels,
|
||||
Internal: na.Network.Spec.Internal,
|
||||
Attachable: na.Network.Spec.Attachable,
|
||||
Ingress: na.Network.Spec.Ingress,
|
||||
Ingress: convert.IsIngressNetwork(na.Network),
|
||||
EnableIPv6: na.Network.Spec.Ipv6Enabled,
|
||||
CheckDuplicate: true,
|
||||
Scope: netconst.SwarmScope,
|
||||
|
|
Loading…
Add table
Reference in a new issue