[ https://issues.apache.org/jira/browse/BEAM-13334?focusedWorklogId=690060&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-690060 ]
ASF GitHub Bot logged work on BEAM-13334: ----------------------------------------- Author: ASF GitHub Bot Created on: 03/Dec/21 14:45 Start Date: 03/Dec/21 14:45 Worklog Time Spent: 10m Work Description: AydarZaynutdinov commented on a change in pull request #16121: URL: https://github.com/apache/beam/pull/16121#discussion_r761996512 ########## 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) + } else { + // Use the log file to write all stdErr into it. + runCmdWithOutput(runCmd, &runOutput, file, successChannel, errorChannel) + } + } else { + // Other SDKs write logs to the log file on their own. + runCmdWithOutput(runCmd, &runOutput, &runError, successChannel, errorChannel) + } + + ok, err = processStep(ctxWithTimeout, pipelineId, cacheService, cancelChannel, successChannel) if err != nil { return } + if !ok { + if sdkEnv.ApacheBeamSdk == pb.Sdk_SDK_GO { Review comment: after the second if we have some logic that should be done without checking SDK: ``` ... if !ok { if sdkEnv.ApacheBeamSdk == pb.Sdk_SDK_GO { // code for the Go SDK only } // code for all SDK (including Go SDK after the top part) return } ... ``` If I join these 2 `if`s it will be something like: ``` if !ok && sdkEnv.ApacheBeamSdk == pb.Sdk_SDK_GO { // code for the Go SDK only // code for all SDK (including Go SDK after the top part) return } if !ok { // code for all SDK (including Go SDK after the top part) return } ``` So I think it's better to use present code. -- 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: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 690060) Time Spent: 1h (was: 50m) > [Playground] Save Go logs to the cache > -------------------------------------- > > Key: BEAM-13334 > URL: https://issues.apache.org/jira/browse/BEAM-13334 > Project: Beam > Issue Type: Sub-task > Components: beam-playground > Reporter: Aydar Zaynutdinov > Assignee: Aydar Zaynutdinov > Priority: P3 > Labels: beam-playground-backend, beam-playground-sprint-5 > Time Spent: 1h > Remaining Estimate: 0h > > Configure Go code processing to save all code processing logs to the cache > using a certain `pipelineId` as a key and a new subKey `Logs`. -- This message was sent by Atlassian Jira (v8.20.1#820001)