fix(js):job log not found issue

- return 404 code when the job log is not found

Signed-off-by: Steven Zou <szou@vmware.com>
This commit is contained in:
Steven Zou 2021-04-13 12:11:31 +08:00
parent 88889ba864
commit 39256193ca
2 changed files with 6 additions and 7 deletions

View File

@ -133,12 +133,7 @@ func (bc *basicController) GetJobLogData(jobID string) ([]byte, error) {
return nil, errs.BadRequestError(errors.New("empty job ID"))
}
logData, err := logger.Retrieve(jobID)
if err != nil {
return nil, errors.Wrapf(err, "error for getting log of job %s", jobID)
}
return logData, nil
return logger.Retrieve(jobID)
}
// CheckStatus is implementation of same method in core interface.

View File

@ -2,7 +2,10 @@ package getter
import (
"errors"
"fmt"
"github.com/goharbor/harbor/src/common/dao"
"github.com/goharbor/harbor/src/jobservice/errs"
)
// DBGetter is responsible for retrieving DB log data
@ -22,7 +25,8 @@ func (dbg *DBGetter) Retrieve(logID string) ([]byte, error) {
jobLog, err := dao.GetJobLog(logID)
if err != nil {
return nil, err
// Other errors have been ignored by GetJobLog()
return nil, errs.NoObjectFoundError(fmt.Sprintf("log entity: %s", logID))
}
return []byte(jobLog.Content), nil