Merge pull request #2264 from swordqiu/hotfix/qj-qcloud-storagecache-bucket-name-too-long

fix: qcloud storagecache bucket name too long
This commit is contained in:
Yousong Zhou
2019-08-14 09:51:10 +08:00
committed by GitHub
3 changed files with 8 additions and 4 deletions
+2 -2
View File
@@ -28,8 +28,8 @@ import (
type TBucketACLType string
const (
// 100 MB
MAX_PUT_OBJECT_SIZEBYTES = int64(1000 * 1000 * 100)
// 50 MB
MAX_PUT_OBJECT_SIZEBYTES = int64(1000 * 1000 * 50)
// ACLDefault = TBucketACLType("default")
+2 -1
View File
@@ -336,7 +336,8 @@ func (self *SManagedVirtualizationHostDriver) RequestRebuildDiskOnStorage(ctx co
func (driver *SManagedVirtualizationHostDriver) IsReachStoragecacheCapacityLimit(host *models.SHost, cachedImages []models.SCachedimage) bool {
quota := host.GetHostDriver().GetStoragecacheQuota(host)
if quota > 0 && len(cachedImages) >= quota {
log.Debugf("Cached image total: %d quota: %d", len(cachedImages), quota)
if quota > 0 && len(cachedImages)+1 >= quota {
return true
}
return false
+4 -1
View File
@@ -167,7 +167,10 @@ func (self *SStoragecache) uploadImage(ctx context.Context, userCred mcclient.To
return "", err
}
bucketName := strings.ToLower(fmt.Sprintf("imgcache-%s-%s", self.region.GetId(), image.ImageId))
bucketName := strings.ReplaceAll(strings.ToLower(self.region.GetId()+image.ImageId), "-", "")
if len(bucketName) > 40 {
bucketName = bucketName[:40]
}
exists, _ := self.region.IBucketExist(bucketName)
if !exists {
log.Debugf("Bucket %s not exists, to create ...", bucketName)