Skip to content

Commit

Permalink
Update to new grpc client creation logic (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 authored May 31, 2024
1 parent 54d199c commit f019a81
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 95 deletions.
2 changes: 1 addition & 1 deletion cmd/image/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func TestCheckMD5(t *testing.T) {
testfile := "/tmp/testmd5"
testfileMD5 := "/tmp/testmd5.md5"
content := []byte("This is testcontent")
err := os.WriteFile(testfile, content, os.ModePerm)
err := os.WriteFile(testfile, content, os.ModePerm) // nolint:gosec
if err != nil {
t.Error(err)
}
Expand Down
7 changes: 1 addition & 6 deletions cmd/metal-client.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cmd

import (
"context"
"crypto/tls"
"crypto/x509"
"errors"
Expand Down Expand Up @@ -53,13 +52,9 @@ func NewMetalAPIClient(log *slog.Logger, spec *Specification) (*MetalAPIClient,
grpcOpts := []grpc.DialOption{
grpc.WithKeepaliveParams(kacp),
grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)),
grpc.WithBlock(),
}

ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()

conn, err := grpc.DialContext(ctx, metalConfig.GRPCAddress, grpcOpts...)
conn, err := grpc.NewClient(metalConfig.GRPCAddress, grpcOpts...)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/network/ethtool.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (e *Ethtool) stopFirmwareLLDP() {
if !info.IsDir() && info.Name() == "command" {
e.log.Info("ethtool", "stopFirmwareLLDP found command", path)
stopCommand := []byte("lldp stop")
err := os.WriteFile(path, stopCommand, os.ModePerm)
err := os.WriteFile(path, stopCommand, os.ModePerm) // nolint:gosec
if err != nil {
e.log.Error("ethtool", "stopFirmwareLLDP stop lldp > command", path, "error", err)
}
Expand Down
11 changes: 5 additions & 6 deletions cmd/register/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,11 @@ func (r *Register) readHardwareDetails() (*v1.BootServiceRegisterRequest, error)
}

hardware := &v1.MachineHardware{
Memory: uint64(memory.TotalPhysicalBytes),
CpuCores: uint32(cpu.TotalCores),
Nics: nics,
Disks: disks,
Cpus: metalCPUs,
Gpus: metalGPUs,
Memory: uint64(memory.TotalPhysicalBytes),
Nics: nics,
Disks: disks,
Cpus: metalCPUs,
Gpus: metalGPUs,
}

// IPMI
Expand Down
3 changes: 1 addition & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func Run(log *slog.Logger, spec *Specification, hal hal.InBand) (*event.EventEmi
EventEmitter: eventEmitter,
ChrootPrefix: "/rootfs",
OsImageDestination: "/tmp/os.tgz",
MetalAPIClient: metalAPIClient,
}

// Reboot after 24Hours if no allocation was requested.
Expand Down Expand Up @@ -139,7 +138,7 @@ func Run(log *slog.Logger, spec *Specification, hal hal.InBand) (*event.EventEmi
return eventEmitter, err
}

err = hammer.MetalAPIClient.WaitForAllocation(eventEmitter, spec.MachineUUID)
err = metalAPIClient.WaitForAllocation(eventEmitter, spec.MachineUUID)
if err != nil {
return eventEmitter, fmt.Errorf("wait for installation %w", err)
}
Expand Down
40 changes: 21 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ module github.com/metal-stack/metal-hammer
go 1.22

require (
github.com/beevik/ntp v1.4.1
github.com/beevik/ntp v1.4.3
github.com/cheggaaa/pb/v3 v3.1.5
github.com/google/gopacket v1.1.19
github.com/google/uuid v1.6.0
github.com/grafana/loki-client-go v0.0.0-20230116142646-e7494d0ef70c
github.com/jaypipes/ghw v0.12.0
github.com/metal-stack/go-hal v0.5.3
github.com/metal-stack/go-lldpd v0.4.7
github.com/metal-stack/metal-api v0.29.0
github.com/metal-stack/metal-go v0.29.0
github.com/metal-stack/metal-api v0.31.0
github.com/metal-stack/metal-go v0.31.0
github.com/metal-stack/pixie v0.3.2
github.com/metal-stack/v v1.0.3
// archiver must stay in version v2.1.0, see replace below
Expand All @@ -21,12 +21,12 @@ require (
github.com/pierrec/lz4/v4 v4.1.21
github.com/prometheus/common v0.53.0
github.com/samber/slog-loki/v3 v3.3.0
github.com/samber/slog-multi v1.0.2
github.com/samber/slog-multi v1.0.3
github.com/u-root/u-root v0.14.0
github.com/vishvananda/netlink v1.2.1-beta.2
golang.org/x/sync v0.7.0
golang.org/x/sys v0.20.0
google.golang.org/grpc v1.63.2
google.golang.org/grpc v1.64.0
google.golang.org/protobuf v1.34.1
gopkg.in/yaml.v3 v3.0.1
)
Expand All @@ -50,15 +50,15 @@ require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/dennwc/varint v1.0.0 // indirect
github.com/dsnet/compress v0.0.1 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/frankban/quicktest v1.14.6 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/gliderlabs/ssh v0.3.7 // indirect
github.com/go-jose/go-jose/v4 v4.0.1 // indirect
github.com/go-jose/go-jose/v4 v4.0.2 // indirect
github.com/go-kit/kit v0.13.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-openapi/analysis v0.23.0 // indirect
Expand All @@ -71,12 +71,14 @@ require (
github.com/go-openapi/strfmt v0.23.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-openapi/validate v0.24.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd // indirect
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/jaypipes/pcidb v1.0.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
Expand Down Expand Up @@ -105,31 +107,31 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/procfs v0.14.0 // indirect
github.com/prometheus/prometheus v0.51.2 // indirect
github.com/prometheus/procfs v0.15.0 // indirect
github.com/prometheus/prometheus v0.52.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/samber/lo v1.39.0 // indirect
github.com/samber/slog-common v0.16.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/sethvargo/go-password v0.3.0 // indirect
github.com/stmcginnis/gofish v0.17.0 // indirect
github.com/stmcginnis/gofish v0.18.0 // indirect
github.com/u-root/uio v0.0.0-20240224005618-d2acac8f3701 // indirect
github.com/ulikunitz/xz v0.5.12 // indirect
github.com/vishvananda/netns v0.0.4 // indirect
github.com/vmware/goipmi v0.0.0-20181114221114-2333cd82d702 // indirect
go.mongodb.org/mongo-driver v1.15.0 // indirect
go.opentelemetry.io/otel v1.26.0 // indirect
go.opentelemetry.io/otel/metric v1.26.0 // indirect
go.opentelemetry.io/otel/trace v1.26.0 // indirect
go.opentelemetry.io/otel v1.27.0 // indirect
go.opentelemetry.io/otel/metric v1.27.0 // indirect
go.opentelemetry.io/otel/trace v1.27.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/exp v0.0.0-20240529005216-23cca8864a10 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240506185236-b8a5c65736ae // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
howett.net/plist v1.0.1 // indirect
)
Loading

0 comments on commit f019a81

Please sign in to comment.