Skip to content

Commit 72d2d8b

Browse files
Merge pull request #514 from jenkins-x-plugins/prevent-hang
fix: prevent jx-build-controller from hanging
2 parents a091446 + a04ddee commit 72d2d8b

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

cmd/docs/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
66
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
7+
// http://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,

cmd/docs/md_docs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
66
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
7+
// http://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,

pkg/cmd/effective/effective.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package effective
22

33
import (
4-
"io/ioutil"
54
"os"
65
"path/filepath"
76
"strconv"
@@ -322,7 +321,7 @@ func (o *Options) displayPipeline(path, name string, pipeline *tektonv1beta1.Pip
322321
fileName = "jx-pipeline"
323322
}
324323
tmpFileName := fileName + "-" + strings.ReplaceAll(name, string(os.PathSeparator), "-") + "-*.yaml"
325-
tmpFile, err := ioutil.TempFile("", tmpFileName)
324+
tmpFile, err := os.CreateTemp("", tmpFileName)
326325
if err != nil {
327326
return errors.Wrapf(err, "failed to create temp file")
328327
}

pkg/pipelines/processor/inliner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (p *inliner) processPipelineSpec(ps *v1beta1.PipelineSpec, path string) (bo
5050
return ProcessPipelineSpec(ps, path, p.processTaskSpec)
5151
}
5252

53-
//nolint
53+
// nolint
5454
func (p *inliner) processTaskSpec(ts *v1beta1.TaskSpec, path, name string) (bool, error) {
5555
templateImage := ""
5656
if ts.StepTemplate != nil {

pkg/tektonlog/tektonlog.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ type stageTime struct {
215215
task string
216216
skipped bool
217217
podExists bool
218+
completed bool
218219
}
219220

220221
func (t *TektonLogger) getRunningBuildLogs(ctx context.Context, pa *v1.PipelineActivity, pipelineRuns []*tektonapis.PipelineRun, buildName string, out chan<- LogLine) error {
@@ -259,7 +260,7 @@ func (t *TektonLogger) getRunningBuildLogs(ctx context.Context, pa *v1.PipelineA
259260
completedStages[podName] = true
260261
}
261262

262-
} else if stage.skipped {
263+
} else if stage.skipped || stage.completed {
263264
completedStages[stageName] = true
264265
log.Logger().Infof("pod is skipped/failed for task: %s", stageName)
265266
}
@@ -273,7 +274,7 @@ func (t *TektonLogger) getRunningBuildLogs(ctx context.Context, pa *v1.PipelineA
273274
if len(completedStages) == len(stages) {
274275
loggedAllRunsForActivity = true
275276
} else {
276-
log.Logger().Debug("let's a wait second for next pod/task to start")
277+
log.Logger().Debug("let's wait a second for next pod/task to start")
277278
time.Sleep(time.Second)
278279
}
279280
}
@@ -332,12 +333,13 @@ func (t *TektonLogger) collectStages(ctx context.Context, pipelineRuns []*tekton
332333

333334
func findExecutedOrSkippedStagesStage(taskName string, pr *tektonapis.PipelineRun) stageTime {
334335
for _, taskStatus := range pr.Status.TaskRuns {
335-
if taskName == taskStatus.PipelineTaskName && taskStatus.Status.PodName != "" {
336+
if taskName == taskStatus.PipelineTaskName {
336337
return stageTime{
337338
podName: taskStatus.Status.PodName,
338339
startTime: taskStatus.Status.StartTime,
339340
task: taskName,
340-
podExists: true,
341+
podExists: taskStatus.Status.PodName != "",
342+
completed: taskStatus.Status.CompletionTime != nil,
341343
}
342344
}
343345
}

0 commit comments

Comments
 (0)