Skip to content

Commit 5e64a3c

Browse files
authored
Merge pull request #264 from newrelic/dependabot/go_modules/golang.org/x/net-0.55.0
chore(deps): bump golang.org/x/net from 0.33.0 to 0.55.0
2 parents 15db916 + be56764 commit 5e64a3c

12 files changed

Lines changed: 114 additions & 37 deletions

File tree

.github/workflows/compile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
go-version:
15-
- 1.22.x
15+
- 1.25.x
1616
platform:
1717
- ubuntu-latest
1818
- macos-latest

.github/workflows/integration-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Install Go
2121
uses: actions/setup-go@v3
2222
with:
23-
go-version: 1.22.x
23+
go-version: 1.25.x
2424
- name: Checkout code
2525
uses: actions/checkout@v3
2626
with:
@@ -42,7 +42,7 @@ jobs:
4242
- name: Install Go
4343
uses: actions/setup-go@v2
4444
with:
45-
go-version: 1.22.x
45+
go-version: 1.25.x
4646
- name: Checkout code
4747
uses: actions/checkout@v2
4848
with:

.github/workflows/lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
golangci:
99
strategy:
1010
matrix:
11-
go-version: [1.22.x]
11+
go-version: [1.25.x]
1212
os: [ubuntu-latest, macos-latest, windows-latest]
1313
name: lint
1414
runs-on: ${{ matrix.os }}
@@ -35,9 +35,9 @@ jobs:
3535
fi
3636
3737
- name: golangci-lint
38-
uses: golangci/golangci-lint-action@v6
38+
uses: golangci/golangci-lint-action@v8
3939
with:
40-
version: v1.63
40+
version: v2.12.2
4141
args: --timeout=5m
4242
only-new-issues: true
4343

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Install Go
1313
uses: actions/setup-go@v2
1414
with:
15-
go-version: 1.22.x
15+
go-version: 1.25.x
1616
- name: Checkout code
1717
uses: actions/checkout@v2
1818
with:

.github/workflows/rollback.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- name: Install Go
1212
uses: actions/setup-go@v2
1313
with:
14-
go-version: 1.22.x
14+
go-version: 1.25.x
1515
- name: Checkout code
1616
uses: actions/checkout@v2
1717
with:

.github/workflows/unit-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Install Go
2727
uses: actions/setup-go@v3
2828
with:
29-
go-version: 1.22.x
29+
go-version: 1.25.x
3030
- name: Cache deps
3131
uses: actions/cache@v3
3232
with:
@@ -44,7 +44,7 @@ jobs:
4444
- name: Install Go
4545
uses: actions/setup-go@v2
4646
with:
47-
go-version: 1.22.x
47+
go-version: 1.25.x
4848
- name: Checkout code
4949
uses: actions/checkout@v2
5050
with:

attach/attach.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func Upload(endpoint string, identifyingKey string, timestamp string, dependenci
7373
if !printedUrls[url] {
7474
infoStr := fmt.Sprintf("\t%v\n", url)
7575
filteredOutput := color.ColorString(color.LightBlue, infoStr)
76-
log.Infof(filteredOutput)
76+
log.Infof("%s", filteredOutput)
7777
}
7878
printedUrls[url] = true
7979
}

dockerHelper_test.go

Lines changed: 83 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
package main
22

33
import (
4+
"context"
45
"os"
56
"os/exec"
67
"runtime"
8+
"strings"
9+
"time"
710

811
log "github.com/newrelic/newrelic-diagnostics-cli/logger"
912
)
1013

