canonical / lxd-ui

Easy and accessible container and virtual machine management. A browser interface for LXD
GNU General Public License v3.0
265 stars 33 forks source link

In 5.21.2-ui-0.8.3 adding a boot.priority via YAML in the UI causes 'json: cannot unmarshal number into Go struct field ProfilePut.devices of type string' #919

Closed stew3254 closed 42 minutes ago

stew3254 commented 21 hours ago

Required information

Issue description

Since there is no option to set the boot priority on different devices in the 5.21 LXD UI, I attempted to add the boot.priority via the YAML configuration section of a profile. When I try to do that, I am given the error 'json: cannot unmarshal number into Go struct field ProfilePut.devices of type string'. If I remove that option from the YAML configuration in the UI, I can save. Doing this in the CLI doesn't raise any issues.

Now that I've added it to the profile via the CLI, if I navigate back to the YAML view I don't see it.

Steps to reproduce

  1. Create a profile with two devices via the CLI. In my case it was a root disk and an ISO. I didn't use the UI way since I don't store my ISOs as a volume because downloading onto the host was faster than uploading my own copy, and that method duplicates disk space unnecessarily when you already have the ISO files.

Example:

name: 22.04.5
description: Jammy Server ISO
config:
  limits.cpu: "2"
  limits.memory: 4GiB
devices:
  iso:
    source: /home/ubuntu/isos/ubuntu-22.04.5-live-server-amd64.iso
    type: disk
  root:
    path: /
    pool: default
    size: 25GiB
    type: disk
used_by: []
  1. Navigate to the profile you created in the UI and go to the YAML configuration
  2. Attempt to add the boot.priority to the two devices. In my case I added a priority of 10 to the root, and 5 to the ISO. This should trigger an error
  3. Remove those fields from the UI and attempt to save. Should work
  4. Via the CLI, edit the profile to add those parameters
  5. Go back to the UI and look at the YAML and they're not there.
edlerd commented 20 hours ago

Hey @stew3254 thank you for reporting the issue.

You can set the boot.priority in the YAML editor of the UI. The value needs to be put into quotes so it is passed as a string and not as a number. I tested this with the UI and it works:

  root:
    path: /
    pool: default
    size: 25GiB
    type: disk
    boot.priority: "10"

Note the quotes around 10, without I am running into the same error that you describe above.

I can confirm there is a bug that the ui will drop the boot.priority on following edits. I will create a PR shortly to fix this issue, so the field gets preserved on edit.

stew3254 commented 20 hours ago

Thanks @edlerd! I didn't consider putting it in quotes. Glad we were able to find something though.