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

Netbox plugin: Sync disk size error #7643

Open
ecoutinho opened this issue May 7, 2024 · 4 comments
Open

Netbox plugin: Sync disk size error #7643

ecoutinho opened this issue May 7, 2024 · 4 comments

Comments

@ecoutinho
Copy link

Are you using XOA or XO from the sources?

XO from the sources

Which release channel?

stable

Provide your commit number

771b0

Describe the bug

When I try to synchronize with Netbox v3.7.8, it aborts with the error: "The specified disk size (130) must match the aggregate size of assigned virtual disks (100).". On this Netbox version, it is not necessary to set Resources > Disk size on the VM properties. Disk size is managed via the attachment of virtual disks.

From XO logs:
xo:netbox DEBUG PATCH /virtualization/virtual-machines/ [ { disk: 130, id: 181 } ]

The VM (181) where the error occurs, has two disks in XO (100GB + 30GB), while it has only one disk (100GB) setup in Netbox. So, when the Sync plugin tries to set Total disk size to 130GB, Netbox checks the sum of the virtual disks and as they don't match, it throws an error.

Error message

netbox.synchronize
{
  "pools": [
    "ee8b0aa4-a0af-8720-4fc7-4d7950e90b85"
  ]
}
{
  "originalUrl": "https://netbox/api/virtualization/virtual-machines/",
  "url": "https://netbox/api/virtualization/virtual-machines/",
  "method": "PATCH",
  "requestBody": [
    {
      "platform": 26,
      "tags": [
        {
          "id": 17
        },
        {
          "id": 18
        }
      ],
      "id": 199
    },
    {
      "platform": 10,
      "id": 141
    },
    "and 56 others"
  ],
  "netboxError": {
    "disk": [
      "The specified disk size (130) must match the aggregate size of assigned virtual disks (100)."
    ]
  },
  "message": "400 Bad Request",
  "name": "Error",
  "stack": "Error: 400 Bad Request
    at Object.assertSuccess (/opt/xen-orchestra/node_modules/http-request-plus/index.js:162:19)
    at httpRequestPlus (/opt/xen-orchestra/node_modules/http-request-plus/index.js:217:22)
    at httpRequest (/opt/xen-orchestra/packages/xo-server-netbox/src/index.js:149:26)
    at Netbox.#request (/opt/xen-orchestra/packages/xo-server-netbox/src/index.js:178:30)
    at Netbox.#synchronize (/opt/xen-orchestra/packages/xo-server-netbox/src/index.js:643:21)
    at Api.#callApiMethod (file:///opt/xen-orchestra/packages/xo-server/src/xo-mixins/api.mjs:366:20)"
}

To reproduce

  1. Go to 'Pools > Advanced'
  2. Click on 'Synchronize with Netbox'
  3. See error

Expected behavior

Not setting the total disk size in VM properties, would allow the sync.

For now, I've commented that check on Netbox code (netbox/virtualization/models/virtualmachines.py) which also allows the sync to complete.

Screenshots

No response

Node

18.20.2

Hypervisor

XCP-ng 8.2.0

Additional context

Netbox v3.7.8

@pdonias
Copy link
Member

pdonias commented May 7, 2024

Hi! Did you create the virtual disk manually in Netbox? XO doesn't synchronize disks (yet).

@ecoutinho
Copy link
Author

Hi, Yes, a colleague had created the VM and just one disk in Netbox. When I added a second disk in XO and tried to sync, the error occurred.

@pdonias
Copy link
Member

pdonias commented May 14, 2024

Ok, that makes sense then. From Netbox's point of view, either you set a disk size on the VM or you attach disks to the VM and the total size is computed automatically. But both can't work together if the sizes don't match. We might synchronize disks in the future but for now, you either need to let the plugin synchronize the size without adding disks, or you need to make sure you add the disks manually in Netbox when you create one in XO.

@ecoutinho
Copy link
Author

OK, I see what you mean, it makes sense. I don't know if it's possible, but it would be great to have information on which VM the synchronization was aborted. I had to enable XO debug to figure out the VM id and then figure out what was failing. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants