Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework the plugin loading logic #1703

Merged
merged 6 commits into from Jun 8, 2021

Conversation

dominiklohmann
Copy link
Member

@dominiklohmann dominiklohmann commented Jun 1, 2021

馃摂 Description

This PR contains a set of changes related to how we load plugins.

  1. --plugins and --plugin-dirs options may now be specified on the command line as well as the configuration under vast.plugins and vast.plugin-dirs respectively.
  2. We no longer load static plugins by default.
  3. The CMake build option VAST_ENABLE_PLUGIN_AUTOLOADING no longer exists.
  4. Adding bundled to vast.plugins causes all bundled plugins, i.e., static or dynamic plugins built alongside VAST, to be loaded.
  5. Adding all to vast.plugins causes all bundled and external plugins to be loaded.

馃摑 Checklist

  • All user-facing changes have changelog entries.
  • The changes are reflected on docs.tenzir.com/vast, if necessary.
  • The PR description contains instructions for the reviewer, if necessary.

馃幆 Review Instructions

Review code file-by-file.

Regarding the design: I went over this with @mavam and we agreed this was a good UX improvement. I will wait until after the initial review with writing the documentation for this, though.

To test this change I recommend the following steps:

  1. Test various combinations of the new plugin option with a bundled plugin in a standard location.
    cmake -B build.vast -D "VAST_PLUGINS=${PWD}/plugins/pcap"
    cmake --build build.vast
    cmake --install build.vast --prefix "${PWD}/install.vast"
    vast -v --plugins=... version
  2. Test various combinations of the new plugin option with an external plugin in a non-standard location and a bundled plugin in a standard location.
    VAST_DIR="${PWD}/install.vast" -S example/plugins/analyzer -B build.analyzer
    cmake --build build.analyzer
    vast -v --plugins=... --plugin-dirs="${PWD}/build.analyzer/lib/vast/plugins" version
  3. Test various combinations of the new plugin option with an external plugin in a non-standard location and a bundled plugin in a standard location.
    cmake --install build.analyzer --prefix "${PWD}/install.vast"
    vast -v --plugins=... version

@dominiklohmann dominiklohmann added the feature New functionality label Jun 1, 2021
@dominiklohmann dominiklohmann requested a review from a team June 1, 2021 14:41
@dominiklohmann dominiklohmann force-pushed the story/ch25588/flexible-plugin-loading branch from 7a00a9c to d974a91 Compare June 1, 2021 14:57
Copy link
Member

@lava lava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a quick first look.

Maybe you can expand the description a bit to include what the specific issues were that you and @mavam were trying to solve with this redesign, otherwise its hard to tell if it succeeds at that or not.

As a general feeling, it seems like expanding the bundled and all keywords into a list of plugins could be done outside the routines that handle the actual loading of plugins, to disentangle the code.

vast/vast.cpp Outdated Show resolved Hide resolved
vast/vast.cpp Outdated Show resolved Hide resolved
vast/vast.cpp Outdated Show resolved Hide resolved
vast/vast.cpp Outdated Show resolved Hide resolved
libvast/src/system/configuration.cpp Show resolved Hide resolved
vast/vast.cpp Outdated Show resolved Hide resolved
libvast/src/detail/load_plugin.cpp Outdated Show resolved Hide resolved
@dominiklohmann dominiklohmann force-pushed the story/ch25588/flexible-plugin-loading branch from d974a91 to d382eb3 Compare June 1, 2021 16:11
@dominiklohmann
Copy link
Member Author

Maybe you can expand the description a bit to include what the specific issues were that you and @mavam were trying to solve with this redesign, otherwise its hard to tell if it succeeds at that or not.

A few things that were all interrelated:

  • Do no longer enable static plugins by default to treat both types of bundled plugins equally.
  • Make it possible to use --plugins= and --plugin-dirs= on the command line.
  • Add an option to load all bundled plugins
  • Add an option to load all installed plugins including external plugins

As a general feeling, it seems like expanding the bundled and all keywords into a list of plugins could be done outside the routines that handle the actual loading of plugins, to disentangle the code.