14+
const (
15+
dockerBuildTimeout = 10 * time.Minute
16+
dockerRunTimeout = 10 * time.Minute
17+
)
18+
19+
var dockerBuildRetryPatterns = []string{
20+
"hcs::CreateComputeSystem",
21+
"failed to connect to the docker API",
22+
"docker_engine",
23+
}
24+
1125
func CreateDockerImage(imageName string, dockerFROM string, docker_cmd string, dockerLines []string) error {
1226

1327
//Create the Dockerfile
@@ -19,18 +33,74 @@ func CreateDockerImage(imageName string, dockerFROM string, docker_cmd string, d
1933

2034
log.Debug("Running docker build -f integrationDockerfile -t ", imageName, " .")
2135

22-
cmdBuild := exec.Command("docker", "build", "-f", dockerfile, "-t", imageName, ".")
23-
24-
output, cmdBuildErr := cmdBuild.CombinedOutput()
36+
const maxAttempts = 3
37+
var output []byte
38+
var cmdBuildErr error
39+
var timedOut bool
40+
for attempt := 1; attempt <= maxAttempts; attempt++ {
41+
ctx, cancel := context.WithTimeout(context.Background(), dockerBuildTimeout)
42+
cmdBuild := exec.CommandContext(ctx, "docker", "build", "-f", dockerfile, "-t", imageName, ".")
43+
output, cmdBuildErr = cmdBuild.CombinedOutput()
44+
timedOut = ctx.Err() == context.DeadlineExceeded
45+
cancel()
46+
47+
if cmdBuildErr == nil {
48+
break
49+
}
50+
if timedOut {
51+
log.Info("Docker build TIMED OUT for ", imageName, " after ", dockerBuildTimeout, " (attempt ", attempt, " of ", maxAttempts, ")")
52+
log.Info("Partial build output for ", imageName, ":\n", string(output))
53+
logDockerDiagnostics(imageName)
54+
}
55+
if attempt == maxAttempts || !isTransientDockerError(string(output)) {
56+
break
57+
}
58+
log.Info("Transient docker build error for ", imageName, " (attempt ", attempt, " of ", maxAttempts, "), retrying in ", attempt*5, "s")
59+
time.Sleep(time.Duration(attempt*5) * time.Second)
60+
}
2561

2662
if cmdBuildErr != nil {
2763
log.Info("Error running docker build -", cmdBuildErr)
2864
log.Info("Error was ", string(output))
2965
return cmdBuildErr
3066
}
67+
log.Info("Docker build output for ", imageName, ":\n", string(output))
3168
return nil
3269
}
3370

71+
func isTransientDockerError(output string) bool {
72+
for _, pattern := range dockerBuildRetryPatterns {
73+
if strings.Contains(output, pattern) {
74+
return true
75+
}
76+
}
77+
return false
78+
}
79+
80+
func logDockerDiagnostics(imageName string) {
81+
log.Info("=== Docker diagnostics for ", imageName, " ===")
82+
83+
psCtx, psCancel := context.WithTimeout(context.Background(), 30*time.Second)
84+
psOut, psErr := exec.CommandContext(psCtx, "docker", "ps", "-a").CombinedOutput()
85+
psCancel()
86+
if psErr != nil {
87+
log.Info("docker ps -a failed: ", psErr, " output: ", string(psOut))
88+
} else {
89+
log.Info("docker ps -a:\n", string(psOut))
90+
}
91+
92+
infoCtx, infoCancel := context.WithTimeout(context.Background(), 30*time.Second)
93+
infoOut, infoErr := exec.CommandContext(infoCtx, "docker", "info").CombinedOutput()
94+
infoCancel()
95+
if infoErr != nil {
96+
log.Info("docker info failed: ", infoErr, " output: ", string(infoOut))
97+
} else {
98+
log.Info("docker info:\n", string(infoOut))
99+
}
100+
101+
log.Info("=== End docker diagnostics for ", imageName, " ===")
102+
}
103+
34104
// CreateDockerfile - This builds the raw Dockerfile from the slice of tests
35105
func CreateDockerfile(imageName string, dockerFROM string, dockerCMD string, dockerfileLines []string) (string, error) {
36106
f, _ := os.CreateTemp("temp", imageName)
@@ -47,7 +117,7 @@ func CreateDockerfile(imageName string, dockerFROM string, dockerCMD string, doc
47117
}
48118

49119
baseWindowsDockerFrom := []string{
50-
"FROM mcr.microsoft.com/windows/servercore:ltsc2022",
120+
"FROM mcr.microsoft.com/windows/servercore:ltsc2025",
51121
`SHELL ["powershell"]`,
52122
"RUN NET USER nrdiagadmin /add",
53123
"RUN NET LOCALGROUP administrators /add nrdiagadmin",
@@ -120,10 +190,18 @@ func RunDockerContainer(imageName string, hostsAdditions []string) (string, erro
120190
}
121191
}
122192
args = append(args, imageName)
123-
cmd := exec.Command("docker", args...)
193+
194+
ctx, cancel := context.WithTimeout(context.Background(), dockerRunTimeout)
195+
defer cancel()
196+
cmd := exec.CommandContext(ctx, "docker", args...)
124197

125198
out, cmdErr := cmd.CombinedOutput()
126199
if cmdErr != nil {
200+
if ctx.Err() == context.DeadlineExceeded {
201+
log.Info("Docker run TIMED OUT for ", imageName, " after ", dockerRunTimeout)
202+
log.Info("Partial run output for ", imageName, ":\n", string(out))
203+
logDockerDiagnostics(imageName)
204+
}
127205
// Docker daemon returns exit code 125 in jenkins but runs normally otherwise
128206
if cmdErr.Error() == "exit status 125" {
129207
return string(out[:]), nil

go.mod

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/newrelic/newrelic-diagnostics-cli
22

3-
go 1.22.0
4-
5-
toolchain go1.23.5
3+
go 1.25.0
64

75
require (
86
github.com/StackExchange/wmi v1.2.1
@@ -15,7 +13,7 @@ require (
1513
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4
1614
github.com/stretchr/testify v1.9.0
1715
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8
18-
golang.org/x/sys v0.28.0
16+
golang.org/x/sys v0.45.0
1917
gopkg.in/cheggaaa/pb.v1 v1.0.28
2018
gopkg.in/yaml.v3 v3.0.1
2119
)
@@ -40,7 +38,7 @@ require (
4038
github.com/tklauser/go-sysconf v0.3.14 // indirect
4139
github.com/tklauser/numcpus v0.8.0 // indirect
4240
github.com/yusufpapurcu/wmi v1.2.4 // indirect
43-
golang.org/x/net v0.33.0 // indirect
44-
golang.org/x/text v0.21.0 // indirect
45-
golang.org/x/tools v0.28.0 // indirect
41+
golang.org/x/net v0.55.0 // indirect
42+
golang.org/x/text v0.37.0 // indirect
43+
golang.org/x/tools v0.44.0 // indirect
4644
)

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,19 @@ github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo
6262
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
6363
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY=
6464
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
65-
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
66-
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
65+
golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8=
66+
golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww=
6767
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6868
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6969
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
7070
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
7171
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
72-
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
73-
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
74-
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
75-
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
76-
golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8=
77-
golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw=
72+
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
73+
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
74+
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
75+
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
76+
golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
77+
golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI=
7878
google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk=
7979
google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
8080
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=

0 commit comments

Comments
 (0)