Skip to content

Commit 0b4cfa2

Browse files
authored
Update go, alpine, proto toolchain (#527)
1 parent 10c1fc1 commit 0b4cfa2

17 files changed

+244
-252
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3.19
1+
FROM alpine:3.20
22
RUN apk -U add ca-certificates
33
COPY bin/metal-api /metal-api
44
CMD ["/metal-api"]

cmd/metal-api/internal/grpc/boot-service-wait_integration_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,14 @@ func (t *test) startMachineInstances() {
249249
opts := []grpc.DialOption{
250250
grpc.WithKeepaliveParams(kacp),
251251
grpc.WithTransportCredentials(insecure.NewCredentials()),
252-
grpc.WithBlock(),
253252
}
254253
for i := range t.numberMachineInstances {
255254
machineID := strconv.Itoa(i)
256255
// golangci-lint has an issue with math/rand/v2
257256
// here it provides sufficient randomness though because it's not used for cryptographic purposes
258257
port := 50005 + rand.N(t.numberApiInstances) //nolint:gosec
259258
ctx, cancel := context.WithCancel(context.Background())
260-
conn, err := grpc.DialContext(ctx, fmt.Sprintf("localhost:%d", port), opts...)
259+
conn, err := grpc.NewClient(fmt.Sprintf("localhost:%d", port), opts...)
261260
require.NoError(t, err)
262261
t.cc = append(t.cc, &client{
263262
ClientConn: conn,

cmd/metal-api/internal/headscale/client.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,14 @@ func NewHeadscaleClient(addr, controlPlaneAddr, apiKey string, logger *slog.Logg
5252

5353
// Connect or reconnect to Headscale server
5454
func (h *HeadscaleClient) connect(apiKey string) (err error) {
55-
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
56-
defer cancel()
57-
5855
grpcOptions := []grpc.DialOption{
59-
grpc.WithBlock(),
6056
grpc.WithTransportCredentials(insecure.NewCredentials()),
6157
grpc.WithPerRPCCredentials(tokenAuth{
6258
token: apiKey,
6359
}),
6460
}
6561

66-
h.conn, err = grpc.DialContext(ctx, h.address, grpcOptions...)
62+
h.conn, err = grpc.NewClient(h.address, grpcOptions...)
6763
if err != nil {
6864
return fmt.Errorf("failed to connect to headscale server %s: %w", h.address, err)
6965
}

cmd/metal-api/internal/metal/network.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ type NicState struct {
6767
// state has been reached.
6868
//
6969
// If the given status differs from the current Actual state, Desired is left
70-
// unchanged if it differes from the new state so the desired state is still tracked.
70+
// unchanged if it differs from the new state so the desired state is still tracked.
7171
// The Actual state is updated to the given status.
7272
//
7373
// This allows tracking both the desired and actual states, while clearing

cmd/metal-api/internal/service/integration_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func createTestEnvironment(t *testing.T) testEnv {
8585
psc.On("Find", testifymock.Anything, &mdmv1.ProjectFindRequest{}).Return(&mdmv1.ProjectListResponse{Projects: []*mdmv1.Project{
8686
{Meta: &mdmv1.Meta{Id: "test-project-1"}},
8787
}}, nil)
88-
mdc := mdm.NewMock(psc, nil, nil)
88+
mdc := mdm.NewMock(psc, nil, nil, nil)
8989

9090
go func() {
9191
err := metalgrpc.Run(&metalgrpc.ServerConfig{
@@ -397,11 +397,10 @@ func (te *testEnv) machineWait(uuid string) error {
397397
opts := []grpc.DialOption{
398398
grpc.WithKeepaliveParams(kacp),
399399
grpc.WithTransportCredentials(insecure.NewCredentials()),
400-
grpc.WithBlock(),
401400
}
402401

403402
port := 50005
404-
conn, err := grpc.DialContext(context.Background(), fmt.Sprintf("localhost:%d", port), opts...)
403+
conn, err := grpc.NewClient(fmt.Sprintf("localhost:%d", port), opts...)
405404
if err != nil {
406405
return err
407406
}

cmd/metal-api/internal/service/ip-service_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func TestAllocateIP(t *testing.T) {
182182
)
183183
tsc := mdmock.TenantServiceClient{}
184184

185-
mdc := mdm.NewMock(&psc, &tsc, nil)
185+
mdc := mdm.NewMock(&psc, &tsc, nil, nil)
186186

187187
ipservice, err := NewIP(logger, ds, bus.DirectEndpoints(), ipamer, mdc)
188188
require.NoError(t, err)

cmd/metal-api/internal/service/machine-service_allocation_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,8 @@ func TestMachineAllocationIntegration(t *testing.T) {
5656
grpc.WithTransportCredentials(insecure.NewCredentials()),
5757
}
5858

59-
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
60-
defer cancel()
61-
6259
port := 50006
63-
conn, err := grpc.DialContext(ctx, fmt.Sprintf("localhost:%d", port), opts...)
60+
conn, err := grpc.NewClient(fmt.Sprintf("localhost:%d", port), opts...)
6461
require.NoError(t, err)
6562

6663
c := grpcv1.NewBootServiceClient(conn)
@@ -304,7 +301,7 @@ func setupTestEnvironment(machineCount int, t *testing.T) (*datastore.RethinkSto
304301

305302
psc := &mdmv1mock.ProjectServiceClient{}
306303
psc.On("Get", testifymock.Anything, &mdmv1.ProjectGetRequest{Id: "pr1"}).Return(&mdmv1.ProjectResponse{Project: &mdmv1.Project{}}, nil)
307-
mdc := mdm.NewMock(psc, nil, nil)
304+
mdc := mdm.NewMock(psc, nil, nil, nil)
308305

309306
_, pg, err := test.StartPostgres()
310307
require.NoError(t, err)

cmd/metal-api/internal/service/machine-service_integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func TestMachineAllocationIntegrationFullCycle(t *testing.T) {
8181
defer cancel()
8282

8383
port := 50005
84-
conn, err := grpc.DialContext(ctx, fmt.Sprintf("localhost:%d", port), opts...)
84+
conn, err := grpc.NewClient(fmt.Sprintf("localhost:%d", port), opts...)
8585
require.NoError(t, err)
8686

8787
c := grpcv1.NewBootServiceClient(conn)

cmd/metal-api/internal/service/project-service_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func NewMockedProjectService(t *testing.T, projectServiceMock func(mock *mdmv1mo
4545
if projectServiceMock != nil {
4646
projectServiceMock(psc)
4747
}
48-
mdc := mdm.NewMock(psc, &mdmv1mock.TenantServiceClient{}, nil)
48+
mdc := mdm.NewMock(psc, &mdmv1mock.TenantServiceClient{}, nil, nil)
4949
ds, mock := datastore.InitMockDB(t)
5050
if dsmock != nil {
5151
dsmock(mock)

cmd/metal-api/internal/service/size-service_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func TestCreateSize(t *testing.T) {
177177
psc.On("Find", testifymock.Anything, &mdmv1.ProjectFindRequest{}).Return(&mdmv1.ProjectListResponse{Projects: []*mdmv1.Project{
178178
{Meta: &mdmv1.Meta{Id: "a"}},
179179
}}, nil)
180-
mdc := mdm.NewMock(psc, &mdmv1mock.TenantServiceClient{}, nil)
180+
mdc := mdm.NewMock(psc, &mdmv1mock.TenantServiceClient{}, nil, nil)
181181

182182
sizeservice := NewSize(log, ds, mdc)
183183
container := restful.NewContainer().Add(sizeservice)
@@ -243,7 +243,7 @@ func TestUpdateSize(t *testing.T) {
243243
psc.On("Find", testifymock.Anything, &mdmv1.ProjectFindRequest{}).Return(&mdmv1.ProjectListResponse{Projects: []*mdmv1.Project{
244244
{Meta: &mdmv1.Meta{Id: "p1"}},
245245
}}, nil)
246-
mdc := mdm.NewMock(psc, &mdmv1mock.TenantServiceClient{}, nil)
246+
mdc := mdm.NewMock(psc, &mdmv1mock.TenantServiceClient{}, nil, nil)
247247

248248
sizeservice := NewSize(log, ds, mdc)
249249
container := restful.NewContainer().Add(sizeservice)
@@ -301,7 +301,7 @@ func TestListSizeReservations(t *testing.T) {
301301
psc.On("Find", testifymock.Anything, &mdmv1.ProjectFindRequest{}).Return(&mdmv1.ProjectListResponse{Projects: []*mdmv1.Project{
302302
{Meta: &mdmv1.Meta{Id: "p1"}},
303303
}}, nil)
304-
mdc := mdm.NewMock(psc, &mdmv1mock.TenantServiceClient{}, nil)
304+
mdc := mdm.NewMock(psc, &mdmv1mock.TenantServiceClient{}, nil, nil)
305305

306306
sizeservice := NewSize(log, ds, mdc)
307307
container := restful.NewContainer().Add(sizeservice)

0 commit comments

Comments
 (0)