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

Fix nil pointer when task plugin load returns error #5622

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions flytepropeller/pkg/controller/nodes/task/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,14 @@ func (t *Handler) Setup(ctx context.Context, sCtx interfaces.SetupContext) error
logger.Infof(ctx, "Loading Plugin [%s] ENABLED", p.ID)
cp, err := pluginCore.LoadPlugin(ctx, sCtxFinal, p)

if err != nil {
return regErrors.Wrapf(err, "failed to load plugin - %s", p.ID)
}

if cp.GetID() == agent.ID {
t.agentService.CorePlugin = cp
}

if err != nil {
return regErrors.Wrapf(err, "failed to load plugin - %s", p.ID)
}
// For every default plugin for a task type specified in flytepropeller config we validate that the plugin's
// static definition includes that task type as something it is registered to handle.
for _, tt := range p.RegisteredTaskTypes {
Expand Down
18 changes: 18 additions & 0 deletions flytepropeller/pkg/controller/nodes/task/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ func Test_task_Setup(t *testing.T) {
k8sPluginDefault := &pluginK8sMocks.Plugin{}
k8sPluginDefault.OnGetProperties().Return(pluginK8s.PluginProperties{})

loadErrorPluginType := "loadError"

corePluginEntry := pluginCore.PluginEntry{
ID: corePluginType,
RegisteredTaskTypes: []pluginCore.TaskType{corePluginType},
Expand Down Expand Up @@ -154,6 +156,13 @@ func Test_task_Setup(t *testing.T) {
RegisteredTaskTypes: []pluginCore.TaskType{k8sPluginDefaultType},
ResourceToWatch: &v1.Pod{},
}
loadErrorPluginEntry := pluginCore.PluginEntry{
ID: loadErrorPluginType,
RegisteredTaskTypes: []pluginCore.TaskType{loadErrorPluginType},
LoadPlugin: func(ctx context.Context, iCtx pluginCore.SetupContext) (pluginCore.Plugin, error) {
return nil, fmt.Errorf("test")
},
}

type wantFields struct {
pluginIDs map[pluginCore.TaskType]string
Expand Down Expand Up @@ -232,6 +241,15 @@ func Test_task_Setup(t *testing.T) {
},
},
false},
{"load-error",
testPluginRegistry{
core: []pluginCore.PluginEntry{loadErrorPluginEntry},
k8s: []pluginK8s.PluginEntry{},
},
[]string{loadErrorPluginType},
map[string]string{corePluginType: loadErrorPluginType},
wantFields{},
true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Loading