Signed-off-by: Pradip Dhara <pradipd@microsoft.com>
| ... | ... |
@@ -62,5 +62,5 @@ type Backend interface {
|
| 62 | 62 |
LookupImage(name string) (*types.ImageInspect, error) |
| 63 | 63 |
PluginManager() *plugin.Manager |
| 64 | 64 |
PluginGetter() *plugin.Store |
| 65 |
- GetLBAttachmentStore() *networkSettings.LBAttachmentStore |
|
| 65 |
+ GetAttachmentStore() *networkSettings.AttachmentStore |
|
| 66 | 66 |
} |
| ... | ... |
@@ -137,18 +137,18 @@ func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) {
|
| 137 | 137 |
|
| 138 | 138 |
func (e *executor) Configure(ctx context.Context, node *api.Node) error {
|
| 139 | 139 |
var ingressNA *api.NetworkAttachment |
| 140 |
- lbAttachments := make(map[string]string) |
|
| 140 |
+ attachments := make(map[string]string) |
|
| 141 | 141 |
|
| 142 |
- for _, na := range node.LbAttachments {
|
|
| 142 |
+ for _, na := range node.Attachments {
|
|
| 143 | 143 |
if na.Network.Spec.Ingress {
|
| 144 | 144 |
ingressNA = na |
| 145 | 145 |
} |
| 146 |
- lbAttachments[na.Network.ID] = na.Addresses[0] |
|
| 146 |
+ attachments[na.Network.ID] = na.Addresses[0] |
|
| 147 | 147 |
} |
| 148 | 148 |
|
| 149 | 149 |
if ingressNA == nil {
|
| 150 | 150 |
e.backend.ReleaseIngress() |
| 151 |
- return e.backend.GetLBAttachmentStore().ResetLBAttachments(lbAttachments) |
|
| 151 |
+ return e.backend.GetAttachmentStore().ResetAttachments(attachments) |
|
| 152 | 152 |
} |
| 153 | 153 |
|
| 154 | 154 |
options := types.NetworkCreate{
|
| ... | ... |
@@ -181,7 +181,7 @@ func (e *executor) Configure(ctx context.Context, node *api.Node) error {
|
| 181 | 181 |
return err |
| 182 | 182 |
} |
| 183 | 183 |
|
| 184 |
- return e.backend.GetLBAttachmentStore().ResetLBAttachments(lbAttachments) |
|
| 184 |
+ return e.backend.GetAttachmentStore().ResetAttachments(attachments) |
|
| 185 | 185 |
} |
| 186 | 186 |
|
| 187 | 187 |
// Controller returns a docker container runner. |
| ... | ... |
@@ -125,7 +125,7 @@ type Daemon struct {
|
| 125 | 125 |
hosts map[string]bool // hosts stores the addresses the daemon is listening on |
| 126 | 126 |
startupDone chan struct{}
|
| 127 | 127 |
|
| 128 |
- lbAttachmentStore network.LBAttachmentStore |
|
| 128 |
+ attachmentStore network.AttachmentStore |
|
| 129 | 129 |
} |
| 130 | 130 |
|
| 131 | 131 |
// StoreHosts stores the addresses the daemon is listening on |
| ... | ... |
@@ -491,7 +491,7 @@ func (daemon *Daemon) DaemonLeavesCluster() {
|
| 491 | 491 |
logrus.Warnf("failed to initiate ingress network removal: %v", err)
|
| 492 | 492 |
} |
| 493 | 493 |
|
| 494 |
- daemon.lbAttachmentStore.ClearLBAttachments() |
|
| 494 |
+ daemon.attachmentStore.ClearAttachments() |
|
| 495 | 495 |
} |
| 496 | 496 |
|
| 497 | 497 |
// setClusterProvider sets a component for querying the current cluster state. |
| ... | ... |
@@ -1251,7 +1251,7 @@ func fixMemorySwappiness(resources *containertypes.Resources) {
|
| 1251 | 1251 |
} |
| 1252 | 1252 |
} |
| 1253 | 1253 |
|
| 1254 |
-// GetLBAttachmentStore returns current load balancer store associated with the daemon |
|
| 1255 |
-func (daemon *Daemon) GetLBAttachmentStore() *network.LBAttachmentStore {
|
|
| 1256 |
- return &daemon.lbAttachmentStore |
|
| 1254 |
+// GetAttachmentStore returns current attachment store associated with the daemon |
|
| 1255 |
+func (daemon *Daemon) GetAttachmentStore() *network.AttachmentStore {
|
|
| 1256 |
+ return &daemon.attachmentStore |
|
| 1257 | 1257 |
} |
| ... | ... |
@@ -370,7 +370,7 @@ func (daemon *Daemon) createNetwork(create types.NetworkCreateRequest, id string |
| 370 | 370 |
daemon.LogNetworkEvent(n, "create") |
| 371 | 371 |
|
| 372 | 372 |
if agent && !n.Info().Ingress() && n.Type() == "overlay" {
|
| 373 |
- nodeIP, exists := daemon.GetLBAttachmentStore().GetLBIPForNetwork(id) |
|
| 373 |
+ nodeIP, exists := daemon.GetAttachmentStore().GetIPForNetwork(id) |
|
| 374 | 374 |
if !exists {
|
| 375 | 375 |
return nil, fmt.Errorf("Failed to find a load balancer IP to use for network: %v", id)
|
| 376 | 376 |
} |
| ... | ... |
@@ -35,35 +35,35 @@ type EndpointSettings struct {
|
| 35 | 35 |
IPAMOperational bool |
| 36 | 36 |
} |
| 37 | 37 |
|
| 38 |
-// LBAttachmentStore stores the load balancer IP address for a network id. |
|
| 39 |
-type LBAttachmentStore struct {
|
|
| 38 |
+// AttachmentStore stores the load balancer IP address for a network id. |
|
| 39 |
+type AttachmentStore struct {
|
|
| 40 | 40 |
//key: networkd id |
| 41 | 41 |
//value: load balancer ip address |
| 42 | 42 |
networkToNodeLBIP map[string]net.IP |
| 43 | 43 |
} |
| 44 | 44 |
|
| 45 |
-// ResetLBAttachments clears any exsiting load balancer IP to network mapping and |
|
| 46 |
-// sets the mapping to the given lbAttachments. |
|
| 47 |
-func (lbStore *LBAttachmentStore) ResetLBAttachments(lbAttachments map[string]string) error {
|
|
| 48 |
- lbStore.ClearLBAttachments() |
|
| 49 |
- for nid, nodeIP := range lbAttachments {
|
|
| 45 |
+// ResetAttachments clears any exsiting load balancer IP to network mapping and |
|
| 46 |
+// sets the mapping to the given attachments. |
|
| 47 |
+func (store *AttachmentStore) ResetAttachments(attachments map[string]string) error {
|
|
| 48 |
+ store.ClearAttachments() |
|
| 49 |
+ for nid, nodeIP := range attachments {
|
|
| 50 | 50 |
ip, _, err := net.ParseCIDR(nodeIP) |
| 51 | 51 |
if err != nil {
|
| 52 |
- lbStore.networkToNodeLBIP = make(map[string]net.IP) |
|
| 52 |
+ store.networkToNodeLBIP = make(map[string]net.IP) |
|
| 53 | 53 |
return errors.Wrapf(err, "Failed to parse load balancer address %s", nodeIP) |
| 54 | 54 |
} |
| 55 |
- lbStore.networkToNodeLBIP[nid] = ip |
|
| 55 |
+ store.networkToNodeLBIP[nid] = ip |
|
| 56 | 56 |
} |
| 57 | 57 |
return nil |
| 58 | 58 |
} |
| 59 | 59 |
|
| 60 |
-// ClearLBAttachments clears all the mappings of network to load balancer IP Address. |
|
| 61 |
-func (lbStore *LBAttachmentStore) ClearLBAttachments() {
|
|
| 62 |
- lbStore.networkToNodeLBIP = make(map[string]net.IP) |
|
| 60 |
+// ClearAttachments clears all the mappings of network to load balancer IP Address. |
|
| 61 |
+func (store *AttachmentStore) ClearAttachments() {
|
|
| 62 |
+ store.networkToNodeLBIP = make(map[string]net.IP) |
|
| 63 | 63 |
} |
| 64 | 64 |
|
| 65 |
-// GetLBIPForNetwork return the load balancer IP address for the given network. |
|
| 66 |
-func (lbStore *LBAttachmentStore) GetLBIPForNetwork(networkID string) (net.IP, bool) {
|
|
| 67 |
- ip, exists := lbStore.networkToNodeLBIP[networkID] |
|
| 65 |
+// GetIPForNetwork return the load balancer IP address for the given network. |
|
| 66 |
+func (store *AttachmentStore) GetIPForNetwork(networkID string) (net.IP, bool) {
|
|
| 67 |
+ ip, exists := store.networkToNodeLBIP[networkID] |
|
| 68 | 68 |
return ip, exists |
| 69 | 69 |
} |