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

avoid interacting with nil mutatedWfs #477

Merged
merged 3 commits into from
Aug 25, 2022
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
4 changes: 3 additions & 1 deletion pkg/controller/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ func (p *Propeller) Handle(ctx context.Context, namespace, name string) error {
if wfClosureCrdFields != nil {
// strip data populated from WorkflowClosureReference
w.SubWorkflows, w.Tasks, w.WorkflowSpec = nil, nil, nil
mutatedWf.SubWorkflows, mutatedWf.Tasks, mutatedWf.WorkflowSpec = nil, nil, nil
if mutatedWf != nil {
mutatedWf.SubWorkflows, mutatedWf.Tasks, mutatedWf.WorkflowSpec = nil, nil, nil
}
}

if err != nil {
Expand Down
21 changes: 21 additions & 0 deletions pkg/controller/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -894,4 +894,25 @@ func TestPropellerHandler_OffloadedWorkflowClosure(t *testing.T) {
err := p.Handle(ctx, namespace, name)
assert.Error(t, err)
})

t.Run("TryMutate failure is handled", func(t *testing.T) {
scope := promutils.NewTestScope()

protoStore := &storagemocks.ComposedProtobufStore{}
protoStore.OnReadProtobufMatch(mock.Anything, mock.Anything, mock.Anything).Return(fmt.Errorf("foo"))
exec.HandleCb = func(ctx context.Context, w *v1alpha1.FlyteWorkflow) error {
return fmt.Errorf("foo")
}
dataStore := storage.NewCompositeDataStore(storage.URLPathConstructor{}, protoStore)
p := NewPropellerHandler(ctx, cfg, dataStore, s, exec, scope)

err := p.Handle(ctx, namespace, name)
assert.Error(t, err, "foo")

r, err := s.Get(ctx, namespace, name)
assert.NoError(t, err)
assert.Nil(t, r.WorkflowSpec)
assert.Nil(t, r.SubWorkflows)
assert.Nil(t, r.Tasks)
})
}