Skip to content

Commit 742b4f2

Browse files
committed
Change controller_block_overhead to quantity
When specifying resources like disk sizes, the value is expected to represent a quantity rather than an integer so users can set values like "1Gi". Applying this to controller_block_overhead as well. Signed-off-by: Arik Hadas <ahadas@redhat.com>
1 parent b39058a commit 742b4f2

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,8 @@ spec:
8080
- name: FILESYSTEM_OVERHEAD
8181
value: "{{ controller_filesystem_overhead }}"
8282
{% endif %}
83-
{% if controller_block_overhead is number %}
8483
- name: BLOCK_OVERHEAD
8584
value: "{{ controller_block_overhead }}"
86-
{% endif %}
8785
{% if controller_vsphere_incremental_backup|bool %}
8886
- name: FEATURE_VSPHERE_INCREMENTAL_BACKUP
8987
value: "true"

pkg/controller/plan/util/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func CalculateSpaceWithOverhead(requestedSpace int64, volumeMode *core.Persisten
2727
if *volumeMode == core.PersistentVolumeFilesystem {
2828
spaceWithOverhead = int64(math.Ceil(float64(alignedSize) / (1 - float64(settings.Settings.FileSystemOverhead)/100)))
2929
} else {
30-
spaceWithOverhead = alignedSize + int64(settings.Settings.BlockOverhead)
30+
spaceWithOverhead = alignedSize + settings.Settings.BlockOverhead
3131
}
3232
return spaceWithOverhead
3333
}

pkg/settings/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ go_library(
1818
deps = [
1919
"//pkg/lib/error",
2020
"//pkg/lib/logging",
21+
"//vendor/k8s.io/apimachinery/pkg/api/resource",
2122
],
2223
)

pkg/settings/migration.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"strings"
77

88
liberr "github.com/konveyor/forklift-controller/pkg/lib/error"
9+
"k8s.io/apimachinery/pkg/api/resource"
910
)
1011

1112
// Environment variables.
@@ -47,7 +48,7 @@ type Migration struct {
4748
// FileSystem overhead in percantage
4849
FileSystemOverhead int
4950
// Block fixed overhead size
50-
BlockOverhead int
51+
BlockOverhead int64
5152
}
5253

5354
// Load settings.
@@ -88,8 +89,12 @@ func (r *Migration) Load() (err error) {
8889
if r.FileSystemOverhead, err = getNonNegativeEnvLimit(FileSystemOverhead, 10); err != nil {
8990
return liberr.Wrap(err)
9091
}
91-
if r.BlockOverhead, err = getNonNegativeEnvLimit(BlockOverhead, 0); err != nil {
92-
return liberr.Wrap(err)
92+
if overhead, ok := os.LookupEnv(BlockOverhead); ok {
93+
if quantity, err := resource.ParseQuantity(overhead); err != nil {
94+
return liberr.Wrap(err)
95+
} else if r.BlockOverhead, ok = quantity.AsInt64(); !ok {
96+
return fmt.Errorf("Block overhead is invalid: %s", overhead)
97+
}
9398
}
9499

95100
return

0 commit comments

Comments
 (0)