fix: esxi ignore check file failure in host.getIStoragecache (#335)

This commit is contained in:
Jian Qiu
2019-04-11 14:44:08 +08:00
committed by yunion-ci-robot
parent 0c9fcb2ba4
commit c07faba68b
+11 -3
View File
@@ -565,6 +565,7 @@ func (host *SHost) newLocalStorageCache() (*SDatastoreImageCache, error) {
if err != nil {
return nil, err
}
var errmsg string
var cacheDs *SDatastore
var maxDs *SDatastore
var maxCapacity int
@@ -576,9 +577,12 @@ func (host *SHost) newLocalStorageCache() (*SDatastoreImageCache, error) {
_, err := ds.CheckFile(ctx, IMAGE_CACHE_DIR_NAME)
if err != nil {
if err != cloudprovider.ErrNotFound {
return nil, err
}
if maxCapacity < ds.GetCapacityMB() {
// return nil, err
if len(errmsg) > 0 {
errmsg += ","
}
errmsg += err.Error()
} else if maxCapacity < ds.GetCapacityMB() {
maxCapacity = ds.GetCapacityMB()
maxDs = ds
}
@@ -592,6 +596,10 @@ func (host *SHost) newLocalStorageCache() (*SDatastoreImageCache, error) {
cacheDs = maxDs
}
if cacheDs == nil {
return nil, fmt.Errorf(errmsg)
}
return &SDatastoreImageCache{
datastore: cacheDs,
host: host,