mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
daemon/cluster: handle partial attachment entries during configure
We have seen a panic when re-joining a node to a swarm cluster. The cause of the issue is unknown, so we just need to add a test for nil objects and log when we get the condition. Hopefully this can prevent the crash and we can recover the config at a later time. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
785b3e3287
commit
454128c6e8
1 changed files with 10 additions and 1 deletions
|
@ -143,13 +143,22 @@ func (e *executor) Configure(ctx context.Context, node *api.Node) error {
|
||||||
attachments := make(map[string]string)
|
attachments := make(map[string]string)
|
||||||
|
|
||||||
for _, na := range node.Attachments {
|
for _, na := range node.Attachments {
|
||||||
|
if na == nil || na.Network == nil || len(na.Addresses) == 0 {
|
||||||
|
// this should not happen, but we got a panic here and don't have a
|
||||||
|
// good idea about what the underlying data structure looks like.
|
||||||
|
logrus.WithField("NetworkAttachment", fmt.Sprintf("%#v", na)).
|
||||||
|
Warnf("skipping nil or malformed node network attachment entry")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if na.Network.Spec.Ingress {
|
if na.Network.Spec.Ingress {
|
||||||
ingressNA = na
|
ingressNA = na
|
||||||
}
|
}
|
||||||
|
|
||||||
attachments[na.Network.ID] = na.Addresses[0]
|
attachments[na.Network.ID] = na.Addresses[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ingressNA == nil) && (node.Attachment != nil) {
|
if (ingressNA == nil) && (node.Attachment != nil) && (len(node.Attachment.Addresses) > 0) {
|
||||||
ingressNA = node.Attachment
|
ingressNA = node.Attachment
|
||||||
attachments[ingressNA.Network.ID] = ingressNA.Addresses[0]
|
attachments[ingressNA.Network.ID] = ingressNA.Addresses[0]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue