mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-24 23:41:52 +08:00
fix(region): redis master zone empty fix
This commit is contained in:
@@ -246,11 +246,13 @@ func (self *SElasticcache) GetVpcId() string {
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetZoneId() string {
|
||||
zone, err := self.region.getZoneById(transZoneIdToEcsZoneId(self.region, "redis", self.ZoneID))
|
||||
zoneId := transZoneIdToEcsZoneId(self.region, "redis", self.ZoneID)
|
||||
zone, err := self.region.getZoneById(fetchMasterZoneId(zoneId))
|
||||
if err != nil {
|
||||
log.Errorf("failed to find zone for elasticcache %s error: %v", self.GetId(), err)
|
||||
return ""
|
||||
}
|
||||
|
||||
return zone.GetGlobalId()
|
||||
}
|
||||
|
||||
|
||||
@@ -479,3 +479,17 @@ func transRegionIdFromEcsRegionId(region *SRegion, service string) string {
|
||||
|
||||
return region.GetId()
|
||||
}
|
||||
|
||||
func fetchMasterZoneId(zoneId string) string {
|
||||
// cn-shenzhen-finance-1MAZ2(d,e)
|
||||
i := strings.Index(zoneId, "MAZ")
|
||||
if i > 0 {
|
||||
s := strings.Index(zoneId, "(")
|
||||
e := strings.Index(zoneId, ",")
|
||||
if s >= 0 && e >= 0 {
|
||||
return zoneId[0:i] + zoneId[s+1:e]
|
||||
}
|
||||
}
|
||||
|
||||
return zoneId
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user