From 3423557ac1dba55a50a3f5cac3f41c32e03122dc Mon Sep 17 00:00:00 2001 From: ioito Date: Wed, 19 Jun 2019 16:46:51 +0800 Subject: [PATCH] fix invalid memory address or nil pointer error --- pkg/compute/models/storagecaches.go | 2 +- pkg/util/zstack/storagecache.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/compute/models/storagecaches.go b/pkg/compute/models/storagecaches.go index bc4e8e0556..7792a676a7 100644 --- a/pkg/compute/models/storagecaches.go +++ b/pkg/compute/models/storagecaches.go @@ -378,7 +378,7 @@ func (self *SStoragecache) StartImageUncacheTask(ctx context.Context, userCred m func (self *SStoragecache) GetIStorageCache() (cloudprovider.ICloudStoragecache, error) { storages := self.getValidStorages() if len(storages) == 0 { - msg := "no storages for this storagecache???" + msg := fmt.Sprintf("no storages for this storagecache %s(%s)???", self.Name, self.Id) log.Errorf(msg) return nil, fmt.Errorf(msg) } diff --git a/pkg/util/zstack/storagecache.go b/pkg/util/zstack/storagecache.go index 9da4a23863..e35b475f65 100644 --- a/pkg/util/zstack/storagecache.go +++ b/pkg/util/zstack/storagecache.go @@ -123,6 +123,7 @@ func (self *SStoragecache) uploadImage(ctx context.Context, userCred mcclient.To if err != nil { return "", err } + img.storageCache = self err = cloudprovider.WaitStatus(img, api.CACHED_IMAGE_STATUS_READY, time.Second*5, time.Minute*10) //windows镜像转换比较慢,等待时间稍微设长一些 if err != nil { log.Errorf("waitting for image %s(%s) status ready timeout", img.Name, img.UUID)