devfile / devworkspace-operator

Apache License 2.0
61 stars 55 forks source link

Mounting files that conflict with stow directory files causes persistent home to not work #1257

Closed dkwon17 closed 3 months ago

dkwon17 commented 5 months ago

Description

Mounting files via configmap, secret or PVC that conflict with stow directory files, this causes the stow command to fail when running persistentUserHome in the DWOC is enabled.

How To Reproduce

  1. Create a configmap that creates a file that conflicts with a file in the /home/tooling directory of the UDI image, such as /home/user/.config/containers/storage.conf:

    kind: ConfigMap
    apiVersion: v1
    metadata:
    name: fuse-overlay
    labels:
    controller.devfile.io/mount-to-devworkspace: 'true'
    controller.devfile.io/watch-configmap: 'true'
    annotations:
    controller.devfile.io/mount-as: file
    controller.devfile.io/mount-path: /home/user/.config/containers
    data:
    storage.conf: |
    [storage]
    driver = "overlay"
    
    [storage.options.overlay]
    mount_program="/usr/bin/fuse-overlayfs"
  2. Enable persistUserHome in the DWOC:

    apiVersion: controller.devfile.io/v1alpha1
    config:
    workspace:
    persistUserHome:
      enabled: true
  3. Create this DevWorkspace:

    kind: DevWorkspace
    apiVersion: workspace.devfile.io/v1alpha2
    metadata:
    name: plain-devworkspace
    spec:
    started: true
    routingClass: 'basic'
    template:
    attributes:
      controller.devfile.io/storage-type: per-workspace
    components:
      - name: udi
        container:
          image: quay.io/devfile/universal-developer-image:ubi8-latest
  4. When the workspace is running, run the following command in the udi container to verify that the stow command in the UDI's entrypoint did not succeed:

    $ cat /tmp/stow.log | tail -n 10
    LINK: .sdkman/var/delay_upgrade => ../../../tooling/.sdkman/var/delay_upgrade
    MKDIR: .sdkman/var/metadata
    LINK: .sdkman/var/platform => ../../../tooling/.sdkman/var/platform
    LINK: .sdkman/var/version => ../../../tooling/.sdkman/var/version
    LINK: .sdkman/var/version_native => ../../../tooling/.sdkman/var/version_native
    LINK: .gitconfig => ../tooling/.gitconfig
    Planning stow of package .... done
    WARNING! stowing . would cause conflicts:
    * existing target is not owned by stow: .config/containers/storage.conf
    All operations aborted.

Expected behavior

It would be great if the stow command should succeed

Additional context