Skip to content

Commit

Permalink
Add VCH uuid into image storage usage calculation (vmware#8418)
Browse files Browse the repository at this point in the history
  • Loading branch information
wjun authored Dec 18, 2018
1 parent 9676e9f commit e2f1b28
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/apiservers/portlayer/restapi/handlers/storage_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,12 +733,12 @@ func (h *StorageHandlersImpl) StatPath(params storage.StatPathParams) middleware

}

// ListImages returns a list of images in a store
// GetImageStorageUsage returns images storage usage for this VCH
func (h *StorageHandlersImpl) GetImageStorageUsage(params storage.GetImageStorageUsageParams) middleware.Responder {
op := trace.NewOperationFromID(context.Background(), params.OpID, "GetImageStorageUsage(%s)", params.StoreName)
defer trace.End(trace.Begin("GetImageStorageUsage", op))

result, err := h.imageCache.DataStore.GetImageStorageUsage(op)
result, err := h.imageCache.DataStore.GetImageStorageUsage(op, params.StoreName)
if err != nil {
op.Errorf("Error gettting image storage usage: %s", err)
return storage.NewGetImageStorageUsageDefault(500)
Expand Down
2 changes: 1 addition & 1 deletion lib/portlayer/storage/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type ImageStorer interface {
DeleteImage(op trace.Operation, image *Image) (*Image, error)

// GetImageStorageUsage gets the image storage usage from the image store.
GetImageStorageUsage(op trace.Operation) (int64, error)
GetImageStorageUsage(op trace.Operation, storeName string) (int64, error)

storage.Resolver
storage.Importer
Expand Down
2 changes: 1 addition & 1 deletion lib/portlayer/storage/image/mock/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,6 @@ func (c *MockDataStore) DeleteImage(op trace.Operation, image *image.Image) (*im
return image, nil
}

func (c *MockDataStore) GetImageStorageUsage(op trace.Operation) (int64, error) {
func (c *MockDataStore) GetImageStorageUsage(op trace.Operation, storeName string) (int64, error) {
return 0, nil
}
4 changes: 2 additions & 2 deletions lib/portlayer/storage/image/vsphere/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,8 @@ func (v *ImageStore) ListImages(op trace.Operation, store *url.URL, IDs []string
return images, nil
}

func (v *ImageStore) GetImageStorageUsage(op trace.Operation) (int64, error) {
return v.Helper.GetFilesSize(op, "", true, "*.vmdk")
func (v *ImageStore) GetImageStorageUsage(op trace.Operation, storeName string) (int64, error) {
return v.Helper.GetFilesSize(op, v.imageStorePath(storeName), true, "*.vmdk")
}

// DeleteImage deletes an image from the image store. If the image is in
Expand Down

0 comments on commit e2f1b28

Please sign in to comment.