Skip to content

Commit

Permalink
Return InvalidArgument for workflow compilation failures in CreateWor…
Browse files Browse the repository at this point in the history
…kflow (#4566)

* Return InvalidArgument for workflow compilation failures in CreateWorkflow

Signed-off-by: Katrina Rogan <[email protected]>

* lint

Signed-off-by: Katrina Rogan <[email protected]>

---------

Signed-off-by: Katrina Rogan <[email protected]>
Co-authored-by: Dan Rammer <[email protected]>
  • Loading branch information
katrogan and hamersaw authored Dec 11, 2023
1 parent 91d24a9 commit a5a9509
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion flyteadmin/cmd/entrypoints/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var serveCmd = &cobra.Command{

// register otel tracer providers
for _, serviceName := range []string{otelutils.AdminGormTracer, otelutils.AdminServerTracer} {
if err := otelutils.RegisterTracerProvider(serviceName, otelutils.GetConfig()) ; err != nil {
if err := otelutils.RegisterTracerProvider(serviceName, otelutils.GetConfig()); err != nil {
logger.Errorf(ctx, "Failed to create otel tracer provider. %v", err)
return err
}
Expand Down
2 changes: 1 addition & 1 deletion flyteadmin/pkg/manager/impl/workflow_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (w *WorkflowManager) CreateWorkflow(
workflowClosure, err := w.getCompiledWorkflow(ctx, finalizedRequest)
if err != nil {
logger.Errorf(ctx, "Failed to compile workflow with err: %v", err)
return nil, errors.NewFlyteAdminErrorf(codes.Internal,
return nil, errors.NewFlyteAdminErrorf(codes.InvalidArgument,
"failed to compile workflow for [%+v] with err %v", request.Id, err)
}
err = validation.ValidateCompiledWorkflow(
Expand Down
6 changes: 5 additions & 1 deletion flyteadmin/pkg/manager/impl/workflow_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/golang/protobuf/proto"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/flyteorg/flyte/flyteadmin/pkg/common"
commonMocks "github.com/flyteorg/flyte/flyteadmin/pkg/common/mocks"
Expand Down Expand Up @@ -243,10 +244,13 @@ func TestCreateWorkflow_CompileWorkflowError(t *testing.T) {
getMockWorkflowConfigProvider(), mockCompiler, getMockStorage(), storagePrefix, mockScope.NewTestScope())
request := testutils.GetWorkflowRequest()
response, err := workflowManager.CreateWorkflow(context.Background(), request)
assert.Nil(t, response)
s, ok := status.FromError(err)
assert.True(t, ok)
assert.Equal(t, codes.InvalidArgument, s.Code())
assert.EqualError(t, err, fmt.Sprintf(
"failed to compile workflow for [resource_type:WORKFLOW project:\"project\" domain:\"domain\" "+
"name:\"name\" version:\"version\" ] with err %v", expectedErr.Error()))
assert.Nil(t, response)
}

func TestCreateWorkflow_DatabaseError(t *testing.T) {
Expand Down

0 comments on commit a5a9509

Please sign in to comment.