-
Notifications
You must be signed in to change notification settings - Fork 59
Introduce default plugin for task type #199
Changes from 13 commits
fd286d8
70c9375
7963b3e
b86f861
e9167df
08d6c89
c538833
3b69ab0
c7f3861
3d1af75
b5b0d62
0d4aee2
2e507c9
2dafb0b
e2066d3
a8117a0
6d138e0
c5ecc26
99dd7bd
b102b81
3f23ae3
171168c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -204,6 +204,10 @@ func (t *Handler) Setup(ctx context.Context, sCtx handler.SetupContext) error { | |
| return err | ||
| } | ||
|
|
||
| // Not every task type will have a default plugin specified in the flytepropeller config. | ||
| // That's fine, we resort to using the plugins' static RegisteredTaskTypes as a fallback. | ||
| fallbackTaskHandlerMap := make(map[string]map[string]pluginCore.Plugin) | ||
katrogan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| for _, p := range enabledPlugins { | ||
| // create a new resource registrar proxy for each plugin, and pass it into the plugin's LoadPlugin() via a setup context | ||
| pluginResourceNamespacePrefix := pluginCore.ResourceNamespace(newResourceManagerBuilder.GetID()).CreateSubNamespace(pluginCore.ResourceNamespace(p.ID)) | ||
|
|
@@ -216,16 +220,30 @@ func (t *Handler) Setup(ctx context.Context, sCtx handler.SetupContext) error { | |
| return regErrors.Wrapf(err, "failed to load plugin - %s", p.ID) | ||
| } | ||
| for _, tt := range p.RegisteredTaskTypes { | ||
| logger.Infof(ctx, "Plugin [%s] registered for TaskType [%s]", cp.GetID(), tt) | ||
| // TODO(katrogan): Make the default task plugin assignment more explicit (https://github.com/lyft/flyte/issues/516) | ||
| t.defaultPlugins[tt] = cp | ||
| for _, defaultTaskType := range p.DefaultForTaskTypes { | ||
EngHabu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if defaultTaskType == tt { | ||
| if existingHandler, alreadyDefaulted := t.defaultPlugins[tt]; alreadyDefaulted && existingHandler.GetID() != cp.GetID() { | ||
| logger.Panicf(ctx, "TaskType [%s] has multiple default handlers specified: [%s] and [%s]", | ||
|
||
| tt, existingHandler.GetID(), cp.GetID()) | ||
| } | ||
| logger.Infof(ctx, "Plugin [%s] registered for TaskType [%s]", cp.GetID(), tt) | ||
| t.defaultPlugins[tt] = cp | ||
| } | ||
| } | ||
|
|
||
| pluginsForTaskType, ok := t.pluginsForType[tt] | ||
| if !ok { | ||
| pluginsForTaskType = make(map[pluginID]pluginCore.Plugin) | ||
| } | ||
| pluginsForTaskType[cp.GetID()] = cp | ||
| t.pluginsForType[tt] = pluginsForTaskType | ||
|
|
||
| fallbackMap, ok := fallbackTaskHandlerMap[tt] | ||
| if !ok { | ||
| fallbackMap = make(map[string]pluginCore.Plugin) | ||
| } | ||
| fallbackMap[cp.GetID()] = cp | ||
| fallbackTaskHandlerMap[tt] = fallbackMap | ||
| } | ||
| if p.IsDefault { | ||
| if err := t.setDefault(ctx, cp); err != nil { | ||
|
|
@@ -234,6 +252,19 @@ func (t *Handler) Setup(ctx context.Context, sCtx handler.SetupContext) error { | |
| } | ||
| } | ||
|
|
||
| // Read from the fallback task handler map for any remaining tasks without a defaultPlugins registered handler. | ||
| for taskType, registeredPlugins := range fallbackTaskHandlerMap { | ||
| if _, ok := t.defaultPlugins[taskType]; ok { | ||
| break | ||
| } | ||
| if len(registeredPlugins) != 1 { | ||
| logger.Panicf(ctx, "Multiple plugins registered to handle task type: %s. ([%+v])", taskType, registeredPlugins) | ||
|
||
| } | ||
| for _, plugin := range registeredPlugins { | ||
| t.defaultPlugins[taskType] = plugin | ||
| } | ||
| } | ||
|
|
||
| rm, err := newResourceManagerBuilder.BuildResourceManager(ctx) | ||
| if err != nil { | ||
| logger.Errorf(ctx, "Failed to build a resource manager") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.