KhaninArtur commented on a change in pull request #16121:
URL: https://github.com/apache/beam/pull/16121#discussion_r761995360



##########
File path: playground/backend/internal/code_processing/code_processing.go
##########
@@ -91,42 +115,89 @@ func Process(ctx context.Context, cacheService 
cache.Cache, lc *fs_tool.LifeCycl
                var compileOutput bytes.Buffer
                runCmdWithOutput(compileCmd, &compileOutput, &compileError, 
successChannel, errorChannel)
 
-               if err = processStep(ctxWithTimeout, pipelineId, cacheService, 
cancelChannel, successChannel, &compileOutput, &compileError, errorChannel, 
pb.Status_STATUS_COMPILE_ERROR, pb.Status_STATUS_EXECUTING); err != nil {
+               ok, err = processStep(ctxWithTimeout, pipelineId, cacheService, 
cancelChannel, successChannel)
+               if err != nil {
+                       return
+               }
+               if !ok {
+                       _ = processCompileError(ctxWithTimeout, errorChannel, 
compileError.Bytes(), pipelineId, cacheService)
+                       return
+               }
+               if err := processCompileSuccess(ctxWithTimeout, 
compileOutput.Bytes(), pipelineId, cacheService); err != nil {
                        return
                }
        case pb.Sdk_SDK_PYTHON:
-               processSuccess(ctx, []byte(""), pipelineId, cacheService, 
pb.Status_STATUS_EXECUTING)
+               if err := processCompileSuccess(ctxWithTimeout, []byte(""), 
pipelineId, cacheService); err != nil {
+                       return
+               }
        }
 
        // Run
        if sdkEnv.ApacheBeamSdk == pb.Sdk_SDK_JAVA {
-               executor = setJavaExecutableFile(lc, pipelineId, cacheService, 
ctxWithTimeout, executorBuilder, appEnv.WorkingDir())
+               executor, err = setJavaExecutableFile(lc, pipelineId, 
cacheService, ctxWithTimeout, executorBuilder, appEnv.WorkingDir())
+               if err != nil {
+                       return
+               }
        }
        logger.Infof("%s: Run() ...\n", pipelineId)
        runCmd := executor.Run(ctxWithTimeout)
        var runError bytes.Buffer
        runOutput := streaming.RunOutputWriter{Ctx: ctxWithTimeout, 
CacheService: cacheService, PipelineId: pipelineId}
-       runCmdWithOutput(runCmd, &runOutput, &runError, successChannel, 
errorChannel)
+       go readLogFile(ctxWithTimeout, cacheService, 
lc.GetAbsoluteLogFilePath(), pipelineId, stopReadLogsChannel, 
finishReadLogsChannel)
 
-       err = processStep(ctxWithTimeout, pipelineId, cacheService, 
cancelChannel, successChannel, nil, &runError, errorChannel, 
pb.Status_STATUS_RUN_ERROR, pb.Status_STATUS_FINISHED)
+       if sdkEnv.ApacheBeamSdk == pb.Sdk_SDK_GO {
+               // For go SDK all logs are placed to stdErr.
+               file, err := os.Create(lc.GetAbsoluteLogFilePath())
+               if err != nil {
+                       // If some error with creating a log file do the same 
as with other SDK.
+                       logger.Errorf("%s: error during create log file (go 
sdk): %s", pipelineId, err.Error())
+                       runCmdWithOutput(runCmd, &runOutput, &runError, 
successChannel, errorChannel)

Review comment:
       Got it, thanks!




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to