Skip to content

Commit b77aecd

Browse files
committed
address linter issues
1 parent 0e0414e commit b77aecd

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

dhcp/dhcp_windows.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,24 +87,24 @@ func (s *Socket) Close() error {
8787
func (c *DHCP) getIPv4InterfaceAddresses(ifName string) ([]net.IP, error) {
8888
nic, err := c.netioClient.GetNetworkInterfaceByName(ifName)
8989
if err != nil {
90-
return []net.IP{}, err
90+
return []net.IP{}, errors.Wrap(err, "failed to get interface by name to find ipv4 addresses")
9191
}
9292
addresses, err := c.netioClient.GetNetworkInterfaceAddrs(nic)
9393
if err != nil {
94-
return []net.IP{}, err
94+
return []net.IP{}, errors.Wrap(err, "failed to get interface addresses")
9595
}
9696
ret := []net.IP{}
9797
for _, address := range addresses {
9898
// check if the ip is ipv4 and parse it
99-
ip, _, err := net.ParseCIDR(address.String())
100-
if err != nil || ip.To4() == nil {
99+
ip, _, cidrErr := net.ParseCIDR(address.String())
100+
if cidrErr != nil || ip.To4() == nil {
101101
continue
102102
}
103103
ret = append(ret, ip)
104104
}
105105

106106
c.logger.Info("Interface addresses found", zap.Any("foundIPs", addresses), zap.Any("selectedIPs", ret))
107-
return ret, err
107+
return ret, nil
108108
}
109109

110110
func (c *DHCP) verifyIPv4InterfaceAddressCount(ifName string, count, maxRuns int, sleep time.Duration) error {
@@ -118,7 +118,7 @@ func (c *DHCP) verifyIPv4InterfaceAddressCount(ifName string, count, maxRuns int
118118
}
119119
return nil
120120
})
121-
return addressCountErr
121+
return errors.Wrap(addressCountErr, "failed to verify interface ipv4 address count")
122122
}
123123

124124
// issues a dhcp discover request on an interface by finding the secondary's ip and sending on its ip

network/network_windows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const (
4646
defaultIPv6Route = "::/0"
4747
// Default IPv6 nextHop
4848
defaultIPv6NextHop = "fe80::1234:5678:9abc"
49+
dhcpTimeout = 15 * time.Second
4950
)
5051

5152
// Windows implementation of route.
@@ -438,8 +439,7 @@ func (nm *networkManager) newNetworkImplHnsV2(nwInfo *EndpointInfo, extIf *exter
438439
func (nm *networkManager) sendDHCPDiscoverOnSecondary(client dhcpClient, mac net.HardwareAddr, ifName string) error {
439440
// issue dhcp discover packet to ensure mapping created for dns via wireserver to work
440441
// we do not use the response for anything
441-
timeout := 15 * time.Second
442-
ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(timeout))
442+
ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(dhcpTimeout))
443443
defer cancel()
444444
logger.Info("Sending DHCP packet", zap.Any("macAddress", mac), zap.String("ifName", ifName))
445445
err := client.DiscoverRequest(ctx, mac, ifName)

0 commit comments

Comments
 (0)