Skip to content
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

Device: Don't remove an existing target directory when unmounting a disk device if the original dir hasn't been created by LXD #12700

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Commits on May 23, 2024

  1. api: Add disk_state_created API extension

    Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
    gabrielmougard committed May 23, 2024
    Configuration menu
    Copy the full SHA
    0a88c2f View commit details
    Browse the repository at this point in the history
  2. api: Introduce a new AgentDeviceRemove type

    Some devices like disk devices with a target path need to be cleanly unmounted.
    In the case of a VM instance, we prefer to handle the unmount logic within the agent
    and handle the unmounting of the potential overmounts of the guest.
    
    In some cases, we also need to remove a path resource (or not) on the guest side. That is
    why we also pass some extra metadata contained in the `Volatile` field, to handle the resource
    removal process in the agent and not on the LXD side (this would result in spawning aan SFTP client, which is a wasteful approach)
    
    Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
    gabrielmougard committed May 23, 2024
    Configuration menu
    Copy the full SHA
    7f97b2e View commit details
    Browse the repository at this point in the history
  3. instance/instancetype/instance: Add a new volatile key `volatile.<dis…

    …k_dev_name>.last_state.created` for the disk device
    
    Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
    gabrielmougard committed May 23, 2024
    Configuration menu
    Copy the full SHA
    d3ef8d9 View commit details
    Browse the repository at this point in the history
  4. lxd/device/disk: Add the device name to the mount entry when stopping…

    … a device
    
    Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
    gabrielmougard committed May 23, 2024
    Configuration menu
    Copy the full SHA
    145b6fe View commit details
    Browse the repository at this point in the history
  5. lxd/instance/drivers/lxc: detect if we need to remove a target direct…

    …ory when unmounting
    
    When a disk device is removed while relying on a host directory and mapped to a target within a container,
    we detect if the target directory has been created by LXD or not in order to not delete the content of a target
    directory during the unmount.
    
    Example:
    
    - Let say we mounted a custom host empty directory (`test`) on the existing `/opt` directory of the container,
    when unmounted (`lxc device remove ...`), the target `/opt` won't be removed, because we marked it as NOT being created
    by LXD at mount time.
    
    - If, however, we created a custom empty target directory at mount time:
    `lxc config device add u1 test disk source=/home/user/test path=/new_dir`,
    the directory `new_dir` will be created on the target instance and if we decide to unmount `test`,
    the target `/new_dir` will be removed because is has been created by LXD
    
    Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
    gabrielmougard committed May 23, 2024
    Configuration menu
    Copy the full SHA
    77aace6 View commit details
    Browse the repository at this point in the history
  6. lxd/instance/drivers/qemu: fix error formatting

    Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
    gabrielmougard committed May 23, 2024
    Configuration menu
    Copy the full SHA
    0235a7e View commit details
    Browse the repository at this point in the history
  7. lxd-agent: unmount logic inside a VM

    Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
    gabrielmougard committed May 23, 2024
    Configuration menu
    Copy the full SHA
    bbacb20 View commit details
    Browse the repository at this point in the history
  8. lxd-agent: expose the DELETE 1.0/devices VM agent endpoint

    Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
    gabrielmougard committed May 23, 2024
    Configuration menu
    Copy the full SHA
    5f9560c View commit details
    Browse the repository at this point in the history
  9. lxd/instance/drivers/qemu: Add the devlxdDeviceRemove function

    Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
    gabrielmougard committed May 23, 2024
    Configuration menu
    Copy the full SHA
    b6240cb View commit details
    Browse the repository at this point in the history
  10. lxd/instance/driver_qemu: Ensure the underlying VM virtiofs mount has…

    … been unmounted
    
    Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
    gabrielmougard committed May 23, 2024
    Configuration menu
    Copy the full SHA
    8e0a4a5 View commit details
    Browse the repository at this point in the history
  11. test: Check that we can still access the target dir if it hasn''t bee…

    …n created by lxd
    
    Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
    gabrielmougard committed May 23, 2024
    Configuration menu
    Copy the full SHA
    6164750 View commit details
    Browse the repository at this point in the history
  12. lxd/metadata: update metadata configuration

    Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
    gabrielmougard committed May 23, 2024
    Configuration menu
    Copy the full SHA
    a48fd44 View commit details
    Browse the repository at this point in the history
  13. doc: update rest API

    Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
    gabrielmougard committed May 23, 2024
    Configuration menu
    Copy the full SHA
    4139a48 View commit details
    Browse the repository at this point in the history