sechub: PDS: Log error stream output of failed job

Problem

In case a PDS job fails, no additional information about the failure is getting logged other then that the job failed.

Solution

In case a PDS job fails, SecHub should retrieve the job_stream_error text of the PDS job and log parts of it. Only a summary should be logged as the job_stream_error output can get very long. For example, the first 2500 characters.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 31 (31 by maintainers)

Commits related to this issue

Most upvoted comments

@Jeeppler Thank you for the tip for readability. I made an improvement. Please have a look at my PR.

With the first, we checked whether your debugger settings are working. Result: the debugger works well. With number two, we checked whether the job really failed and it did.

The issue is, no exception is thrown if the job failed. As you can see in PDSExecutionCallable.call()#140:

        if (result.exitCode != 0) {
            result.failed = true;
        }

Basically, in all instances, where result.failed is set to true (result.failed = true), we want to have the stream error and stream output data logged.

In PDSExecutionCallable.call()#131 the workspace is cleared, therefore access to the stream error and output files is not possible anymore. As a result, you need to get both stream error and output from the db.

I would try the following:

Add a check in line 147, just after the log info message (in Pseudo code):

        LOG.info("Finished execution of job {} with exitCode={}, failed={}, cancelOperationsHasBeenStarted={}", pdsJobUUID, result.exitCode, result.failed,
                cancelOperationsHasBeenStarted);

if (result.failed) {
   getJobErrorStream from DB
   getJobOutputStream from DB

   read the last x couple of lines or characters of ErrorStream 
   read the last x couple of lines or characters of OutputStream

   Log shortened error stream
   Log shortened output stream
}

This might or might not be a working solution. I did not dig too deep into the source code. Give it a try and look at the code to gain a better understanding.