feat: adding device sync to Nautobot Operator#2098
Conversation
| {name: "vlan", configRefs: nautobotCR.Spec.VlanRef, syncFunc: r.syncVlan}, | ||
| // depends on: namespace, rir, location, vlanGroup, vlan, tenant, tenantGroup, role | ||
| {name: "prefix", configRefs: nautobotCR.Spec.PrefixRef, syncFunc: r.syncPrefix}, | ||
| {name: "device", configRefs: nautobotCR.Spec.DeviceRef, syncFunc: r.syncDevice}, |
There was a problem hiding this comment.
device sync is currently at the end of the sync order but cluster sync runs earlier on line 99 and tries to assign devices during cluster sync. Since clusters depend on devices already existing, should device sync run before cluster sync? Otherwise new devices may not exist yet when cluster assignment happens.
There was a problem hiding this comment.
I think this might be a problem later on. the current order relies on programmers to manually remember the order of dependency when adding new resources. I don't think that should be the case. We should use a DAG(Directed Acyclic Graphs) here and do a topological sort instead. This would guarantee correct processing order instead of relying on the order in the list. For example, if devices need to be processed before cluster sync, the DAG would enforce that automatically — rather than depending on someone remembering to place device above cluster.
| type: array | ||
| deviceRef: | ||
| items: | ||
| description: ConfigMapRef defines a reference to a specific ConfigMap |
There was a problem hiding this comment.
Nit: can we improve the description here? It sounds slightly unintuitive. I can't make sens eof this sentence, 'ie' reference to a specific ConfigMap' of what?
| description: ConfigMapRef defines a reference to a specific ConfigMap | ||
| properties: | ||
| configMapSelector: | ||
| description: The name of the ConfigMap resource being referred |
There was a problem hiding this comment.
The description says this selector "is" a name, but then on line 132 we have a separate key field — so it's unclear what the outer description is even referring to. This still looks confusing to me.
| description: ConfigMapRef defines a reference to a specific ConfigMap | ||
| properties: | ||
| configMapSelector: | ||
| description: The name of the ConfigMap resource being referred |
There was a problem hiding this comment.
Same confusion as I described in /config/crd/bases/sync.rax.io_nautobots.yaml
| {name: "vlan", configRefs: nautobotCR.Spec.VlanRef, syncFunc: r.syncVlan}, | ||
| // depends on: namespace, rir, location, vlanGroup, vlan, tenant, tenantGroup, role | ||
| {name: "prefix", configRefs: nautobotCR.Spec.PrefixRef, syncFunc: r.syncPrefix}, | ||
| {name: "device", configRefs: nautobotCR.Spec.DeviceRef, syncFunc: r.syncDevice}, |
There was a problem hiding this comment.
I think this might be a problem later on. the current order relies on programmers to manually remember the order of dependency when adding new resources. I don't think that should be the case. We should use a DAG(Directed Acyclic Graphs) here and do a topological sort instead. This would guarantee correct processing order instead of relying on the order in the list. For example, if devices need to be processed before cluster sync, the DAG would enforce that automatically — rather than depending on someone remembering to place device above cluster.
Add device sync support to the Nautobot operator with full CRUD lifecycle (create/update/delete) following the same patterns as device types.
Sample ConfigMap/YAML files.
Sample Config Map