From d00a07b1e6d46c3cc9ef95e8b6227115830e2701 Mon Sep 17 00:00:00 2001 From: Pradip Dhara Date: Thu, 21 Sep 2017 23:04:34 -0700 Subject: [PATCH] Updating moby to correspond to naming convention used in https://github.com/docker/swarmkit/pull/2385 Signed-off-by: Pradip Dhara --- daemon/cluster/executor/backend.go | 2 +- daemon/cluster/executor/container/executor.go | 10 +++---- daemon/daemon.go | 10 +++---- daemon/network.go | 2 +- daemon/network/settings.go | 30 +++++++++---------- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/daemon/cluster/executor/backend.go b/daemon/cluster/executor/backend.go index 89952c1452..f6763d15cd 100644 --- a/daemon/cluster/executor/backend.go +++ b/daemon/cluster/executor/backend.go @@ -62,5 +62,5 @@ type Backend interface { LookupImage(name string) (*types.ImageInspect, error) PluginManager() *plugin.Manager PluginGetter() *plugin.Store - GetLBAttachmentStore() *networkSettings.LBAttachmentStore + GetAttachmentStore() *networkSettings.AttachmentStore } diff --git a/daemon/cluster/executor/container/executor.go b/daemon/cluster/executor/container/executor.go index a5bf2603d9..14e41fa837 100644 --- a/daemon/cluster/executor/container/executor.go +++ b/daemon/cluster/executor/container/executor.go @@ -137,18 +137,18 @@ func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) { func (e *executor) Configure(ctx context.Context, node *api.Node) error { var ingressNA *api.NetworkAttachment - lbAttachments := make(map[string]string) + attachments := make(map[string]string) - for _, na := range node.LbAttachments { + for _, na := range node.Attachments { if na.Network.Spec.Ingress { ingressNA = na } - lbAttachments[na.Network.ID] = na.Addresses[0] + attachments[na.Network.ID] = na.Addresses[0] } if ingressNA == nil { e.backend.ReleaseIngress() - return e.backend.GetLBAttachmentStore().ResetLBAttachments(lbAttachments) + return e.backend.GetAttachmentStore().ResetAttachments(attachments) } options := types.NetworkCreate{ @@ -181,7 +181,7 @@ func (e *executor) Configure(ctx context.Context, node *api.Node) error { return err } - return e.backend.GetLBAttachmentStore().ResetLBAttachments(lbAttachments) + return e.backend.GetAttachmentStore().ResetAttachments(attachments) } // Controller returns a docker container runner. diff --git a/daemon/daemon.go b/daemon/daemon.go index c4762d3eae..23c7b20199 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -125,7 +125,7 @@ type Daemon struct { hosts map[string]bool // hosts stores the addresses the daemon is listening on startupDone chan struct{} - lbAttachmentStore network.LBAttachmentStore + attachmentStore network.AttachmentStore } // StoreHosts stores the addresses the daemon is listening on @@ -491,7 +491,7 @@ func (daemon *Daemon) DaemonLeavesCluster() { logrus.Warnf("failed to initiate ingress network removal: %v", err) } - daemon.lbAttachmentStore.ClearLBAttachments() + daemon.attachmentStore.ClearAttachments() } // setClusterProvider sets a component for querying the current cluster state. @@ -1251,7 +1251,7 @@ func fixMemorySwappiness(resources *containertypes.Resources) { } } -// GetLBAttachmentStore returns current load balancer store associated with the daemon -func (daemon *Daemon) GetLBAttachmentStore() *network.LBAttachmentStore { - return &daemon.lbAttachmentStore +// GetAttachmentStore returns current attachment store associated with the daemon +func (daemon *Daemon) GetAttachmentStore() *network.AttachmentStore { + return &daemon.attachmentStore } diff --git a/daemon/network.go b/daemon/network.go index 92d49765c1..aa03250f90 100644 --- a/daemon/network.go +++ b/daemon/network.go @@ -370,7 +370,7 @@ func (daemon *Daemon) createNetwork(create types.NetworkCreateRequest, id string daemon.LogNetworkEvent(n, "create") if agent && !n.Info().Ingress() && n.Type() == "overlay" { - nodeIP, exists := daemon.GetLBAttachmentStore().GetLBIPForNetwork(id) + nodeIP, exists := daemon.GetAttachmentStore().GetIPForNetwork(id) if !exists { return nil, fmt.Errorf("Failed to find a load balancer IP to use for network: %v", id) } diff --git a/daemon/network/settings.go b/daemon/network/settings.go index 0d7d5baf5a..d952b2bdc6 100644 --- a/daemon/network/settings.go +++ b/daemon/network/settings.go @@ -35,35 +35,35 @@ type EndpointSettings struct { IPAMOperational bool } -// LBAttachmentStore stores the load balancer IP address for a network id. -type LBAttachmentStore struct { +// AttachmentStore stores the load balancer IP address for a network id. +type AttachmentStore struct { //key: networkd id //value: load balancer ip address networkToNodeLBIP map[string]net.IP } -// ResetLBAttachments clears any exsiting load balancer IP to network mapping and -// sets the mapping to the given lbAttachments. -func (lbStore *LBAttachmentStore) ResetLBAttachments(lbAttachments map[string]string) error { - lbStore.ClearLBAttachments() - for nid, nodeIP := range lbAttachments { +// ResetAttachments clears any exsiting load balancer IP to network mapping and +// sets the mapping to the given attachments. +func (store *AttachmentStore) ResetAttachments(attachments map[string]string) error { + store.ClearAttachments() + for nid, nodeIP := range attachments { ip, _, err := net.ParseCIDR(nodeIP) if err != nil { - lbStore.networkToNodeLBIP = make(map[string]net.IP) + store.networkToNodeLBIP = make(map[string]net.IP) return errors.Wrapf(err, "Failed to parse load balancer address %s", nodeIP) } - lbStore.networkToNodeLBIP[nid] = ip + store.networkToNodeLBIP[nid] = ip } return nil } -// ClearLBAttachments clears all the mappings of network to load balancer IP Address. -func (lbStore *LBAttachmentStore) ClearLBAttachments() { - lbStore.networkToNodeLBIP = make(map[string]net.IP) +// ClearAttachments clears all the mappings of network to load balancer IP Address. +func (store *AttachmentStore) ClearAttachments() { + store.networkToNodeLBIP = make(map[string]net.IP) } -// GetLBIPForNetwork return the load balancer IP address for the given network. -func (lbStore *LBAttachmentStore) GetLBIPForNetwork(networkID string) (net.IP, bool) { - ip, exists := lbStore.networkToNodeLBIP[networkID] +// GetIPForNetwork return the load balancer IP address for the given network. +func (store *AttachmentStore) GetIPForNetwork(networkID string) (net.IP, bool) { + ip, exists := store.networkToNodeLBIP[networkID] return ip, exists }