Skip to content

Commit 48a7660

Browse files
authored
Merge pull request #43 from nginxinc/fix-extend-timeouts
Extend timeout for log collection
2 parents a962647 + adee012 commit 48a7660

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

cmd/nginx-supportpkg.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ func Execute() {
6060
}
6161

6262
if collector.AllNamespacesExist() {
63+
failedJobs := 0
6364
for _, job := range jobList {
6465
fmt.Printf("Running job %s...", job.Name)
6566
err = job.Collect(collector)
6667
if err != nil {
6768
fmt.Printf(" Error: %s\n", err)
69+
failedJobs++
6870
} else {
6971
fmt.Print(" OK\n")
7072
}
@@ -75,7 +77,13 @@ func Execute() {
7577
fmt.Println(fmt.Errorf("error when wrapping up: %s", err))
7678
os.Exit(1)
7779
} else {
78-
fmt.Printf("Supportpkg successfully generated: %s\n", tarFile)
80+
if failedJobs == 0 {
81+
fmt.Printf("Supportpkg successfully generated: %s\n", tarFile)
82+
} else {
83+
fmt.Printf("WARNING: %d failed job(s)\n", failedJobs)
84+
fmt.Printf("Supportpkg generated with warnings: %s\n", tarFile)
85+
}
86+
7987
}
8088
} else {
8189
fmt.Println(" Error: Some namespaces do not exist")

pkg/jobs/common_job_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func CommonJobList() []Job {
5252
},
5353
{
5454
Name: "collect-pods-logs",
55-
Timeout: time.Second * 30,
55+
Timeout: time.Second * 120,
5656
Execute: func(dc *data_collector.DataCollector, ctx context.Context, ch chan JobResult) {
5757
jobResult := JobResult{Files: make(map[string][]byte), Error: nil}
5858
for _, namespace := range dc.Namespaces {

pkg/jobs/job.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (j Job) Collect(dc *data_collector.DataCollector) error {
5050

5151
select {
5252
case <-ctx.Done():
53-
dc.Logger.Printf("\tJob %s has timed out: %s\n", j.Name, ctx.Err())
53+
dc.Logger.Printf("\tJob %s has timed out: %s\n---\n", j.Name, ctx.Err())
5454
return errors.New(fmt.Sprintf("Context cancelled: %v", ctx.Err()))
5555

5656
case jobResults := <-ch:

0 commit comments

Comments
 (0)