-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: account for mountSources when calculating per-workspace PVC size #1253
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -166,6 +166,16 @@ func (p *PerWorkspaceStorageProvisioner) rewriteContainerVolumeMounts(workspaceI | |||
return nil | ||||
} | ||||
|
||||
// Calculates the per-workspace PVC size required for the given devworkspace based on the following rules: | ||||
// | ||||
// 1. If all volumes in the devworkspace specify their size, the computed PVC size will be used. | ||||
// | ||||
// 2. If all volumes in the devworkspace either specify their size or are ephemeral, the computed PVC size will be used. | ||||
// | ||||
// 3. If at least one volume in the devworkspace specifies its size, and the computed PVC size is greater | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Little formatting mistake here (extra space should be removed) |
||||
// 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 | ||||
|
||||
|
@@ -189,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 { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we use
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch ! Yes we should. |
||||
// 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 | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: "Uses default PVC size when no volumes define their size but mountSources used" | ||
|
||
input: | ||
devworkspaceId: "test-workspaceid" | ||
podAdditions: | ||
containers: | ||
- name: testing-container-1 | ||
image: testing-image | ||
volumeMounts: | ||
- name: "projects" | ||
mountPath: "/projects-mountpath" | ||
initContainers: | ||
- name: testing-initContainer-1 | ||
image: testing-image | ||
|
||
workspace: | ||
components: | ||
- name: testing-container-1 | ||
container: | ||
image: testing-image-1 | ||
mountSources: true | ||
|
||
output: | ||
podAdditions: | ||
containers: | ||
- name: testing-container-1 | ||
image: testing-image | ||
volumeMounts: | ||
- name: storage-test-workspaceid | ||
subPath: "projects" | ||
mountPath: "/projects-mountpath" | ||
initContainers: | ||
- name: testing-initContainer-1 | ||
image: testing-image | ||
|
||
volumes: | ||
- name: storage-test-workspaceid | ||
persistentVolumeClaim: | ||
claimName: storage-test-workspaceid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkwon17 I made a mistake here (and repeated this mistake while on our call):
If all volumes in the devworkspace specify their size, the computed PVC size will used if it is greater than the default PVC size (see this line and this test case).
Will modify this function's documentation accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My above statement was wrong... my mistake.
If all volume sizes are defined, and the computed PVC size is smaller than the default PVC size, the computed PVC size will be used.
This creates a conflict with my work-around for mountSources from this PR: the only way you could get a PVC that is smaller than the default PVC size is to define all volumes and disable mountSources. IMO, this is not acceptable.
I don't know yet if there's an elegant solution to the conflict between using mountSources and wanting a PVC that is smaller than the default. My current ideas are to:
Error provisioning storage: Failed to sync storage-workspace8723f4cb2dfa4922 PVC to cluster: PersistentVolumeClaim "storage-workspace8723f4cb2dfa4922" is invalid: spec.resources[storage]: Invalid value: "0": must be greater than zero
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkwon17 I'm gonna make an update to this PR, most likely based on my last suggested approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is the proper solution for this issue.