Skip to content

Commit a862ec8

Browse files
committed
Make the block overhead configurable
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>
1 parent 5f52229 commit a862ec8

File tree

7 files changed

+27
-16
lines changed

7 files changed

+27
-16
lines changed

operator/config/manager/manager.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ spec:
6666
value: ${CDI_EXPORT_TOKEN_TTL}
6767
- name: FILESYSTEM_OVERHEAD
6868
value: ${FILESYSTEM_OVERHEAD}
69+
- name: BLOCK_OVERHEAD
70+
value: ${BLOCK_OVERHEAD}
6971
- name: POPULATOR_CONTROLLER_IMAGE
7072
value: ${POPULATOR_CONTROLLER_IMAGE}
7173
- name: OVIRT_POPULATOR_IMAGE

operator/roles/forkliftcontroller/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ controller_vsphere_incremental_backup: true
3535
controller_ovirt_warm_migration: true
3636
controller_max_vm_inflight: 20
3737
controller_filesystem_overhead: 10
38+
controller_block_overhead: 0
3839
profiler_volume_path: "/var/cache/profiler"
3940

4041
inventory_volume_path: "/var/cache/inventory"

operator/roles/forkliftcontroller/templates/controller/deployment-controller.yml.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ spec:
8080
- name: FILESYSTEM_OVERHEAD
8181
value: "{{ controller_filesystem_overhead }}"
8282
{% endif %}
83+
{% if controller_block_overhead is number %}
84+
- name: BLOCK_OVERHEAD
85+
value: "{{ controller_block_overhead }}"
86+
{% endif %}
8387
{% if controller_vsphere_incremental_backup|bool %}
8488
- name: FEATURE_VSPHERE_INCREMENTAL_BACKUP
8589
value: "true"

pkg/controller/plan/adapter/openstack/builder.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,10 +1098,7 @@ func (r *Builder) persistentVolumeClaimWithSourceRef(image model.Image, storageC
10981098
err = liberr.Wrap(err)
10991099
return
11001100
}
1101-
1102-
if *volumeMode == core.PersistentVolumeFilesystem {
1103-
virtualSize = utils.CalculateSpaceWithOverhead(virtualSize)
1104-
}
1101+
virtualSize = utils.CalculateSpaceWithOverhead(virtualSize, volumeMode)
11051102

11061103
// The image might be a VM Snapshot Image and has no volume associated to it
11071104
if originalVolumeDiskId, ok := image.Properties["forklift_original_volume_id"]; ok {

pkg/controller/plan/adapter/ovirt/builder.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -793,24 +793,19 @@ func (r *Builder) getDefaultVolumeAndAccessMode(storageClassName string) ([]core
793793
// Build a PersistentVolumeClaim with DataSourceRef for VolumePopulator
794794
func (r *Builder) persistentVolumeClaimWithSourceRef(diskAttachment model.XDiskAttachment, storageClassName string, populatorName string,
795795
annotations map[string]string) (pvc *core.PersistentVolumeClaim, err error) {
796-
797-
// We add 10% overhead because of the fsOverhead in CDI, around 5% to ext4 and 5% for root partition.
798-
// This value is configurable using `FILESYSTEM_OVERHEAD`
799796
diskSize := diskAttachment.Disk.ProvisionedSize
800-
801797
var accessModes []core.PersistentVolumeAccessMode
802798
var volumeMode *core.PersistentVolumeMode
803799
accessModes, volumeMode, err = r.getDefaultVolumeAndAccessMode(storageClassName)
804800
if err != nil {
805801
err = liberr.Wrap(err)
806802
return
807803
}
808-
809-
// Accounting for fsOverhead is only required for `volumeMode: Filesystem`, as we may not have enough space
810-
// after creating a filesystem on an underlying block device
811-
if *volumeMode == core.PersistentVolumeFilesystem {
812-
diskSize = utils.CalculateSpaceWithOverhead(diskSize)
813-
}
804+
// We add 10% overhead because of the fsOverhead in CDI, around 5% to ext4 and 5% for root partition.
805+
// This value is configurable using `FILESYSTEM_OVERHEAD`
806+
// Encrypted Ceph RBD makes the pod see less space, this possible overhead needs to be taken into account.
807+
// For Block the value is configurable using `BLOCK_OVERHEAD`
808+
diskSize = utils.CalculateSpaceWithOverhead(diskSize, volumeMode)
814809

815810
annotations[AnnImportDiskId] = diskAttachment.ID
816811

pkg/controller/plan/util/utils.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"math"
55

66
"github.com/konveyor/forklift-controller/pkg/settings"
7+
core "k8s.io/api/core/v1"
78
)
89

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

23-
func CalculateSpaceWithOverhead(requestedSpace int64) int64 {
24+
func CalculateSpaceWithOverhead(requestedSpace int64, volumeMode *core.PersistentVolumeMode) int64 {
2425
alignedSize := roundUp(requestedSpace, DefaultAlignBlockSize)
25-
spaceWithOverhead := int64(math.Ceil(float64(alignedSize) / (1 - float64(settings.Settings.FileSystemOverhead)/100)))
26+
var spaceWithOverhead int64
27+
if *volumeMode == core.PersistentVolumeFilesystem {
28+
spaceWithOverhead = int64(math.Ceil(float64(alignedSize) / (1 - float64(settings.Settings.FileSystemOverhead)/100)))
29+
} else {
30+
spaceWithOverhead = alignedSize + int64(settings.Settings.BlockOverhead)
31+
}
2632
return spaceWithOverhead
2733
}

pkg/settings/migration.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const (
2020
SnapshotStatusCheckRate = "SNAPSHOT_STATUS_CHECK_RATE"
2121
CDIExportTokenTTL = "CDI_EXPORT_TOKEN_TTL"
2222
FileSystemOverhead = "FILESYSTEM_OVERHEAD"
23+
BlockOverhead = "BLOCK_OVERHEAD"
2324
)
2425

2526
// Migration settings
@@ -45,6 +46,8 @@ type Migration struct {
4546
CDIExportTokenTTL int
4647
// FileSystem overhead in percantage
4748
FileSystemOverhead int
49+
// Block fixed overhead size
50+
BlockOverhead int
4851
}
4952

5053
// Load settings.
@@ -85,6 +88,9 @@ func (r *Migration) Load() (err error) {
8588
if r.FileSystemOverhead, err = getNonNegativeEnvLimit(FileSystemOverhead, 10); err != nil {
8689
return liberr.Wrap(err)
8790
}
91+
if r.BlockOverhead, err = getNonNegativeEnvLimit(BlockOverhead, 0); err != nil {
92+
return liberr.Wrap(err)
93+
}
8894

8995
return
9096
}

0 commit comments

Comments
 (0)