8000 Fix possible nil pointer exception · moby/libnetwork@6b93786 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6b93786

Browse files
Flavio CriscianithaJeztah
authored andcommitted
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> (cherry picked from commit 1954e1c) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent bda0583 commit 6b93786

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

network.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,9 @@ func (n *network) validateConfiguration() error {
389389
driverOptions map[string]string
390390
opts interface{}
391391
)
392-
switch data.(type) {
393-
case map[string]interface{}:
394-
opts = data.(map[string]interface{})
395-
case map[string]string:
396-
opts = data.(map[string]string)
392+
switch t := data.(type) {
393+
case map[string]interface{}, map[string]string:
394+
opts = t
397395
}
398396
ba, err := json.Marshal(opts)
399397
if err != nil {

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)
0