Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Fix #1211: Return better error for plugin not found when starting a task #1242

Merged
merged 2 commits into from
Oct 11, 2016
Merged

Fix #1211: Return better error for plugin not found when starting a task #1242

merged 2 commits into from
Oct 11, 2016

Conversation

geauxvirtual
Copy link
Contributor

Fixes #1211

Summary of changes:

  • Refactor and return same plugin not found error for both validating a task and starting a task.
  • Refactor code creating plugin key to use key function.

Testing done:

  • Verified tests pass for small, medium, and legacy.
  • Verified error returns details on a plugin when a plugin is not found while trying to start a task.

@intelsdi-x/snap-maintainers

@@ -383,7 +377,7 @@ func (s *subscriptionGroup) subscribePlugins(id string,
for i, sub := range plugins {
plg, err := s.pluginManager.get(key(sub))
if err != nil {
serrs = append(serrs, serror.New(err))
serrs = append(serrs, pluginNotFoundError(sub))
Copy link
Contributor

Choose a reason for hiding this comment

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

PluginNotFound is not the only error that can be returned from the pluginManager.get call. Do we need to worry about badkey errors also?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm looking through the code to see if there any chance the code could hit that error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at the code, it's seems the check for a bad key is only if the plugin is not found and breaking the key apart to see if the latest plugin needs to be grabbed. The same error bad key is returned for multiple scenarios, so it's never clear what part of the key is bad.

pluginManager.get could return a clearer error on what plugin was not found, so then creating this error in subscription_group.go would then not be needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another example in the code base of treating any error returned from pluginManager.get as plugin not found. https://github.com/intelsdi-x/snap/blob/master/control/plugin_manager.go#L509-L518

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think pluginManager.get should be in charge of returning better errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After looking at the code, I would think the error handling would be better suited in pluginManager.get instead of loadedPlugins.get. At that point, loadedPlugins.get could possibly be simplified to return the loadedPlugin or nil, and let pluginManager.get decide what error to return: pluginNotFound or invalid key when no plugin is returned.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is that something you were going to do as part of this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel refactoring that code would be better in another PR.

@kindermoumoute
Copy link
Contributor

LGTM

@IRCody IRCody merged commit dcc1f27 into intelsdi-x:master Oct 11, 2016
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.

3 participants