Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose virtual size of backing images (backport #2680) #2722

Merged
merged 3 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion controller/backing_image_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,28 @@ func (bic *BackingImageController) syncBackingImageFileInfo(bi *longhorn.Backing
bic.eventRecorder.Eventf(bi, corev1.EventTypeNormal, constant.EventReasonUpdate, "Set size to %v", bi.Status.Size)
}
if bi.Status.Size != info.Size {
return fmt.Errorf("found mismatching size %v reported by backing image manager %v in disk %v, the size recorded in status is %v", info.Size, bim.Name, bim.Spec.DiskUUID, bi.Status.Size)
if bi.Status.DiskFileStatusMap[bim.Spec.DiskUUID].State != longhorn.BackingImageStateFailed {
msg := fmt.Sprintf("found mismatching size %v reported by backing image manager %v in disk %v, the size recorded in status is %v",
info.Size, bim.Name, bim.Spec.DiskUUID, bi.Status.Size)
log.Error(msg)
bi.Status.DiskFileStatusMap[bim.Spec.DiskUUID].State = longhorn.BackingImageStateFailed
bi.Status.DiskFileStatusMap[bim.Spec.DiskUUID].Message = msg
}
}
}
if info.VirtualSize > 0 {
if bi.Status.VirtualSize == 0 {
bi.Status.VirtualSize = info.VirtualSize
bic.eventRecorder.Eventf(bi, corev1.EventTypeNormal, constant.EventReasonUpdate, "Set virtualSize to %v", bi.Status.VirtualSize)
}
if bi.Status.VirtualSize != info.VirtualSize {
if bi.Status.DiskFileStatusMap[bim.Spec.DiskUUID].State != longhorn.BackingImageStateFailed {
msg := fmt.Sprintf("found mismatching virtualSize %v reported by backing image manager %v in disk %v, the virtualSize recorded in status is %v",
info.VirtualSize, bim.Name, bim.Spec.DiskUUID, bi.Status.VirtualSize)
log.Error(msg)
bi.Status.DiskFileStatusMap[bim.Spec.DiskUUID].State = longhorn.BackingImageStateFailed
bi.Status.DiskFileStatusMap[bim.Spec.DiskUUID].Message = msg
}
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions engineapi/backing_image_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ func (c *BackingImageManagerClient) parseBackingImageFileInfo(bi *bimapi.Backing
return nil
}
return &longhorn.BackingImageFileInfo{
Name: bi.Name,
UUID: bi.UUID,
Size: bi.Size,
Name: bi.Name,
UUID: bi.UUID,
Size: bi.Size,
VirtualSize: bi.VirtualSize,

State: longhorn.BackingImageState(bi.Status.State),
CurrentChecksum: bi.Status.CurrentChecksum,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ require (
github.com/gorilla/websocket v1.5.1
github.com/jinzhu/copier v0.3.5
github.com/kubernetes-csi/csi-lib-utils v0.6.1
github.com/longhorn/backing-image-manager v1.5.4
github.com/longhorn/backing-image-manager v1.5.5-rc1
github.com/longhorn/backupstore v0.0.0-20240219094812-3a87ee02df77
github.com/longhorn/go-common-libs v0.0.0-20240319112414-b75404dc7fbc
github.com/longhorn/go-iscsi-helper v0.0.0-20240308033847-bc3aab599425
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1034,8 +1034,8 @@ github.com/kubernetes-csi/csi-lib-utils v0.6.1 h1:+AZ58SRSRWh2vmMoWAAGcv7x6fIyBM
github.com/kubernetes-csi/csi-lib-utils v0.6.1/go.mod h1:GVmlUmxZ+SUjVLXicRFjqWUUvWez0g0Y78zNV9t7KfQ=
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0=
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE=
github.com/longhorn/backing-image-manager v1.5.4 h1:z5eQ3r39q3VyuCSNtX2S++2tPaorsnOopKf3cjjvNzE=
github.com/longhorn/backing-image-manager v1.5.4/go.mod h1:M28iC1bpVgefAt8E72ozeE9aSwxXcoXmmIClj5zC7bo=
github.com/longhorn/backing-image-manager v1.5.5-rc1 h1:BmvqdMaoeKWien0p+3NGWM4DMnWhpm+ZQ68TKDrvdn8=
github.com/longhorn/backing-image-manager v1.5.5-rc1/go.mod h1:bus07p3/FRW45athdhF8y6ajbw3xl3SW7O0xTWVaXrw=
github.com/longhorn/backupstore v0.0.0-20240219094812-3a87ee02df77 h1:iJRq59kA22f9HIjFtY/lz5rKCorZJrrYXju70XoWdmE=
github.com/longhorn/backupstore v0.0.0-20240219094812-3a87ee02df77/go.mod h1:4cbJWtlrD2cGTQxQLtdlPTYopiJiusXH7CpOBrn/s3k=
github.com/longhorn/go-common-libs v0.0.0-20240319112414-b75404dc7fbc h1:Eh9Npc5yBcVD8E4zVQIGUtC62HcfqevrHjQ2kh7fJ/E=
Expand Down
11 changes: 11 additions & 0 deletions k8s/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ spec:
type: string
uuid:
type: string
virtualSize:
format: int64
type: integer
type: object
nullable: true
type: object
Expand Down Expand Up @@ -412,6 +415,10 @@ spec:
jsonPath: .status.size
name: Size
type: string
- description: The virtual size of the image (may be larger than file size)
jsonPath: .status.virtualSize
name: VirtualSize
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
Expand Down Expand Up @@ -479,6 +486,10 @@ spec:
type: integer
uuid:
type: string
virtualSize:
description: Virtual size of image, which may be larger than physical size. Will be zero until known (e.g. while a backing image is uploading)
format: int64
type: integer
type: object
type: object
served: true
Expand Down
4 changes: 4 additions & 0 deletions k8s/pkg/apis/longhorn/v1beta2/backingimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ type BackingImageStatus struct {
UUID string `json:"uuid"`
// +optional
Size int64 `json:"size"`
// Virtual size of image, which may be larger than physical size. Will be zero until known (e.g. while a backing image is uploading)
// +optional
VirtualSize int64 `json:"virtualSize"`
// +optional
Checksum string `json:"checksum"`
// +optional
Expand All @@ -74,6 +77,7 @@ type BackingImageStatus struct {
// +kubebuilder:printcolumn:name="UUID",type=string,JSONPath=`.status.uuid`,description="The system generated UUID"
// +kubebuilder:printcolumn:name="SourceType",type=string,JSONPath=`.spec.sourceType`,description="The source of the backing image file data"
// +kubebuilder:printcolumn:name="Size",type=string,JSONPath=`.status.size`,description="The backing image file size in each disk"
// +kubebuilder:printcolumn:name="VirtualSize",type=string,JSONPath=`.status.virtualSize`,description="The virtual size of the image (may be larger than file size)"
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`

// BackingImage is where Longhorn stores backing image object.
Expand Down
2 changes: 2 additions & 0 deletions k8s/pkg/apis/longhorn/v1beta2/backingimagemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ type BackingImageFileInfo struct {
// +optional
Size int64 `json:"size"`
// +optional
VirtualSize int64 `json:"virtualSize"`
// +optional
State BackingImageState `json:"state"`
// +optional
CurrentChecksum string `json:"currentChecksum"`
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading