mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #2240 from ctelfer/nice-lb-names
Give LB sandboxes predictable names
This commit is contained in:
commit
92dd7fda05
3 changed files with 6 additions and 2 deletions
|
@ -1107,6 +1107,8 @@ func (c *controller) NewSandbox(containerID string, options ...SandboxOption) (S
|
||||||
sb.config.hostsPath = filepath.Join(c.cfg.Daemon.DataDir, "/network/files/hosts")
|
sb.config.hostsPath = filepath.Join(c.cfg.Daemon.DataDir, "/network/files/hosts")
|
||||||
sb.config.resolvConfPath = filepath.Join(c.cfg.Daemon.DataDir, "/network/files/resolv.conf")
|
sb.config.resolvConfPath = filepath.Join(c.cfg.Daemon.DataDir, "/network/files/resolv.conf")
|
||||||
sb.id = "ingress_sbox"
|
sb.id = "ingress_sbox"
|
||||||
|
} else if sb.loadBalancerNID != "" {
|
||||||
|
sb.id = "lb_" + sb.loadBalancerNID
|
||||||
}
|
}
|
||||||
c.Unlock()
|
c.Unlock()
|
||||||
|
|
||||||
|
|
|
@ -2126,7 +2126,7 @@ func (n *network) lbEndpointName() string {
|
||||||
func (n *network) createLoadBalancerSandbox() (retErr error) {
|
func (n *network) createLoadBalancerSandbox() (retErr error) {
|
||||||
sandboxName := n.lbSandboxName()
|
sandboxName := n.lbSandboxName()
|
||||||
// Mark the sandbox to be a load balancer
|
// Mark the sandbox to be a load balancer
|
||||||
sbOptions := []SandboxOption{OptionLoadBalancer()}
|
sbOptions := []SandboxOption{OptionLoadBalancer(n.id)}
|
||||||
if n.ingress {
|
if n.ingress {
|
||||||
sbOptions = append(sbOptions, OptionIngress())
|
sbOptions = append(sbOptions, OptionIngress())
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,7 @@ type sandbox struct {
|
||||||
ingress bool
|
ingress bool
|
||||||
ndotsSet bool
|
ndotsSet bool
|
||||||
oslTypes []osl.SandboxType // slice of properties of this sandbox
|
oslTypes []osl.SandboxType // slice of properties of this sandbox
|
||||||
|
loadBalancerNID string // NID that this SB is a load balancer for
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
// This mutex is used to serialize service related operation for an endpoint
|
// This mutex is used to serialize service related operation for an endpoint
|
||||||
// The lock is here because the endpoint is saved into the store so is not unique
|
// The lock is here because the endpoint is saved into the store so is not unique
|
||||||
|
@ -1169,8 +1170,9 @@ func OptionIngress() SandboxOption {
|
||||||
|
|
||||||
// OptionLoadBalancer function returns an option setter for marking a
|
// OptionLoadBalancer function returns an option setter for marking a
|
||||||
// sandbox as a load balancer sandbox.
|
// sandbox as a load balancer sandbox.
|
||||||
func OptionLoadBalancer() SandboxOption {
|
func OptionLoadBalancer(nid string) SandboxOption {
|
||||||
return func(sb *sandbox) {
|
return func(sb *sandbox) {
|
||||||
|
sb.loadBalancerNID = nid
|
||||||
sb.oslTypes = append(sb.oslTypes, osl.SandboxTypeLoadBalancer)
|
sb.oslTypes = append(sb.oslTypes, osl.SandboxTypeLoadBalancer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue