From 87a32bfef4f9b4c3594d20dac22d0e8cf60db341 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 19 May 2021 10:02:01 -0700 Subject: [PATCH] avoid possible nil when node is disconnected from its parent fix https://github.com/chrislusf/seaweedfs/issues/2073 --- weed/topology/data_node.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/weed/topology/data_node.go b/weed/topology/data_node.go index 69f739dd5..2813f7b45 100644 --- a/weed/topology/data_node.go +++ b/weed/topology/data_node.go @@ -177,7 +177,13 @@ func (dn *DataNode) GetVolumesById(id needle.VolumeId) (vInfo storage.VolumeInfo func (dn *DataNode) GetDataCenter() *DataCenter { rack := dn.Parent() + if rack == nil { + return nil + } dcNode := rack.Parent() + if dcNode == nil { + return nil + } dcValue := dcNode.GetValue() return dcValue.(*DataCenter) }