devfile / devworkspace-operator

Apache License 2.0
59 stars 49 forks source link

fix: account for mountSources when calculating per-workspace PVC size #1253

Open AObuchow opened 2 months ago

AObuchow commented 2 months ago

What does this PR do?

When calculating the per-workspace PVC size, container components in a devworkspace are now treated as if they were volume components with no size specified.

This change was made to address an edge case in the per-workspace PVC size calculation where a devworkspace that has no volume components, but has a container component with mountSources enabled will request a PVC size of 0.

When mountSources is used, the devworkspace requires storage to store the project sources. However, it's ambiguous as to how much storage is required for the project sources. Thus, the best we can do is to treat container components with mountSources enabled as if they were volume components with an unspecified size.

I also documented the original 3 rules that were followed when calculating the per-workspace PVC size (mentioned in this PR) and added a 4th rule regarding the mountSources edge case.

What issues does this PR fix or reference?

Fix https://github.com/devfile/devworkspace-operator/issues/1239

Is it tested? How?

  1. Install DWO built from this PR
  2. Apply the following DevWorkspace, which used to fail in the original issue:
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. Ensure the devworkspace starts up successfully.
  2. Ensure the devworkspace's PVC size is the default 5Gi

PR Checklist

openshift-ci[bot] commented 2 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AObuchow

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/devfile/devworkspace-operator/blob/main/OWNERS)~~ [AObuchow] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment