devfile / devworkspace-operator

Apache License 2.0
61 stars 55 forks source link

Fix: disable persistent home when ephemeral storage used; persistent home volume shouldn't use capital letters #1210

Closed AObuchow closed 10 months ago

AObuchow commented 10 months ago

What does this PR do?

This PR makes 2 fixes to the $HOME persistence feature in DWO:

(Sorry for putting 2 bug fixes in a single PR - it seemed to make sense since they're both related)

What issues does this PR fix or reference?

1200 & #1203

Is it tested? How?

Initial setup

  1. Set the $DWO_IMG environment variable to point to your quay repository for DWO, e.g: export DWO_IMG=quay.io/<your-username>/devworkspace-controller:next
  2. Run make install_cert_manager docker install if testing on Minikube. For openshift, run make docker install
  3. Enable persistUserHome in the DWOC: kubectl edit dwoc -n $NAMESPACE
apiVersion: controller.devfile.io/v1alpha1                                                                                                                                 
config:                                                                                                                                                                    
  routing:                                                                                                                                                                 
    clusterHostSuffix: 192.168.49.2.nip.io                                                                                                                                 
    defaultRoutingClass: basic                                                                                                                                             
  workspace:                                                                                                                                                               
    imagePullPolicy: Always                                                                                                                                                
+    persistUserHome:                                                                                                                                                       
+      enabled: true                                                                                                                                                        
kind: DevWorkspaceOperatorConfig

Testing fix for #1200

  1. Create a devworkspace that uses persistent storage. The plain-devworkspace sample will suffice: kubectl apply -f ./samples/plain.yaml
  2. Ensure the workspace starts up successfully with kubectl get dw -n $NAMESPACE -w
  3. Check the workspace pod's spec, and verify it has a volumeMount with a subPath set to /persistent-home. For example:
(...)
        volumeMounts:                                                                                                                                                                                                                                                                            
        - mountPath: /home/user/                                                                                                                                           
          name: claim-devworkspace                                                                                                                                         
          subPath: workspace1835a0b4d9f04fd2/persistent-home   
(...)

Testing fix for #1203

  1. Create a devworkspace that uses ephemeral storage. The following devworkspace can be used:
kind: DevWorkspace
apiVersion: workspace.devfile.io/v1alpha2
metadata:
  name: plain-devworkspace-ephemeral
spec:
  started: true
  routingClass: 'basic'
  template:
    attributes:
        controller.devfile.io/storage-type: ephemeral
    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 workspace starts up successfully with kubectl get dw -n $NAMESPACE -w
$ kubectl get dw -n $NAMESPACE -w
NAME                           DEVWORKSPACE ID             PHASE     INFO
plain-devworkspace-ephemeral   workspace03197f210f9247e4   Running   Workspace is running

PR Checklist

codecov[bot] commented 10 months ago

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (093bb40) 52.82% compared to head (4d83873) 52.84%.

Files Patch % Lines
controllers/workspace/devworkspace_controller.go 0.00% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1210 +/- ## ========================================== + Coverage 52.82% 52.84% +0.01% ========================================== Files 84 84 Lines 7604 7604 ========================================== + Hits 4017 4018 +1 + Misses 3300 3299 -1 Partials 287 287 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

openshift-ci[bot] commented 10 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: amisevsk, 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)~~ [amisevsk] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment