Skip to content

Commit

Permalink
add an error in base case for file size exceeded
Browse files Browse the repository at this point in the history
Signed-off-by: Yee Hing Tong <[email protected]>
  • Loading branch information
wild-endeavor committed Sep 6, 2024
1 parent a058fd1 commit 20bb8cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type RemoteFileOutputReader struct {
maxPayloadSize int64
}

var ErrRemoteFileExceedsMaxSize = errors.New("remote file exceeds max size")

func (r RemoteFileOutputReader) IsError(ctx context.Context) (bool, error) {
metadata, err := r.store.Head(ctx, r.outPath.GetErrorPath())
if err != nil {
Expand Down Expand Up @@ -81,7 +83,7 @@ func (r RemoteFileOutputReader) Exists(ctx context.Context) (bool, error) {
}
if md.Exists() {
if md.Size() > r.maxPayloadSize {
return false, errors.Errorf("output file @[%s] is too large [%d] bytes, max allowed [%d] bytes", r.outPath.GetOutputPath(), md.Size(), r.maxPayloadSize)
return false, errors.Wrapf(ErrRemoteFileExceedsMaxSize, "output file @[%s] is too large [%d] bytes, max allowed [%d] bytes", r.outPath.GetOutputPath(), md.Size(), r.maxPayloadSize)

Check warning on line 86 in flyteplugins/go/tasks/pluginmachinery/ioutils/remote_file_output_reader.go

View check run for this annotation

Codecov / codecov/patch

flyteplugins/go/tasks/pluginmachinery/ioutils/remote_file_output_reader.go#L86

Added line #L86 was not covered by tests
}
return true, nil
}
Expand Down
9 changes: 9 additions & 0 deletions flytepropeller/pkg/controller/nodes/task/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,15 @@ func (t *Handler) ValidateOutput(ctx context.Context, nodeID v1alpha1.NodeID, i
}
ok, err := r.Exists(ctx)
if err != nil {
if regErrors.Is(err, ioutils.ErrRemoteFileExceedsMaxSize) {
return &io.ExecutionError{
ExecutionError: &core.ExecutionError{
Code: "OutputSizeExceeded",
Message: fmt.Sprintf("Remote output size exceeds max, err: [%s]", err.Error()),
},
IsRecoverable: false,
}, nil

Check warning on line 744 in flytepropeller/pkg/controller/nodes/task/handler.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/nodes/task/handler.go#L737-L744

Added lines #L737 - L744 were not covered by tests
}
logger.Errorf(ctx, "Failed to check if the output file exists. Error: %s", err.Error())
return nil, err
}
Expand Down

0 comments on commit 20bb8cb

Please sign in to comment.