From 2c07be92a71764bf6ab179677f837ec212d662da Mon Sep 17 00:00:00 2001 From: barnettZQG Date: Mon, 2 Jul 2018 13:50:15 +0800 Subject: [PATCH] [FIX] fix volume restore bug if volume is empty. --- builder/exector/groupapp_restore.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/builder/exector/groupapp_restore.go b/builder/exector/groupapp_restore.go index fe280bdb3..ce9c09768 100644 --- a/builder/exector/groupapp_restore.go +++ b/builder/exector/groupapp_restore.go @@ -186,8 +186,11 @@ func (b *BackupAPPRestore) restoreVersionAndData(backup *dbmodel.AppBackup, appS dstDir := fmt.Sprintf("%s/data_%s/%s.zip", b.cacheDir, b.getOldServiceID(app.ServiceID), strings.Replace(volume.VolumeName, "/", "", -1)) tmpDir := fmt.Sprintf("/grdata/tmp/%s_%d", volume.ServiceID, volume.ID) if err := util.Unzip(dstDir, tmpDir); err != nil { - logrus.Errorf("restore service(%s) volume(%s) data error.%s", app.ServiceID, volume.VolumeName, err.Error()) - return err + if !strings.Contains(err.Error(), "no such file") { + logrus.Errorf("restore service(%s) volume(%s) data error.%s", app.ServiceID, volume.VolumeName, err.Error()) + return err + } + os.MkdirAll(tmpDir, 0777) } //if app type is statefulset, change pod hostpath if b.getServiceType(app.ServiceLabel) == util.StatefulServiceType {