Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Introduce default plugin for task type #199

Merged
merged 22 commits into from
Nov 2, 2020
Merged

Conversation

katrogan
Copy link
Contributor

TL;DR

Introduce default plugin for task type configurable in the flytepropeller config.

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

Tracking Issue

flyteorg/flyte#516

Follow-up issue

NA

@katrogan katrogan removed the request for review from kumare3 October 19, 2020 23:02
go.mod Outdated Show resolved Hide resolved
pkg/controller/nodes/task/config/config.go Outdated Show resolved Hide resolved
pkg/controller/nodes/task/config/config.go Outdated Show resolved Hide resolved
pkg/controller/nodes/task/config/config.go Outdated Show resolved Hide resolved
pkg/controller/nodes/task/config/config.go Show resolved Hide resolved
pkg/controller/nodes/task/handler.go Outdated Show resolved Hide resolved
@katrogan
Copy link
Contributor Author

friendly ping @EngHabu

@katrogan katrogan requested a review from EngHabu October 26, 2020 16:42
@katrogan
Copy link
Contributor Author

ping @EngHabu

Copy link
Contributor

@EngHabu EngHabu left a comment

Choose a reason for hiding this comment

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

I think we are close!
I'll try to write down my understand and plz correct me where I got it wrong.
We have these different settings:
1- Plugin Author decides which task types a plugin can handle,
2- Plugin Author decides which task types a plugin can be the default for (We should consider punting on this)
3- Admin decides which plugins are enabled
4- Admin decides which plugins are defaults for which task types

Some validation before attempting the resolution:

The resolution for which defaults are should be:

I think we should consider getting rid of #2 and just consider #1 as such... In what scenarios would these be different?

config.yaml Outdated Show resolved Hide resolved
for _, defaultTaskType := range p.DefaultForTaskTypes {
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]",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think you can just return an error... and let the top layer panic... I generally think panic should happen at the very top layer of any application (specifically the top most layer that cannot propagate errors any further) and everywhere else we should just propagate errors (Must*-style functions is a sort-of an exception)

pkg/controller/nodes/task/plugin_config.go Outdated Show resolved Hide resolved
pkg/controller/nodes/task/config/config.go Outdated Show resolved Hide resolved
break
}
if len(registeredPlugins) != 1 {
logger.Panicf(ctx, "Multiple plugins registered to handle task type: %s. ([%+v])", taskType, registeredPlugins)
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

pkg/controller/nodes/task/handler.go Show resolved Hide resolved
@katrogan
Copy link
Contributor Author

We have these different settings:
1- Plugin Author decides which task types a plugin can handle,
2- Plugin Author decides which task types a plugin can be the default for (We should consider punting on this)
3- Admin decides which plugins are enabled
4- Admin decides which plugins are defaults for which task types

Some validation before attempting the resolution:

If a plugin exist in #4 but the plugin isn't enabled (not in #3 nor allpluginsEnabled) or doesn't exist, fail?
The resolution for which defaults are should be:

If a task type exist in #4, that plugin choice wins
Otherwise, tasks defined in #2 take precedence, if there is a conflict, fail
I think we should consider getting rid of #2 and just consider #1 as such... In what scenarios would these be different?

2 is not supported. Plugin authors cannot specify defaults, only registered tasks. Plugin resolution in propeller should ignore any default values plugin authors attempt to set.

re: 3 this will require an idl and admin change. currently admin only provides overrides for specific plugins for a task type. if we want the net affect of this change to be 3, such that the defaults are specified in admin rather than in the propeller config I can close this PR and take that approach.

@katrogan
Copy link
Contributor Author

re 2: see why it's not supported currently here: #199 (comment) (one of your comments was on an outdated file version, so not sure if that led to any confusion)

i updated to error when a default for a task type is specified for a plugin that is not enabled. other than that the order of default preference should indeed be 4, then 1

@katrogan katrogan requested a review from EngHabu October 30, 2020 21:26
@codecov-io
Copy link

codecov-io commented Oct 30, 2020

Codecov Report

Merging #199 into master will decrease coverage by 0.12%.
The diff coverage is 37.93%.

@katrogan katrogan requested a review from EngHabu October 31, 2020 00:00
EngHabu
EngHabu previously approved these changes Nov 2, 2020
Copy link
Contributor

@EngHabu EngHabu left a comment

Choose a reason for hiding this comment

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

I think that's it! Thank you a ton for walking me through the code the other day.
Just a couple of tiny nits

pkg/controller/nodes/task/plugin_config.go Outdated Show resolved Hide resolved
pkg/controller/nodes/task/plugin_config.go Outdated Show resolved Hide resolved
pkg/controller/nodes/task/handler.go Outdated Show resolved Hide resolved
pkg/controller/nodes/task/handler.go Outdated Show resolved Hide resolved
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