mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
fix(region): purge manager quota (#21478)
This commit is contained in:
@@ -63,6 +63,10 @@ func (self *SCloudregion) purgeAll(ctx context.Context, managerId string) error
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "purgeResources")
|
||||
}
|
||||
err = self.purgeQuotas(ctx, managerId)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "purgeQuotas")
|
||||
}
|
||||
|
||||
// fix #20036 避免regional子网未删除, 导致zone残留
|
||||
zones, err := self.GetZones()
|
||||
@@ -268,6 +272,20 @@ func (self *SNatGateway) purge(ctx context.Context, userCred mcclient.TokenCrede
|
||||
return self.SInfrasResourceBase.Delete(ctx, userCred)
|
||||
}
|
||||
|
||||
func (self *SCloudregion) purgeQuotas(ctx context.Context, managerId string) error {
|
||||
quotas := CloudproviderQuotaManager.Query("id").Equals("manager_id", managerId).Equals("cloudregion_id", self.Id)
|
||||
pairs := []purgePair{
|
||||
{manager: CloudproviderQuotaManager, key: "id", q: quotas},
|
||||
}
|
||||
for i := range pairs {
|
||||
err := pairs[i].purgeAll(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SCloudregion) purgeResources(ctx context.Context, managerId string) error {
|
||||
buckets := BucketManager.Query("id").Equals("manager_id", managerId).Equals("cloudregion_id", self.Id)
|
||||
ess := ElasticSearchManager.Query("id").Equals("manager_id", managerId).Equals("cloudregion_id", self.Id)
|
||||
@@ -903,8 +921,10 @@ func (cprvd *SCloudprovider) purge(ctx context.Context, userCred mcclient.TokenC
|
||||
dnszones := DnsZoneManager.Query("id").Equals("manager_id", cprvd.Id)
|
||||
records := DnsRecordManager.Query("id").In("dns_zone_id", dnszones.SubQuery())
|
||||
dnsVpcs := DnsZoneVpcManager.Query("row_id").In("dns_zone_id", dnszones.SubQuery())
|
||||
quotas := CloudproviderQuotaManager.Query("id").Equals("manager_id", cprvd.Id)
|
||||
|
||||
pairs := []purgePair{
|
||||
{manager: CloudproviderQuotaManager, key: "id", q: quotas},
|
||||
{manager: DnsZoneVpcManager, key: "row_id", q: dnsVpcs},
|
||||
{manager: DnsRecordManager, key: "id", q: records},
|
||||
{manager: DnsZoneManager, key: "id", q: dnszones},
|
||||
|
||||
Reference in New Issue
Block a user