Skip to content

Commit

Permalink
fix(region): compute binded disk count when deleting snapshotpolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
rainzm committed Oct 20, 2020
1 parent b3105a0 commit 6f1417d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/compute/models/snapshotpolicy.go
Expand Up @@ -310,11 +310,11 @@ func (sp *SSnapshotPolicy) DetachAfterDelete(ctx context.Context, userCred mccli

func (sp *SSnapshotPolicy) CustomizeDelete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) error {
// check if sp bind to some disks
sds, err := SnapshotPolicyDiskManager.FetchAllBySnapshotpolicyID(ctx, userCred, sp.GetId())
count, err := SnapshotPolicyDiskManager.FetchDiskCountBySPID(sp.Id)
if err != nil {
return errors.Wrap(err, "fetch bind info failed")
return errors.Wrap(err, "unable to FetchDiskCountBySPID")
}
if len(sds) != 0 {
if count != 0 {
return httperrors.NewBadRequestError("Couldn't delete snapshot policy binding to disks")
}
sp.SetStatus(userCred, api.SNAPSHOT_POLICY_DELETING, "")
Expand Down Expand Up @@ -350,6 +350,7 @@ func (manager *SSnapshotPolicyManager) FetchCustomizeColumns(
VirtualResourceDetails: virtRows[i],
}
rows[i] = objs[i].(*SSnapshotPolicy).getMoreDetails(rows[i])
log.Infof("details: %v", rows[i])
}

return rows
Expand Down

0 comments on commit 6f1417d

Please sign in to comment.