Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.resolvConfPath = filepath.Join(c.cfg.Daemon.DataDir, "/network/files/resolv.conf")
sb.id = "ingress_sbox"
} else if sb.loadBalancerNID != "" {
sb.id = "lb_" + sb.loadBalancerNID
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do lb-<id> so that is consistent with the 1- of the overlay?

Copy link
Copy Markdown
Contributor Author

@ctelfer ctelfer Jul 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, not easily. The network namespaces in /var/run/docker/netns of the form 1-XXXXXXXXX are generated within the overlay driver and don't have actual libnetwork.Sandbox structures associated with them. The load balancer sandboxes, by contrast, are full blown libnetwork.Sandbox entities. I tried naming them lb-XXXXXXXXX first, actually, but doing so caused immediate failures. I am not sure why yet. But just changing "-" to "_" completely fixed the issue. I could change the form to be XXXXXXX_sbox perhaps if that seems preferable. WDYT?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still like more the lb prefix, it's much more explainable than the _sbox postfix

}
c.Unlock()

Expand Down
2 changes: 1 addition & 1 deletion network.go
Original file line number Diff line number Diff line change
Expand Up @@ -2126,7 +2126,7 @@ func (n *network) lbEndpointName() string {
func (n *network) createLoadBalancerSandbox() (retErr error) {
sandboxName := n.lbSandboxName()
// Mark the sandbox to be a load balancer
sbOptions := []SandboxOption{OptionLoadBalancer()}
sbOptions := []SandboxOption{OptionLoadBalancer(n.id)}
if n.ingress {
sbOptions = append(sbOptions, OptionIngress())
}
Expand Down
4 changes: 3 additions & 1 deletion sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ type sandbox struct {
ingress bool
ndotsSet bool
oslTypes []osl.SandboxType // slice of properties of this sandbox
loadBalancerNID string // NID that this SB is a load balancer for
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this actually the network id?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the network ID of the network that this sandbox load balances for. Of course, this is only set if the sandbox is specifically a load balancer sandbox. Otherwise a given sandbox is most likely a container and can belong to multiple networks.

sync.Mutex
// 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
Expand Down Expand Up @@ -1169,8 +1170,9 @@ func OptionIngress() SandboxOption {

// OptionLoadBalancer function returns an option setter for marking a
// sandbox as a load balancer sandbox.
func OptionLoadBalancer() SandboxOption {
func OptionLoadBalancer(nid string) SandboxOption {
return func(sb *sandbox) {
sb.loadBalancerNID = nid
sb.oslTypes = append(sb.oslTypes, osl.SandboxTypeLoadBalancer)
}
}
Expand Down