Skip to content

Commit

Permalink
Make the block overhead configurable
Browse files Browse the repository at this point in the history
This patch will allow the user to configure the block overhead.
Currently it defaults to 0. The overhead is required when migrating to
encrypted Ceph RBD (block). The pod may see less space on the disk and
therefore the migration will fail when it tries to allocate the last
sectors. See more about encrypted Ceph RBD in:
https://docs.ceph.com/en/quincy/rbd/rbd-encryption/

The value needs to be set in the ForkliftController spec under the
value: `controller_block_overhead`. The addition will be the fixed
number provided to the size of the disk.

Signed-off-by: Liran Rotenberg <lrotenbe@redhat.com>
  • Loading branch information
liranr23 committed Dec 12, 2023
1 parent 6e9b4bd commit 8b01d3b
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 16 deletions.
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 @@ -1100,10 +1100,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 @@ -780,24 +780,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)
}
return spaceWithOverhead
}
6 changes: 6 additions & 0 deletions pkg/settings/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
SnapshotStatusCheckRate = "SNAPSHOT_STATUS_CHECK_RATE"
CDIExportTokenTTL = "CDI_EXPORT_TOKEN_TTL"
FileSystemOverhead = "FILESYSTEM_OVERHEAD"
BlockOverhead = "BLOCK_OVERHEAD"
)

// Default virt-v2v image.
Expand Down Expand Up @@ -49,6 +50,8 @@ type Migration struct {
CDIExportTokenTTL int
// FileSystem overhead in percantage
FileSystemOverhead int
// Block fixed overhead size
BlockOverhead int
}

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

return
}

0 comments on commit 8b01d3b

Please sign in to comment.