Verify Endpoint.Info() before accessing it

- During concurrent operations in multihost environment,
  it is possible that the implementer of `EndpointInfo`
  is nil. It simply means the endpoint is no longer
  available in the datastore.

Signed-off-by: Alessandro Boch <aboch@docker.com>
(cherry picked from commit 54d22cbd9a04a965c935a693bf403d2c87109b5a)
This commit is contained in:
Alessandro Boch
2015-11-09 18:36:27 -05:00
committed by Tibor Vass
parent 04c79bb941
commit e1f59b5987
2 changed files with 16 additions and 3 deletions
+11 -2
View File
@@ -199,7 +199,11 @@ func buildNetworkResource(nw libnetwork.Network) *types.NetworkResource {
epl := nw.Endpoints()
for _, e := range epl {
sb := e.Info().Sandbox()
ei := e.Info()
if ei == nil {
continue
}
sb := ei.Sandbox()
if sb == nil {
continue
}
@@ -241,7 +245,12 @@ func buildEndpointResource(e libnetwork.Endpoint) types.EndpointResource {
}
er.EndpointID = e.ID()
if iface := e.Info().Iface(); iface != nil {
ei := e.Info()
if ei == nil {
return er
}
if iface := ei.Iface(); iface != nil {
if mac := iface.MacAddress(); mac != nil {
er.MacAddress = mac.String()
}
+5 -1
View File
@@ -1218,7 +1218,11 @@ func (container *Container) disconnectFromNetwork(n libnetwork.Network) error {
)
s := func(current libnetwork.Endpoint) bool {
if sb := current.Info().Sandbox(); sb != nil {
epInfo := current.Info()
if epInfo == nil {
return false
}
if sb := epInfo.Sandbox(); sb != nil {
if sb.ContainerID() == container.ID {
ep = current
sbox = sb