region/host: fix reset ceph root disk after rebuild root (#13794)

Ceph storage disk rebuild root will rename origin disk to backing
disk, so we need use backing disk reset snapshot.

Signed-off-by: wanyaoqi <wanyaoqi1995@163.com>
This commit is contained in:
wanyaoqi
2022-03-27 11:34:35 +08:00
committed by GitHub
parent 4a13598189
commit a5c27565d5
4 changed files with 15 additions and 5 deletions
+3
View File
@@ -1209,6 +1209,9 @@ func (self *SKVMRegionDriver) GetDiskResetParams(snapshot *models.SSnapshot) *js
params.Set("snapshot_id", jsonutils.NewString(snapshot.Id))
params.Set("out_of_chain", jsonutils.NewBool(snapshot.OutOfChain))
params.Set("location", jsonutils.NewString(snapshot.Location))
if len(snapshot.BackingDiskId) > 0 {
params.Set("backing_disk_id", jsonutils.NewString(snapshot.BackingDiskId))
}
return params
}
+5 -1
View File
@@ -280,9 +280,13 @@ func (d *SRBDDisk) ResetFromSnapshot(ctx context.Context, params interface{}) (j
if !ok {
return nil, hostutils.ParamsError
}
diskId := resetParams.BackingDiskId
if len(diskId) == 0 {
diskId = d.GetId()
}
storage := d.Storage.(*SRbdStorage)
pool, _ := storage.StorageConf.GetString("pool")
return nil, storage.resetDisk(pool, d.GetId(), resetParams.SnapshotId)
return nil, storage.resetDisk(pool, diskId, resetParams.SnapshotId)
}
func (d *SRBDDisk) CreateFromRbdSnapshot(ctx context.Context, snapshot, srcDiskId, srcPool string) error {
@@ -315,9 +315,11 @@ func diskReset(ctx context.Context, storage storageman.IStorage, diskId string,
if err != nil {
return nil, httperrors.NewMissingParameterError("snapshot_id")
}
backingDiskId, _ := body.GetString("backing_disk_id")
hostutils.DelayTask(ctx, disk.ResetFromSnapshot, &storageman.SDiskReset{
SnapshotId: snapshotId,
Input: body,
SnapshotId: snapshotId,
BackingDiskId: backingDiskId,
Input: body,
})
return nil, nil
}
+3 -2
View File
@@ -36,8 +36,9 @@ func (i *SDiskCreateByDiskinfo) String() string {
}
type SDiskReset struct {
SnapshotId string
Input jsonutils.JSONObject
SnapshotId string
BackingDiskId string
Input jsonutils.JSONObject
}
type SDiskCleanupSnapshots struct {