Skip to content

Commit

Permalink
Merge pull request #3384 from saschagrunert/history-skip
Browse files Browse the repository at this point in the history
Skip unfinished jobs in `krel history`
  • Loading branch information
k8s-ci-robot authored Dec 1, 2023
2 parents 3801935 + 11112ad commit a5b92b7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pkg/gcp/gcb/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ func (h *History) Run() error {
end := job.Timing["BUILD"].EndTime
logs := job.LogUrl

if start == "" || end == "" {
logrus.Infof("Skipping unfinished job from %s with ID: %s", job.CreateTime, job.Id)
continue
}

// Calculate the duration of the job
const layout = "2006-01-02T15:04:05.99Z"
tStart, err := h.impl.ParseTime(layout, start)
Expand Down
10 changes: 8 additions & 2 deletions pkg/gcp/gcb/history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ func TestHistoryRun(t *testing.T) {
{
Tags: []string{"RELEASE"},
Timing: map[string]cloudbuild.TimeSpan{
"BUILD": {StartTime: "wrong"},
"BUILD": {
StartTime: "wrong",
EndTime: "2020-10-10",
},
},
},
}, nil)
Expand All @@ -121,7 +124,10 @@ func TestHistoryRun(t *testing.T) {
{
Tags: []string{"STAGE"},
Timing: map[string]cloudbuild.TimeSpan{
"BUILD": {EndTime: "wrong"},
"BUILD": {
StartTime: "2020-10-10",
EndTime: "wrong",
},
},
Substitutions: map[string]string{"_NOMOCK": "true"},
},
Expand Down

0 comments on commit a5b92b7

Please sign in to comment.