Skip to content

Commit

Permalink
fix: don't abort PVC size calculation early if volume size not defined
Browse files Browse the repository at this point in the history
Fix devfile#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 <aobuchow@redhat.com>
  • Loading branch information
AObuchow committed Aug 10, 2023
1 parent e7da883 commit 39be751
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/provision/storage/perWorkspaceStorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 39be751

Please sign in to comment.