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

Pass plugin loaders to client and server #4730

Merged
merged 4 commits into from
Sep 27, 2018
Merged

Pass plugin loaders to client and server #4730

merged 4 commits into from
Sep 27, 2018

Conversation

dadgar
Copy link
Contributor

@dadgar dadgar commented Sep 27, 2018

This PR:

  • Loads a plugin loader and singleton plugin loader on the agent
  • Passes both loaders to the client and server
  • Passes the loaders to testing clients and servers
  • Fixes an issue where client configs were not being reloaded
  • Plugin loader prefers external configs over internal configs

@dadgar dadgar changed the base branch from master to r-clientv2 September 27, 2018 01:20
Copy link
Member

@nickethier nickethier left a comment

Choose a reason for hiding this comment

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

Small nit, looks good though.

Pondered about a way we could only have to add a single new plugin loader field to the config structs with something like below, but ultimately I don't think we gain much from it and the two fields is much more straight forward.

type PluginCatalogWithSingleton interface {
  PluginCatalog
  Singleton() PluginCatalog
}
``


pluginConfig = pc

// TODO We should log the config to warn users about upgrade pathing
Copy link
Member

Choose a reason for hiding this comment

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

Should we attempt to merge the two pluginConfigs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now lets keep it simple. Merging behavior at anything more than key merge would be very tricky. How do you merge two arrays for example

)

// Registration is the registration of an internal plugin
type Registration struct {
Copy link
Member

Choose a reason for hiding this comment

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

I would consider adding a func with a Registration receiver that returns the map[string]interface{} after doing the check if ConfigLoader is set.

Copy link
Member

@schmichael schmichael left a comment

Choose a reason for hiding this comment

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

Is it possible to create the PluginLoader, use it to initialize the catalog, then wrap it in the singleton wrapper and only expose that wrapper to the client?

I'm unsure why you need both around after initialization, and I'm afraid it will be easy to accidentally use the wrong one since they have the same API.


for id, reg := range catalog {
if reg.Config == nil {
a.logger.Warn("skipping loading internal plugin because it is missing its configuration", "plugin", id)
Copy link
Member

Choose a reason for hiding this comment

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

Is this a programming error? If so it seems like it should be ERROR if not a panic.

// Capture the list of binaries in the plugins folder
f, err := os.Open(l.pluginDir)
if err != nil {
// There are no plugins to scan
if os.IsNotExist(err) {
Copy link
Member

Choose a reason for hiding this comment

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

Trace (or debug) log message in this case to help users who accidently misconfigured their plugin dir.

@dadgar dadgar merged commit d7894ea into r-clientv2 Sep 27, 2018
@dadgar dadgar deleted the f-plugin-loader branch September 27, 2018 16:37
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants