project-akri / akri

A Kubernetes Resource Interface for the Edge
https://docs.akri.sh/
Apache License 2.0
1.11k stars 144 forks source link

Enable Instance.shared to be determined by Configuration #5

Closed bfjelds closed 3 years ago

bfjelds commented 4 years ago

Every Instance CRD has a shared property, which determines whether the device/capability can be shared by multiple nodes. If an instance is not shared, every node that discovers it will create a new Instance CRD, while if it is shared, that Instance CRD will be shared by all nodes that can discover the instance/capability.

Currently the sharability of an instance is defined by the protocol that was used to discover it. For example, currently, all instances (more specifically ip cameras in this protocol) discovered by the ONVIF protocol are marked as shared, as can be seen in the ONVIF DiscoveryHandler's implementation of are_shared(). Similarly, all instances discovered with udev are marked as unshared, since the udev protocol only discovers devices on a specific node.

Should the "is this shared?" decision be made elsewhere, such as in the Configuration, allowing an operator to specify sharability? Should the "is this shared?" decision be made on a device by device case?

One thing to note about the validity of the current solution of defining sharability by protocol: Right now, if ONVIF cameras were allowed to be unshared, it could result in multiple instances for a single camera, making it hard to regulate capacity and possibly leading to an overloaded device. Also, having two Instance CRDs for a single device seems counter-intuitive.

kate-goldenring commented 3 years ago

The new Discovery Handler interface puts the decision on the Discovery Handler as to whether a device is shared or not. When a Discovery Handler registers with the Agent, it specifies whether it is discovering shared or unshared devices. This may need to change if there was some reason a Discovery Handler could discover both shared and unshared devices.