devfile / devworkspace-operator

Apache License 2.0
61 stars 55 forks source link

per-workspace storage PVC size calculation is incorrect when no volumes defined & mountSources used #1239

Open AObuchow opened 6 months ago

AObuchow commented 6 months ago

Description

If a devworkspace uses per-workspace storage, has mountSources: true but has no volumes defined, the calculated PVC size will erroneously be 0.

How To Reproduce

  1. Apply the following devworkspace that has no volumes & uses per-workspace storage:
kind: DevWorkspace
apiVersion: workspace.devfile.io/v1alpha2
metadata:
  name: plain-per-workspace
spec:
  started: true
  routingClass: 'basic'
  template:
    attributes:
        controller.devfile.io/storage-type: per-workspace
    components:
      - name: web-terminal
        container:
          image: quay.io/wto/web-terminal-tooling:next
          memoryRequest: 256Mi
          memoryLimit: 512Mi
          mountSources: true
          command:
           - "tail"
           - "-f"
           - "/dev/null"
  1. The DevWorkspace will fail with the following error:
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

Expected behavior

If a devworkspace which does not define any volumes but has mountSources enabled, then the default PVC size should be used when using the per-workspace storage strategy.