Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #33286 from aboch/ingr
Browse files Browse the repository at this point in the history
Properly identify ingress network created with older swarm
Upstream-commit: 39a604c
Component: engine
  • Loading branch information
cpuguy83 authored May 19, 2017
2 parents 845a39e + ba221c0 commit b0a3aba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 12 additions & 2 deletions components/engine/daemon/cluster/convert/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
}

Expand Down Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b0a3aba

Please sign in to comment.