Skip to content

Commit 2416989

Browse files
committed
fix: Use at least minimum PVC size when mountSources used
Fix #1239 This commit fixes an edge case where a devworkspace that has no volume components, but has a container component with mountSources enabled will request a PVC size of 0 when using the per-workspace storage strategy. When mountSources are used, the devworkspace requires storage to store the project sources. However, it is unknown how much storage is actually required for the project sources. Thus, we treat container components with mountSources enabled as if they were volume components with an unspecified size. Signed-off-by: Andrew Obuchowicz <[email protected]>
1 parent 59e2e0f commit 2416989

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: pkg/provision/storage/perWorkspaceStorage.go

+11
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ func (p *PerWorkspaceStorageProvisioner) rewriteContainerVolumeMounts(workspaceI
174174
//
175175
// 3. If at least one volume in the devworkspace specifies its size, and the computed PVC size is greater
176176
// than the default per-workspace PVC size, the computed PVC size will be used.
177+
//
178+
// 4. Container components with mountSources enabled in the devworkspace are treated as if they were volumes with an unspecified size.
177179
func getPVCSize(workspace *common.DevWorkspaceWithConfig, namespacedConfig *nsconfig.NamespacedConfig) (*resource.Quantity, error) {
178180
defaultPVCSize := *workspace.Config.Workspace.DefaultStorageSize.PerWorkspace
179181

@@ -197,6 +199,15 @@ func getPVCSize(workspace *common.DevWorkspaceWithConfig, namespacedConfig *nsco
197199
}
198200
requiredPVCSize.Add(volumeSize)
199201
}
202+
if component.Container != nil {
203+
if component.Container.MountSources != nil && *component.Container.MountSources {
204+
// Edge case: If the project source code is being mounted to a container component
205+
// then an undefined amount of persistent storage is required.
206+
// We treat this case as if there was a volume component with no size defined.
207+
allVolumeSizesDefined = false
208+
continue
209+
}
210+
}
200211
}
201212

202213
// Use the calculated PVC size if it's greater than default PVC size

0 commit comments

Comments
 (0)