From 3f485c7c3133ac0844d4117191d6744aca3e69bd Mon Sep 17 00:00:00 2001 From: Qu Xuan Date: Tue, 20 Apr 2021 17:22:22 +0800 Subject: [PATCH] fix(region): avoid panic when sync aliyun networks --- pkg/multicloud/aliyun/vpc.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/multicloud/aliyun/vpc.go b/pkg/multicloud/aliyun/vpc.go index 9a5f964e3c..520b5915a1 100644 --- a/pkg/multicloud/aliyun/vpc.go +++ b/pkg/multicloud/aliyun/vpc.go @@ -115,7 +115,7 @@ func (self *SVpc) addWire(wire *SWire) { } func (self *SVpc) getWireByZoneId(zoneId string) *SWire { - for i := 0; i <= len(self.iwires); i += 1 { + for i := 0; i < len(self.iwires); i += 1 { wire := self.iwires[i].(*SWire) if wire.zone.ZoneId == zoneId { return wire @@ -137,8 +137,10 @@ func (self *SVpc) fetchVSwitches() error { } for i := 0; i < len(switches); i += 1 { wire := self.getWireByZoneId(switches[i].ZoneId) - switches[i].wire = wire - wire.addNetwork(&switches[i]) + if wire != nil { + switches[i].wire = wire + wire.addNetwork(&switches[i]) + } } return nil }