A volume can’t be attached to another VM (Yaml)

  • Related issues: #5383 [ENHANCEMENT] Refactor harvesterhci.io/owned-by annotation on PVC

Category

  • Volume

Verification Steps

  1. Create two VMs (vm1 and vm2)

  2. Create a data volume vol-001

  3. Click the add volume menu option for vm1 to attach vol-001 to vm1

  4. Ensure vol-001 can correctly been attached to vm1

  5. Click the add volume menu option for vm2 and find available volume

  6. Edit the yaml of vm2

  7. Try to attach the data volume yaml content from vm1 to vm2 spec.volume

        - name: data-vol
          persistentVolumeClaim:
            claimName: vol-001
            hotpluggable: true
  1. Click Save
  2. Check the failure message prompt

Expected Results

  1. No volume can’t be found in the list when click the add volume menu option for vm2
  2. Should prompt the error message to prevent
    admission webhook "validator.harvesterhci.io" denied the request: the volume vol-001 is already used by VM default/vm1
    
    images/volumes/5383-image-01.png