fledge-iot / fledge

An open source platform for the Industrial Internet of Things, it acts as an edge gateway between sensor devices and cloud storage systems.
https://www.lfedge.org/projects/fledge/
Apache License 2.0
117 stars 43 forks source link

plugin_init is called when creating a disabled north/south service #1407

Open FlorentP42 opened 2 weeks ago

FlorentP42 commented 2 weeks ago

Describe the bug When creating a north/south service, you can select if the plugin behind that service will be enabled by default or not from the GUI (or from the API). If you create a service disabled at creation, then plugin_init is called for that plugin. And even more strange the plugin initialized this way then seems to "disappear" without even a call to plugin_shutdown, which may result in memory leaks.

To Reproduce Steps to reproduce the behavior:

  1. Create a new fledge-south-hnz service from Fledge GUI with log level set to "debug" at startup (through START_LOG_LEVEL).
  2. Uncheck the "Enable" box in the last menu of service creation.
  3. Notice in the logs that plugin_init is called (that should not happen).
  4. Enable the plugin in the options.
  5. Notice in the logs that plugin_init is called again (as expected).
  6. Notice in the logs that but plugin_shutdown was not called on that plugin between the two plugin_init (does not feel like the intended behavior).

Expected behavior If we make the service disabled at creation, we expect the service configuration to be saved for when it will be enabled later, but no plugin to be initialized at all.

Additional context