fix panic on storage failed get host (#7390)

This commit is contained in:
wanyaoqi
2020-07-31 16:44:01 +08:00
committed by GitHub
parent 0deb908ac7
commit d6fdf33614
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -4970,7 +4970,7 @@ func (host *SHost) switchWithBackup(ctx context.Context, userCred mcclient.Token
guests2 := host.GetGuestsBackupOnThisHost()
for i := 0; i < len(guests2); i++ {
if guests2[i].isInReconcile(userCred) {
log.Warningf("guest %s is in reconcile", guests[i].GetName())
log.Warningf("guest %s is in reconcile", guests2[i].GetName())
continue
}
data := jsonutils.NewDict()
+3
View File
@@ -211,6 +211,9 @@ func (self *SRbdStorageDriver) RequestCreateSnapshot(ctx context.Context, snapsh
func (self *SRbdStorageDriver) RequestDeleteSnapshot(ctx context.Context, snapshot *models.SSnapshot, task taskman.ITask) error {
storage := snapshot.GetStorage()
host := storage.GetMasterHost()
if host == nil {
return errors.Errorf("storage %s can't get master host", storage.Id)
}
url := fmt.Sprintf("%s/disks/%s/delete-snapshot/%s", host.ManagerUri, storage.Id, snapshot.DiskId)
header := task.GetTaskRequestHeader()
params := jsonutils.NewDict()