netboxlabs / diode-sdk-python

Diode SDK Python
https://netboxlabs.com
Apache License 2.0
13 stars 0 forks source link

Mandatory tenant for devices #17

Open naciohr opened 3 weeks ago

naciohr commented 3 weeks ago

Dear Netboxlabs team,

I've been doing tests with the diode client and the server. While I found the data ingestion process successful, the reconciler happens to fail to create new devices due to the empty tenant restriction. Actually, I reached to the same if I try to add a device directly in Netbox.

I checked the documentation and there's no option to specify a tenant for a Device object.

The following messages come out the diode-reconciler container:

{
  "time": "2024-09-27T09:28:28.831843289Z",
  "level": "DEBUG",
  "msg": "apply change set",
  "response": "{\"change_set_id\":\"1a058445-ae17-4ce5-aa29-21fbd6ea1a8d\",\"result\":\"failed\",\"errors\":[{\"change_id\":\"0b3936ab-8ffe-4867-ba29-5673928c14f0\",\"__all__\":\"__all__: Custom validation failed for tenant: ['This field must not be empty.']\"}]}"
}

This seems to be in effect by the Validation configuration of Netbox server. imaxe

Although this validation can be disabled in the configuration, I find it necessary for a correct organisational structure.

In addition to this, I tested to edit an existent device and while it's able to spot it correctly, it fails to update the properties (status in this case) even though it's linked to an existent tenant.

{
  "time": "2024-09-27T10:07:49.489919496Z",
  "level": "DEBUG",
  "msg": "ingest entity key",
  "key": "ingest-entity:dcim.device-1727431669480617735-edb1ff87-5ad4-4071-ac2c-ac896cdd4f36"
}
{
  "time": "2024-09-27T10:07:49.894569542Z",
  "level": "DEBUG",
  "msg": "apply change set",
  "payload": "{\"change_set_id\":\"aa8497e6-fb07-4e1e-a2cc-4ddba491b347\",\"change_set\":[{\"change_id\":\"74cfdecb-6ef5-47b5-b4f1-0b6e99309544\",\"change_type\":\"update\",\"object_type\":\"dcim.device\",\"object_id\":15237,\"data\":{\"id\":15237,\"name\":\"A_NAME\",\"site\":{\"id\":107},\"role\":{\"id\":19},\"device_type\":{\"id\":562},\"serial\":\"\",\"description\":\"\",\"status\":\"active\",\"comments\":\"\"}}]}"
}
{
  "time": "2024-09-27T10:07:49.937858088Z",
  "level": "DEBUG",
  "msg": "apply change set",
  "response": "{\"change_set_id\":\"aa8497e6-fb07-4e1e-a2cc-4ddba491b347\",\"result\":\"failed\",\"errors\":[{\"change_id\":\"74cfdecb-6ef5-47b5-b4f1-0b6e99309544\",\"__all__\":\"__all__: Custom validation failed for tenant: ['This field must not be empty.']\"}]}"
}
{
  "time": "2024-09-27T10:07:49.93880686Z",
  "level": "WARN",
  "msg": "failed to handle ingest request",
  "request_id": "5f0c9151-c66f-49b7-b7d4-754feb835f64",
  "errors": [
    "msg: failed to apply change set, code: 400, change set id: aa8497e6-fb07-4e1e-a2cc-4ddba491b347, result: failed, errors: [{\"__all__\":\"__all__: Custom validation failed for tenant: ['This field must not be empty.']\",\"change_id\":\"74cfdecb-6ef5-47b5-b4f1-0b6e99309544\"}]"
  ]
}

Therefore I would like to ask you if there's a way to overcome this constraint or if there's a parameter I'm missing in the documentation.

Thanks and regards,

mfiedorowicz commented 3 weeks ago

Hi @naciohr, thanks for raising the issue. At the moment diode doesn't have support for custom validators. The workaround could be to specify tenant along with device during ingestion, but tenant is not supported object type in diode yet either, so we would have to plan work needed to cover both use cases. We're going to keep you updated over here once we know more.