Merge pull request #9568 from wanyaoqi/automated-cherry-pick-of-#9498-upstream-release-3.5

Automated cherry pick of #9498: server migrate misc fix
This commit is contained in:
Zexi Li
2020-12-22 10:06:15 +08:00
committed by GitHub
2 changed files with 20 additions and 2 deletions
+2 -1
View File
@@ -209,7 +209,8 @@ func (self *SGuestdisk) GetJsonDescAtHost(host *SHost) jsonutils.JSONObject {
localpath := disk.GetPathAtHost(host)
if len(localpath) == 0 {
desc.Add(jsonutils.JSONTrue, "migrating")
disk.SetStatus(nil, api.DISK_START_MIGRATE, "migration")
// not used yet
// disk.SetStatus(nil, api.DISK_START_MIGRATE, "migration")
} else {
desc.Add(jsonutils.NewString(localpath), "path")
}
@@ -235,8 +235,25 @@ func (r *SRemoteFile) downloadInternal(getData bool, preChksum string) bool {
defer zlibRC.Close()
reader = zlibRC
}
var finishChan = make(chan struct{})
go func() {
defer recover()
for {
select {
case <-time.After(10 * time.Second):
info, err := fi.Stat()
if err != nil {
log.Errorf("failed stat file %s", r.tmpPath)
return
}
log.Infof("written file %s size %dM", r.tmpPath, info.Size()/1024/1024)
case <-finishChan:
return
}
}
}()
_, err = io.Copy(fi, reader)
close(finishChan)
if err != nil {
log.Errorln(err)
return false