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

Commit

Permalink
Fix #1211: Return a more detailed error if plugin is not found when s…
Browse files Browse the repository at this point in the history
…tarting a task.
  • Loading branch information
geauxvirtual committed Sep 28, 2016
1 parent c644599 commit e3ce8f9
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions control/subscription_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,7 @@ func (p *subscriptionGroups) validatePluginSubscription(pl core.SubscribedPlugin
}).Info(fmt.Sprintf("validating dependencies for plugin %s:%d", pl.Name(), pl.Version()))
lp, err := p.pluginManager.get(fmt.Sprintf("%s"+core.Separator+"%s"+core.Separator+"%d", pl.TypeName(), pl.Name(), pl.Version()))
if err != nil {
se := serror.New(fmt.Errorf("Plugin not found: type(%s) name(%s) version(%d)", pl.TypeName(), pl.Name(), pl.Version()))
se.SetFields(map[string]interface{}{
"name": pl.Name(),
"version": pl.Version(),
"type": pl.TypeName(),
})
serrs = append(serrs, se)
serrs = append(serrs, pluginNotFoundError(pl))
return serrs
}

Expand Down Expand Up @@ -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))
return serrs
}
plgs[i] = plg
Expand Down Expand Up @@ -525,6 +519,16 @@ func comparePlugins(newPlugins,
return
}

func pluginNotFoundError(pl core.SubscribedPlugin) serror.SnapError {
se := serror.New(fmt.Errorf("Plugin not found: type(%s) name(%s) version(%d)", pl.TypeName(), pl.Name(), pl.Version()))
se.SetFields(map[string]interface{}{
"name": pl.Name(),
"version": pl.Version(),
"type": pl.TypeName(),
})
return se
}

func key(p core.SubscribedPlugin) string {
return fmt.Sprintf("%v"+core.Separator+"%v"+core.Separator+"%v", p.TypeName(), p.Name(), p.Version())
}

0 comments on commit e3ce8f9

Please sign in to comment.