Skip to content

Commit

Permalink
finalze slog migration
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 committed Feb 7, 2024
1 parent 264fb05 commit 4940de1
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN8
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA=
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 h1:/RIbNt/Zr7rVhIkQhooTxCxFcdWLGIKnZA4IXNFSrvo=
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
Expand All @@ -93,8 +93,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe h1:bQnxqljG/wqi4NTXu2+DJ3n7APcEA882QZ1JvhQAq9o=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014 h1:FSL3lRCkhaPFxqi0s9o+V4UI2WTzAVOvkgbd4kVV4Wg=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014/go.mod h1:SaPjaZGWb0lPqs6Ittu0spdfrOArqji4ZdeP5IC/9N4=
google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0=
google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
Expand Down
2 changes: 1 addition & 1 deletion pixiecore/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func serverFromFlags(cmd *cobra.Command) *pixiecore.Server {

ret := &pixiecore.Server{
Ipxe: map[pixiecore.Firmware][]byte{},
Log: getLogger(debug),
Log: getLogger(debug).WithGroup("dhcp"),
HTTPPort: httpPort,
HTTPStatusPort: httpStatusPort,
MetricsPort: metricsPort,
Expand Down
2 changes: 1 addition & 1 deletion pixiecore/cli/ipv6apicmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var ipv6ApiCmd = &cobra.Command{
if err != nil {
fatalf("Error reading flag: %s", err)
}
s.Log = getLogger(debug)
s.Log = getLogger(debug).WithGroup("dhcpv6")

if addr == "" {
fatalf("Please specify address to bind to")
Expand Down
20 changes: 10 additions & 10 deletions pixiecore/dhcpv6.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,45 @@ import (
)

func (s *ServerV6) serveDHCP(conn *dhcp6.Conn) error {
s.Log.Debug("dhcpv6", "Waiting for packets...\n")
s.Log.Debug("waiting for packets...")
for {
pkt, src, err := conn.RecvDHCP()
if err != nil {
return fmt.Errorf("error receiving DHCP packet: %w", err)
}
if err := pkt.ShouldDiscard(s.Duid); err != nil {
s.Log.Debug("dhcpv6, discarding (%d) packet (%d): %s\n", pkt.Type, pkt.TransactionID, err))
s.Log.Debug("discarding packet", "type", pkt.Type, "packet", pkt.TransactionID, "error", err)
continue
}

s.Log.Debug("dhcpv6", fmt.Sprintf("Received (%d) packet (%d): %s\n", pkt.Type, pkt.TransactionID, pkt.Options.HumanReadable()))
s.Log.Debug("received packet", "type", pkt.Type, "packet", pkt.TransactionID, "options", pkt.Options.HumanReadable())

response, err := s.PacketBuilder.BuildResponse(pkt, s.Duid, s.BootConfig, s.AddressPool)
if err != nil {
s.Log.Info("dhcpv6", fmt.Sprintf("Error creating response for transaction: %d: %s", pkt.TransactionID, err))
s.Log.Info("error creating response for transaction", "transaction", pkt.TransactionID, "error", err)
if response == nil {
s.Log.Info("dhcpv6","dropping the packet")
s.Log.Info("dropping the packet")
continue
} else {
s.Log.Info("dhcpv6", "will notify the client")
s.Log.Info("will notify the client")
}
}
if response == nil {
s.Log.Info("dhcpv6", fmt.Sprintf("Don't know how to respond to packet type: %d (transaction id %d)", pkt.Type, pkt.TransactionID))
s.Log.Info("don't know how to respond to packet", "type", pkt.Type, "packet", pkt.TransactionID)
continue
}

marshalledResponse, err := response.Marshal()
if err != nil {
s.Log.Info("dhcpv6", fmt.Sprintf("Error marshalling response (%d) (%d): %s", response.Type, response.TransactionID, err))
s.Log.Error("error marshalling response", "type", response.Type, "packet", response.TransactionID, "error", err)
continue
}

if err := conn.SendDHCP(src, marshalledResponse); err != nil {
s.Log.Info("dhcpv6", fmt.Sprintf("Error sending reply (%d) (%d): %s", response.Type, response.TransactionID, err))
s.Log.Error("error sending reply", "type", response.Type, "packet", response.TransactionID, "error", err)
continue
}

s.Log.Debug("dhcpv6", fmt.Sprintf("Sent (%d) packet (%d): %s\n", response.Type, response.TransactionID, response.Options.HumanReadable()))
s.Log.Debug("sent packet", "type", response.Type, "packet", response.TransactionID, "options", response.Options.HumanReadable())
}
}
6 changes: 3 additions & 3 deletions pixiecore/pixicorev6.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ func NewServerV6() *ServerV6 {
// Serve listens for machines attempting to boot, and responds to
// their DHCPv6 requests.
func (s *ServerV6) Serve() error {
s.Log.Info("dhcp", "starting...")
s.Log.Info("starting...")

dhcp, err := dhcp6.NewConn(s.Address, s.Port)
if err != nil {
return err
}

s.Log.Debug("dhcp", "new connection...")
s.Log.Debug("new connection...")

// 5 buffer slots, one for each goroutine, plus one for
// Shutdown(). We only ever pull the first error out, but shutdown
Expand All @@ -59,7 +59,7 @@ func (s *ServerV6) Serve() error {
err = <-s.errs
dhcp.Close()

s.Log.Info("dhcp", "stopped...")
s.Log.Info("stopped...")
return err
}

Expand Down

0 comments on commit 4940de1

Please sign in to comment.