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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prototype plugin architecture #1208

Merged
merged 20 commits into from Jan 6, 2021

Conversation

dominiklohmann
Copy link
Member

@dominiklohmann dominiklohmann commented Dec 3, 2020

📔 Description

A working prototype to load plugins as shared objects with hooks in vast.yaml to pass configuration options to plugins. Provides an example plugin that hooks into the table slice stream of the importer.

📝 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

File-by-file feels best.

@dominiklohmann dominiklohmann added the feature New functionality label Dec 3, 2020
@dominiklohmann dominiklohmann requested a review from a team December 3, 2020 14:54
@mavam
Copy link
Member

mavam commented Dec 3, 2020

Easy to fix CI issue, @dominiklohmann:

FAILED: plugins/example/CMakeFiles/example.dir/example.cpp.o 
ccache /usr/bin/g++-8  -Dexample_EXPORTS -Ilibvast -I../libvast -I../aux/robin-map/include -Iaux/caf/libcaf_core -I../aux/caf/libcaf_core -I../aux/caf/libcaf_io -I../aux/caf/libcaf_openssl -Wall -Wextra -pedantic -ftemplate-backtrace-limit=0 -fdebug-prefix-map=/home/runner/work/vast/vast=. -Wno-redundant-move -fsanitize=address -fno-omit-frame-pointer   -O2 -g1 -Werror -Wno-error=deprecated -Wno-error=deprecated-declarations -fPIC   -fdiagnostics-color=always -std=gnu++17 -MD -MT plugins/example/CMakeFiles/example.dir/example.cpp.o -MF plugins/example/CMakeFiles/example.dir/example.cpp.o.d -o plugins/example/CMakeFiles/example.dir/example.cpp.o -c ../plugins/example/example.cpp
../plugins/example/example.cpp:132:42: error: extra ‘;’ [-Werror=pedantic]
 VAST_REGISTER_PLUGIN(example, 0, 1, 0, 0);
                                          ^

@dominiklohmann dominiklohmann force-pushed the story/ch21022/prototype-plugin-architecture branch from 19bdd66 to e3b39d8 Compare January 4, 2021 18:52
@dominiklohmann dominiklohmann force-pushed the story/ch21022/prototype-plugin-architecture branch from e3b39d8 to c5ac0bf Compare January 4, 2021 19:05
@mavam
Copy link
Member

mavam commented Jan 5, 2021

@dominiklohmann I'm a bit clueless why CI started failing. Do you have an idea?

@dominiklohmann
Copy link
Member Author

@mavam
@dominiklohmann I'm a bit clueless why CI started failing. Do you have an idea?

Looks unrelated to me. Does it reproduce after you re-run the CI?

@mavam
Copy link
Member

mavam commented Jan 5, 2021

Seems like the GCC check now passes. But the Docker issue still persists. Unfortunately I'm a bit clueless how to go after this one. My hunch was that the schema definitions are not available with the example configuration, but they are copied as well. 🤷‍♂️

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.

From the user API this looks pretty good to me, so the comments all concern the implemtation side.

There also seem to be two empty README.md files left over that I can't comment on directly, these should probably be removed of filled with example documentation.

configure Show resolved Hide resolved
// Load plugins.
auto& plugins = plugins::get();
auto plugin_dirs = detail::get_plugin_dirs(cfg);
for (const auto& dir : plugin_dirs) {
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be good to require a more explicit opt-in for plugin loading, this is executing arbitrary code after all and everyone with access to the current users home directory can inject it.

Not completely sure what the best solution would be, but some ideas:

  • a build-time switch to turn off plugin support completely
  • a run-time --enable-plugins switch
  • a list of specific dynamic plugins to load, intead of directories, like --enable-plugin=/usr/lib/vast/plugins/matcher.so

Copy link
Member Author

Choose a reason for hiding this comment

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

We'll postpone this to a separate story so we can discuss this prperly.

Copy link
Member

@lava lava Jan 6, 2021

Choose a reason for hiding this comment

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

Can we at least turn it off by default then until it is discussed? It may be an experimental feature, but it will also be present on production systems.


/// Checks if a version meets the plugin version requirements.
/// @param version The version to compare against the requirements.
bool has_required_version(const plugin_version& version) noexcept;
Copy link
Member

Choose a reason for hiding this comment

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

Although in the medium- to long-term we certainly need a separate plugin versioning scheme (as soon as we have binary third-party plugins), for now we could probably save ourselves a lot of headaches and lingering compatibility bugs by requiring that all plugins must be built from the same commit as vast itself.

Copy link
Member Author

Choose a reason for hiding this comment

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

We're keeping this as is, doesn't hurt to have this now already. We can always make a breaking change while it's labeled experimental.

Copy link
Member

Choose a reason for hiding this comment

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

I was more thinking about the scenario where we unintentionally break ABI but forget to bump the major version of the plugin API, leading to strange memory corruption.

Actually, while writing this I noticed that the implementation of this function also seems off, at the least the major version should match exactly as opposed to being <=.

libvast/vast/plugin.hpp Outdated Show resolved Hide resolved
vast/vast.cpp Show resolved Hide resolved
libvast/vast/config.hpp.in Outdated Show resolved Hide resolved
This came up in a review: While I prefer to generally always use
`auto&&` or `const auto&`, and never `auto&`, because the former always
work, we already use the latter for other calls to the same function and
we should do so consistently.
Copy link
Member

@mavam mavam left a comment

Choose a reason for hiding this comment

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

Curious if the path changes fix the Docker CI build.

vast/vast.cpp Outdated Show resolved Hide resolved
@dominiklohmann dominiklohmann mentioned this pull request Jan 6, 2021
3 tasks
Co-authored-by: Matthias Vallentin <matthias@tenzir.com>
@dominiklohmann
Copy link
Member Author

#1261 confirmed that the Docker workflow failure is unrelated. Let's merge regardless of it and fix that separately.

@mavam mavam merged commit cdf3188 into master Jan 6, 2021
@mavam mavam deleted the story/ch21022/prototype-plugin-architecture branch January 6, 2021 10:53
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