Skip to content

Commit 151f42a

Browse files
author
Flavio Crisciani
committed
Fix possible nil pointer exception
It is possible that the node is not yet present in the node list map. In this case just print a warning and return. The next iteration would be fine Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
1 parent fefb622 commit 151f42a

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

libnetwork/network.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,9 @@ func (n *network) validateConfiguration() error {
396396
driverOptions map[string]string
397397
opts interface{}
398398
)
399-
switch data.(type) {
400-
case map[string]interface{}:
401-
opts = data.(map[string]interface{})
402-
case map[string]string:
403-
opts = data.(map[string]string)
399+
switch t := data.(type) {
400+
case map[string]interface{}, map[string]string:
401+
opts = t
404402
}
405403
ba, err := json.Marshal(opts)
406404
if err != nil {

libnetwork/networkdb/cluster.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,12 @@ func (nDB *NetworkDB) rejoinClusterBootStrap() {
288288
return
289289
}
290290

291-
myself, _ := nDB.nodes[nDB.config.NodeID]
291+
myself, ok := nDB.nodes[nDB.config.NodeID]
292+
if !ok {
293+
nDB.RUnlock()
294+
logrus.Warnf("rejoinClusterBootstrap unable to find local node info using ID:%v", nDB.config.NodeID)
295+
return
296+
}
292297
bootStrapIPs := make([]string, 0, len(nDB.bootStrapIP))
293298
for _, bootIP := range nDB.bootStrapIP {
294299
// botostrap IPs are usually IP:port from the Join

0 commit comments

Comments
 (0)