Skip to content

Commit

Permalink
fix: Use at least minimum PVC size when mountSources used
Browse files Browse the repository at this point in the history
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 <aobuchow@redhat.com>
  • Loading branch information
AObuchow committed Apr 17, 2024
1 parent 59e2e0f commit 2416989
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/provision/storage/perWorkspaceStorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ func (p *PerWorkspaceStorageProvisioner) rewriteContainerVolumeMounts(workspaceI
//
// 3. If at least one volume in the 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.
//
// 4. Container components with mountSources enabled in the devworkspace are treated as if they were volumes with an unspecified size.
func getPVCSize(workspace *common.DevWorkspaceWithConfig, namespacedConfig *nsconfig.NamespacedConfig) (*resource.Quantity, error) {
defaultPVCSize := *workspace.Config.Workspace.DefaultStorageSize.PerWorkspace

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

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

0 comments on commit 2416989

Please sign in to comment.