mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-18 14:47:38 +01:00
Merge pull request #7594 from wy65701436/fix-gc-log
Fix get log issue of Periodic job
This commit is contained in:
commit
e64a71d809
@ -108,7 +108,7 @@ func (d *DefaultClient) GetJobLog(uuid string) ([]byte, error) {
|
|||||||
|
|
||||||
// GetExecutions ...
|
// GetExecutions ...
|
||||||
func (d *DefaultClient) GetExecutions(periodicJobID string) ([]job.Stats, error) {
|
func (d *DefaultClient) GetExecutions(periodicJobID string) ([]job.Stats, error) {
|
||||||
url := fmt.Sprintf("%s/api/v1/jobs/%s/executions", d.endpoint, periodicJobID)
|
url := fmt.Sprintf("%s/api/v1/jobs/%s/executions?page_number=1&page_size=100", d.endpoint, periodicJobID)
|
||||||
req, err := http.NewRequest(http.MethodGet, url, nil)
|
req, err := http.NewRequest(http.MethodGet, url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -169,7 +169,8 @@ func (aj *AJAPI) getLog(id int64) {
|
|||||||
aj.SendNotFoundError(errors.New("Failed to get Job"))
|
aj.SendNotFoundError(errors.New("Failed to get Job"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
jobID := job.UUID
|
|
||||||
|
var jobID string
|
||||||
// to get the latest execution job id, then to query job log.
|
// to get the latest execution job id, then to query job log.
|
||||||
if job.Kind == common_job.JobKindPeriodic {
|
if job.Kind == common_job.JobKindPeriodic {
|
||||||
exes, err := utils_core.GetJobServiceClient().GetExecutions(job.UUID)
|
exes, err := utils_core.GetJobServiceClient().GetExecutions(job.UUID)
|
||||||
@ -178,10 +179,24 @@ func (aj *AJAPI) getLog(id int64) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(exes) == 0 {
|
if len(exes) == 0 {
|
||||||
aj.SendNotFoundError(errors.New("no execution log "))
|
aj.SendNotFoundError(errors.New("no execution log found"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
jobID = exes[0].Info.JobID
|
// get the latest terminal status execution.
|
||||||
|
for _, exe := range exes {
|
||||||
|
if exe.Info.Status == "Error" || exe.Info.Status == "Success" {
|
||||||
|
jobID = exe.Info.JobID
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// no execution found
|
||||||
|
if jobID == "" {
|
||||||
|
aj.SendNotFoundError(errors.New("no execution log found"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
jobID = job.UUID
|
||||||
}
|
}
|
||||||
|
|
||||||
logBytes, err := utils_core.GetJobServiceClient().GetJobLog(jobID)
|
logBytes, err := utils_core.GetJobServiceClient().GetJobLog(jobID)
|
||||||
|
Loading…
Reference in New Issue
Block a user