From a0a83615b4e08ec2c2f6c60e066c46c700cc89c4 Mon Sep 17 00:00:00 2001 From: ioito Date: Thu, 12 Sep 2019 16:47:17 +0800 Subject: [PATCH] fix: avoid nil pointer --- pkg/hostman/storageman/imagecachemanager_rbd.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/hostman/storageman/imagecachemanager_rbd.go b/pkg/hostman/storageman/imagecachemanager_rbd.go index b115b97d4c..521957724f 100644 --- a/pkg/hostman/storageman/imagecachemanager_rbd.go +++ b/pkg/hostman/storageman/imagecachemanager_rbd.go @@ -18,6 +18,7 @@ package storageman import ( "context" + "fmt" "strings" "sync" @@ -116,6 +117,9 @@ func (c *SRbdImageCacheManager) PrefetchImageCache(ctx context.Context, data int zone, _ := body.GetString("zone") cache := c.AcquireImage(ctx, imageId, zone, srcUrl, format) + if cache == nil { + return nil, fmt.Errorf("failed to cache image %s.%s", imageId, format) + } res := map[string]interface{}{ "image_id": imageId,