It cannot with the current behavior, unless all should also hard fail for libraries that cannot be loaded.

@mavam
Copy link
Member

mavam commented Jun 2, 2021

As a general feeling, it seems like expanding the bundled and all keywords into a list of plugins could be done outside the routines that handle the actual loading of plugins, to disentangle the code.

Mixing --plugins=all with --plugins=foo,bar,baz may confuse different things. Putting into separate options could be alternative, e.g.,

  • Explicit plugins: --plugins=foo,bar,baz
  • Plugin groups: --load-bundled-plugins or --load-all-plugins (modulo option naming)

@dominiklohmann
Copy link
Member Author

  • Explicit plugins: --plugins=foo,bar,baz
  • Plugin groups: --load-bundled-plugins or --load-all-plugins (modulo option naming)

I'd like to avoid doing that, as adding more options that need special-case handling in the CAF configuration is a pain to maintain. I also think @lava was talking about the code itself more, where we can expand the all and bundled keywords into a list of plugin file in-place. I actually thought about this some last evening and came up with an idea of how to further refactor this with that in mind.

@dominiklohmann dominiklohmann force-pushed the story/ch25588/flexible-plugin-loading branch from b244b5c to 11a4194 Compare June 2, 2021 15:37
@dominiklohmann dominiklohmann requested a review from lava June 2, 2021 15:55
@dominiklohmann dominiklohmann force-pushed the story/ch25588/flexible-plugin-loading branch 2 times, most recently from d0ec5d6 to fdbb044 Compare June 3, 2021 09:18
Copy link
Member

@lava lava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks generally good to me; just a few stylistic comments below.

Also, I think it would be good to capture the motivation for this PR that you explained in a video call somewhere (maybe a new "feature" changelog entry?), since your previous answer just gave a summary of the PR contents.

libvast/src/plugin.cpp Show resolved Hide resolved
vast.yaml.example Show resolved Hide resolved
This commit contains a set of changes related to how we load plugins.
1. `--plugins` and `--plugin-dirs` options may now be specified on the
   command line as well as the configuration under `vast.plugins` and
   `vast.plugin-dirs` respectively.
2. We no longer load static plugins by default.
3. The CMake build option `VAST_ENABLE_PLUGIN_AUTOLOADING` no longer
   exists.
4. Adding `bundled` to `vast.plugins` causes all bundled plugins, i.e.,
   static or dynamic plugins built alongside VAST to be loaded.
5. Adding `all` to `vast.plugins` causes all bundled *and* external
   plugins to be loaded.

To test this change I recommend the following steps:

1. Test various combinations of the new plugin option with a bundled plugin in
   a standard location.
   ```bash
   cmake -B build.vast -D "VAST_PLUGINS=${PWD}/plugins/pcap"
   cmake --build build.vast
   cmake --install build.vast --prefix "${PWD}/install.vast"
   vast -v --plugins=... version
   ```
2. Test various combinations of the new plugin option with an external plugin in
   a non-standard location and a bundled plugin in a standard location.
   ```bash
   VAST_DIR="${PWD}/install.vast" -S example/plugins/analyzer -B build.analyzer
   cmake --build build.analyzer
   vast -v --plugins=... --plugin-dirs="${PWD}/build.analyzer/lib/vast/plugins" version
   ```
3. Test various combinations of the new plugin option with an external plugin in
   a non-standard location and a bundled plugin in a standard location.
   ```bash
   cmake --install build.analyzer --prefix "${PWD}/install.vast"
   vast -v --plugins=... version
   ```
This implicitly enables all plugins in the Docker image.
This came up in a review, but was considered too complex of a change to
fit in the scope of the existing set of changes. This ensures we don't
forget about it.
@dominiklohmann dominiklohmann force-pushed the story/ch25588/flexible-plugin-loading branch from 93e6076 to 7e7b10f Compare June 8, 2021 08:16
@dominiklohmann dominiklohmann merged commit 1c0c72b into master Jun 8, 2021
@dominiklohmann dominiklohmann deleted the story/ch25588/flexible-plugin-loading branch June 8, 2021 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality
Projects
None yet
3 participants