mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-23 09:08:26 +01:00
Merge pull request #5160 from ywk253100/180619_response_code
Parse the error got from jobservice, fix #5047
This commit is contained in:
commit
66811b3289
@ -21,6 +21,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/vmware/harbor/src/common/dao"
|
"github.com/vmware/harbor/src/common/dao"
|
||||||
|
common_http "github.com/vmware/harbor/src/common/http"
|
||||||
common_job "github.com/vmware/harbor/src/common/job"
|
common_job "github.com/vmware/harbor/src/common/job"
|
||||||
"github.com/vmware/harbor/src/common/models"
|
"github.com/vmware/harbor/src/common/models"
|
||||||
"github.com/vmware/harbor/src/common/utils/log"
|
"github.com/vmware/harbor/src/common/utils/log"
|
||||||
@ -195,6 +196,12 @@ func (ra *RepJobAPI) GetLog() {
|
|||||||
|
|
||||||
logBytes, err := utils.GetJobServiceClient().GetJobLog(job.UUID)
|
logBytes, err := utils.GetJobServiceClient().GetJobLog(job.UUID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if httpErr, ok := err.(*common_http.Error); ok {
|
||||||
|
ra.RenderError(httpErr.Code, "")
|
||||||
|
log.Errorf(fmt.Sprintf("failed to get log of job %d: %d %s",
|
||||||
|
ra.jobID, httpErr.Code, httpErr.Message))
|
||||||
|
return
|
||||||
|
}
|
||||||
ra.HandleInternalServerError(fmt.Sprintf("failed to get log of job %s: %v",
|
ra.HandleInternalServerError(fmt.Sprintf("failed to get log of job %s: %v",
|
||||||
job.UUID, err))
|
job.UUID, err))
|
||||||
return
|
return
|
||||||
|
@ -16,6 +16,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/vmware/harbor/src/common/dao"
|
"github.com/vmware/harbor/src/common/dao"
|
||||||
|
common_http "github.com/vmware/harbor/src/common/http"
|
||||||
"github.com/vmware/harbor/src/common/utils/log"
|
"github.com/vmware/harbor/src/common/utils/log"
|
||||||
"github.com/vmware/harbor/src/ui/utils"
|
"github.com/vmware/harbor/src/ui/utils"
|
||||||
|
|
||||||
@ -65,6 +66,12 @@ func (sj *ScanJobAPI) Prepare() {
|
|||||||
func (sj *ScanJobAPI) GetLog() {
|
func (sj *ScanJobAPI) GetLog() {
|
||||||
logBytes, err := utils.GetJobServiceClient().GetJobLog(sj.jobUUID)
|
logBytes, err := utils.GetJobServiceClient().GetJobLog(sj.jobUUID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if httpErr, ok := err.(*common_http.Error); ok {
|
||||||
|
sj.RenderError(httpErr.Code, "")
|
||||||
|
log.Errorf(fmt.Sprintf("failed to get log of job %d: %d %s",
|
||||||
|
sj.jobID, httpErr.Code, httpErr.Message))
|
||||||
|
return
|
||||||
|
}
|
||||||
sj.HandleInternalServerError(fmt.Sprintf("Failed to get job logs, uuid: %s, error: %v", sj.jobUUID, err))
|
sj.HandleInternalServerError(fmt.Sprintf("Failed to get job logs, uuid: %s, error: %v", sj.jobUUID, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user