mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user