Plugin is created and persisted in the database even if the creation of a network element failed
Even though the creation of a network element fails, a plugin is pulled from the registry and persisted within the storage.
Description
If a new network element is created there are multiple occasions were the creation could fail (e.g., a false address is provided). In this case the controller aborts the network element creation and throws an error message. But internal the controller already requests a plugin for that device from the plugin registry and even persists it within the storage, even though there is no use for it later on.
Expected Behavior
If an error is thrown while adding a new network element, there should be no left overs and especially those left overs should not be persisted.
Actual Behavior
If an error is thrown while adding a network element, the network element itself is not persisted but the associated plugin.
Possible Fix
Persist the plugin later in the process / add a clean up method if the network element creation failed.
Steps to Reproduce
- Create a new network element through the CLI with a non valid address.
- Check the pluginStorage (a new plugin is created, but no device)
Context
Your Environment
- Version used:
- Environment name and version (e.g. go v1.16.3 on FreeBSD 13.0-current):
- Server type and version:
- Operating System and version: