mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #1678 from aboch/cingr
Expose ingress network option
This commit is contained in:
commit
4bca322c68
2 changed files with 31 additions and 5 deletions
|
@ -682,6 +682,10 @@ func (c *controller) NewNetwork(networkType, name string, id string, options ...
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if network.ingress && cap.DataScope != datastore.GlobalScope {
|
||||||
|
return nil, types.ForbiddenErrorf("Ingress network can only be global scope network")
|
||||||
|
}
|
||||||
|
|
||||||
if cap.DataScope == datastore.GlobalScope && !c.isDistributedControl() && !network.dynamic {
|
if cap.DataScope == datastore.GlobalScope && !c.isDistributedControl() && !network.dynamic {
|
||||||
if c.isManager() {
|
if c.isManager() {
|
||||||
// For non-distributed controlled environment, globalscoped non-dynamic networks are redirected to Manager
|
// For non-distributed controlled environment, globalscoped non-dynamic networks are redirected to Manager
|
||||||
|
@ -1161,15 +1165,29 @@ func (c *controller) clearIngress(clusterLeave bool) {
|
||||||
c.ingressSandbox = nil
|
c.ingressSandbox = nil
|
||||||
c.Unlock()
|
c.Unlock()
|
||||||
|
|
||||||
|
var n *network
|
||||||
if ingressSandbox != nil {
|
if ingressSandbox != nil {
|
||||||
|
for _, ep := range ingressSandbox.getConnectedEndpoints() {
|
||||||
|
if nw := ep.getNetwork(); nw.ingress {
|
||||||
|
n = nw
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
if err := ingressSandbox.Delete(); err != nil {
|
if err := ingressSandbox.Delete(); err != nil {
|
||||||
logrus.Warnf("Could not delete ingress sandbox while leaving: %v", err)
|
logrus.Warnf("Could not delete ingress sandbox while leaving: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err := c.NetworkByName("ingress")
|
if n == nil {
|
||||||
if err != nil && clusterLeave {
|
for _, nw := range c.Networks() {
|
||||||
logrus.Warnf("Could not find ingress network while leaving: %v", err)
|
if nw.Info().Ingress() {
|
||||||
|
n = nw.(*network)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if n == nil && clusterLeave {
|
||||||
|
logrus.Warnf("Could not find ingress network while leaving")
|
||||||
}
|
}
|
||||||
|
|
||||||
if n != nil {
|
if n != nil {
|
||||||
|
|
|
@ -66,6 +66,7 @@ type NetworkInfo interface {
|
||||||
IPv6Enabled() bool
|
IPv6Enabled() bool
|
||||||
Internal() bool
|
Internal() bool
|
||||||
Attachable() bool
|
Attachable() bool
|
||||||
|
Ingress() bool
|
||||||
Labels() map[string]string
|
Labels() map[string]string
|
||||||
Dynamic() bool
|
Dynamic() bool
|
||||||
Created() time.Time
|
Created() time.Time
|
||||||
|
@ -615,9 +616,9 @@ func NetworkOptionGeneric(generic map[string]interface{}) NetworkOption {
|
||||||
|
|
||||||
// NetworkOptionIngress returns an option setter to indicate if a network is
|
// NetworkOptionIngress returns an option setter to indicate if a network is
|
||||||
// an ingress network.
|
// an ingress network.
|
||||||
func NetworkOptionIngress() NetworkOption {
|
func NetworkOptionIngress(ingress bool) NetworkOption {
|
||||||
return func(n *network) {
|
return func(n *network) {
|
||||||
n.ingress = true
|
n.ingress = ingress
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1589,6 +1590,13 @@ func (n *network) Attachable() bool {
|
||||||
return n.attachable
|
return n.attachable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *network) Ingress() bool {
|
||||||
|
n.Lock()
|
||||||
|
defer n.Unlock()
|
||||||
|
|
||||||
|
return n.ingress
|
||||||
|
}
|
||||||
|
|
||||||
func (n *network) Dynamic() bool {
|
func (n *network) Dynamic() bool {
|
||||||
n.Lock()
|
n.Lock()
|
||||||
defer n.Unlock()
|
defer n.Unlock()
|
||||||
|
|
Loading…
Add table
Reference in a new issue