diff --git a/flytecopilot/cmd/sidecar.go b/flytecopilot/cmd/sidecar.go index 09abdb31e5c..2f597565bac 100644 --- a/flytecopilot/cmd/sidecar.go +++ b/flytecopilot/cmd/sidecar.go @@ -2,6 +2,7 @@ package cmd import ( "context" + stderrors "errors" "fmt" "time" @@ -144,10 +145,14 @@ func (u *UploadOptions) Sidecar(ctx context.Context) error { if err := u.uploader(ctx); err != nil { logger.Errorf(ctx, "Uploading failed, err %s", err) - if err := u.UploadError(ctx, "OutputUploadFailed", err, storage.DataReference(u.remoteOutputsPrefix)); err != nil { - logger.Errorf(ctx, "Failed to write error document, err :%s", err) - return err + if uerr := u.UploadError(ctx, "OutputUploadFailed", err, storage.DataReference(u.remoteOutputsPrefix)); uerr != nil { + logger.Errorf(ctx, "Failed to write error document, err :%s", uerr) + return stderrors.Join(uerr, err) } + + // failure to upload should still return err exit code from process + logger.Error(ctx, "Setting sidecar command error return value") + return err } return nil } @@ -164,7 +169,10 @@ func NewUploadCommand(opts *RootOptions) *cobra.Command { Short: "uploads flyteData from the localpath to a remote dir.", Long: `Currently it looks at the outputs.pb and creates one file per variable.`, RunE: func(cmd *cobra.Command, args []string) error { - return uploadOptions.Sidecar(context.Background()) + err := uploadOptions.Sidecar(context.Background()) + // failure to upload should still return err exit code from process + logger.Error(cmd.Context(), "NewUploadCommand returning failure through RunE, err %s", err) + return err }, }