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

Make the block overhead configurable #680

Merged
merged 1 commit into from
Dec 12, 2023
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
2 changes: 2 additions & 0 deletions operator/config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ spec:
value: ${CDI_EXPORT_TOKEN_TTL}
- name: FILESYSTEM_OVERHEAD
value: ${FILESYSTEM_OVERHEAD}
- name: BLOCK_OVERHEAD
value: ${BLOCK_OVERHEAD}
- name: POPULATOR_CONTROLLER_IMAGE
value: ${POPULATOR_CONTROLLER_IMAGE}
- name: OVIRT_POPULATOR_IMAGE
Expand Down
1 change: 1 addition & 0 deletions operator/roles/forkliftcontroller/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ controller_vsphere_incremental_backup: true
controller_ovirt_warm_migration: true
controller_max_vm_inflight: 20
controller_filesystem_overhead: 10
controller_block_overhead: 0
profiler_volume_path: "/var/cache/profiler"

inventory_volume_path: "/var/cache/inventory"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ spec:
- name: FILESYSTEM_OVERHEAD
value: "{{ controller_filesystem_overhead }}"
{% endif %}
{% if controller_block_overhead is number %}
- name: BLOCK_OVERHEAD
value: "{{ controller_block_overhead }}"
{% endif %}
{% if controller_vsphere_incremental_backup|bool %}
- name: FEATURE_VSPHERE_INCREMENTAL_BACKUP
value: "true"
Expand Down
5 changes: 1 addition & 4 deletions pkg/controller/plan/adapter/openstack/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1098,10 +1098,7 @@ func (r *Builder) persistentVolumeClaimWithSourceRef(image model.Image, storageC
err = liberr.Wrap(err)
return
}

if *volumeMode == core.PersistentVolumeFilesystem {
virtualSize = utils.CalculateSpaceWithOverhead(virtualSize)
}
virtualSize = utils.CalculateSpaceWithOverhead(virtualSize, volumeMode)

// The image might be a VM Snapshot Image and has no volume associated to it
if originalVolumeDiskId, ok := image.Properties["forklift_original_volume_id"]; ok {
Expand Down
15 changes: 5 additions & 10 deletions pkg/controller/plan/adapter/ovirt/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -793,24 +793,19 @@ func (r *Builder) getDefaultVolumeAndAccessMode(storageClassName string) ([]core
// Build a PersistentVolumeClaim with DataSourceRef for VolumePopulator
func (r *Builder) persistentVolumeClaimWithSourceRef(diskAttachment model.XDiskAttachment, storageClassName string, populatorName string,
annotations map[string]string) (pvc *core.PersistentVolumeClaim, err error) {

// We add 10% overhead because of the fsOverhead in CDI, around 5% to ext4 and 5% for root partition.
// This value is configurable using `FILESYSTEM_OVERHEAD`
diskSize := diskAttachment.Disk.ProvisionedSize

var accessModes []core.PersistentVolumeAccessMode
var volumeMode *core.PersistentVolumeMode
accessModes, volumeMode, err = r.getDefaultVolumeAndAccessMode(storageClassName)
if err != nil {
err = liberr.Wrap(err)
return
}

// Accounting for fsOverhead is only required for `volumeMode: Filesystem`, as we may not have enough space
// after creating a filesystem on an underlying block device
if *volumeMode == core.PersistentVolumeFilesystem {
diskSize = utils.CalculateSpaceWithOverhead(diskSize)
}
// We add 10% overhead because of the fsOverhead in CDI, around 5% to ext4 and 5% for root partition.
// This value is configurable using `FILESYSTEM_OVERHEAD`
// Encrypted Ceph RBD makes the pod see less space, this possible overhead needs to be taken into account.
// For Block the value is configurable using `BLOCK_OVERHEAD`
diskSize = utils.CalculateSpaceWithOverhead(diskSize, volumeMode)

annotations[AnnImportDiskId] = diskAttachment.ID

Expand Down
10 changes: 8 additions & 2 deletions pkg/controller/plan/util/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"math"

"github.com/konveyor/forklift-controller/pkg/settings"
core "k8s.io/api/core/v1"
)

// Disk alignment size used to align FS overhead,
Expand All @@ -20,8 +21,13 @@ func roundUp(requestedSpace, multiple int64) int64 {
return int64(partitions) * multiple
}

func CalculateSpaceWithOverhead(requestedSpace int64) int64 {
func CalculateSpaceWithOverhead(requestedSpace int64, volumeMode *core.PersistentVolumeMode) int64 {
alignedSize := roundUp(requestedSpace, DefaultAlignBlockSize)
spaceWithOverhead := int64(math.Ceil(float64(alignedSize) / (1 - float64(settings.Settings.FileSystemOverhead)/100)))
var spaceWithOverhead int64
if *volumeMode == core.PersistentVolumeFilesystem {
spaceWithOverhead = int64(math.Ceil(float64(alignedSize) / (1 - float64(settings.Settings.FileSystemOverhead)/100)))
} else {
spaceWithOverhead = alignedSize + int64(settings.Settings.BlockOverhead)
}
liranr23 marked this conversation as resolved.
Show resolved Hide resolved
return spaceWithOverhead
}
6 changes: 6 additions & 0 deletions pkg/settings/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
SnapshotStatusCheckRate = "SNAPSHOT_STATUS_CHECK_RATE"
CDIExportTokenTTL = "CDI_EXPORT_TOKEN_TTL"
FileSystemOverhead = "FILESYSTEM_OVERHEAD"
BlockOverhead = "BLOCK_OVERHEAD"
)

// Migration settings
Expand All @@ -45,6 +46,8 @@ type Migration struct {
CDIExportTokenTTL int
// FileSystem overhead in percantage
FileSystemOverhead int
// Block fixed overhead size
BlockOverhead int
}

// Load settings.
Expand Down Expand Up @@ -85,6 +88,9 @@ func (r *Migration) Load() (err error) {
if r.FileSystemOverhead, err = getNonNegativeEnvLimit(FileSystemOverhead, 10); err != nil {
return liberr.Wrap(err)
}
if r.BlockOverhead, err = getNonNegativeEnvLimit(BlockOverhead, 0); err != nil {
return liberr.Wrap(err)
}

return
}
Loading