From 7cb6ca3730564e54b4596a467d59a49b77727b26 Mon Sep 17 00:00:00 2001 From: Andrew Obuchowicz Date: Wed, 9 Aug 2023 08:21:05 -0400 Subject: [PATCH] fix: don't abort PVC size calculation early if volume size not defined Fix #1162 The following rules are supposed to be used when computing the per-workspace PVC size: 1. If all volumes in a devworkspace specify their size, the computed PVC size will be used. 2. If all volumes in a devworkspace either specify their size or are ephemeral, the computed PVC size will be used. 3. If at least one volume in a devworkspace specifies its size, and the computed PVC size is greater than the default per-workspace PVC size, the computed PVC size will be used. Prior to this commit, rule 3 was not being respected in cases where a volume did not define its size, but later volumes (in the volume array) did define their sizes. This commit prevents aborting the PVC size calculation too early, and modifies the test case that was relevant to rule 3 to ensure this case is accounted for. Signed-off-by: Andrew Obuchowicz --- pkg/provision/storage/perWorkspaceStorage.go | 2 +- .../uses-calculated-pvc-size-when-greater-than-default.yaml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/provision/storage/perWorkspaceStorage.go b/pkg/provision/storage/perWorkspaceStorage.go index 7b7c6fbf8..e59b81581 100644 --- a/pkg/provision/storage/perWorkspaceStorage.go +++ b/pkg/provision/storage/perWorkspaceStorage.go @@ -170,7 +170,7 @@ func getPVCSize(workspace *common.DevWorkspaceWithConfig, namespacedConfig *nsco if component.Volume.Size == "" { allVolumeSizesDefined = false - break + continue } volumeSize, err := resource.ParseQuantity(component.Volume.Size) diff --git a/pkg/provision/storage/testdata/perWorkspace-storage/uses-calculated-pvc-size-when-greater-than-default.yaml b/pkg/provision/storage/testdata/perWorkspace-storage/uses-calculated-pvc-size-when-greater-than-default.yaml index ca490c0d3..668f18579 100644 --- a/pkg/provision/storage/testdata/perWorkspace-storage/uses-calculated-pvc-size-when-greater-than-default.yaml +++ b/pkg/provision/storage/testdata/perWorkspace-storage/uses-calculated-pvc-size-when-greater-than-default.yaml @@ -1,4 +1,4 @@ -name: "Calculates PVC size when all volumes define their size" +name: "Calculates PVC size when sum of volumes with defined size is greater than default PVC size" input: devworkspaceId: "test-workspaceid" @@ -26,6 +26,8 @@ input: container: image: testing-image-1 sourceMapping: "/plugins-mountpath" + - name: plugins + volume: {} # Size is not defined, but calculated PVC size will be greater than default 5Gi so, calculated size should be used - name: volume-1 volume: size: 1Gi @@ -38,8 +40,6 @@ input: - name: volume-4 volume: size: 248Mi - - name: plugins - volume: {} # Size is not defined, but calculated PVC size will be greater than default 5Gi so, calculated size should be used output: pvcSize: 5880Mi