Skip to content

Commit ac4f51c

Browse files
committed
address feedback
1 parent 8a56efb commit ac4f51c

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

cni/network/network.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ func NewPlugin(name string,
132132

133133
nl := netlink.NewNetlink()
134134
plc := platform.NewExecClient(logger)
135-
netio := &netio.NetIO{}
135+
nio := &netio.NetIO{}
136136
// Setup network manager.
137-
nm, err := network.NewNetworkManager(nl, plc, netio, network.NewNamespaceClient(), iptables.NewClient(), dhcp.New(logger, netio))
137+
nm, err := network.NewNetworkManager(nl, plc, nio, network.NewNamespaceClient(), iptables.NewClient(), dhcp.New(logger, nio))
138138
if err != nil {
139139
return nil, err
140140
}
@@ -146,7 +146,7 @@ func NewPlugin(name string,
146146
nm: nm,
147147
nnsClient: client,
148148
multitenancyClient: multitenancyClient,
149-
netClient: netio,
149+
netClient: nio,
150150
}, nil
151151
}
152152

dhcp/dhcp_windows.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ const (
1717
socketTimeoutMillis = 1000
1818
)
1919

20+
var (
21+
errInvalidIPv4Address = errors.New("invalid ipv4 address")
22+
errIncorrectAddressCount = errors.New("address count found not equal to expected")
23+
)
24+
2025
type Socket struct {
2126
fd windows.Handle
2227
destAddr windows.SockaddrInet4
@@ -105,7 +110,7 @@ func (c *DHCP) verifyIPv4InterfaceAddressCount(ifName string, count, maxRuns, sl
105110
addressCountErr := retry.Do(func() error {
106111
addresses, err := c.getIPv4InterfaceAddresses(ifName)
107112
if err != nil || len(addresses) != count {
108-
return errors.New("address count found not equal to expected")
113+
return errIncorrectAddressCount
109114
}
110115
return nil
111116
}, maxRuns, sleepMs)
@@ -125,7 +130,7 @@ func (c *DHCP) DiscoverRequest(ctx context.Context, macAddress net.HardwareAddr,
125130
}
126131
uniqueAddress := ipv4Addresses[0].To4()
127132
if uniqueAddress == nil {
128-
return errors.New("invalid ipv4 address")
133+
return errInvalidIPv4Address
129134
}
130135
uniqueAddressStr := uniqueAddress.String()
131136
c.logger.Info("Retrieved automatic ip configuration: ", zap.Any("ip", uniqueAddress), zap.String("ipStr", uniqueAddressStr))

network/network_windows.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,7 @@ func (nm *networkManager) newNetworkImplHnsV2(nwInfo *EndpointInfo, extIf *exter
438438
func (nm *networkManager) sendDHCPDiscoverOnSecondary(client dhcpClient, mac net.HardwareAddr, ifName string) error {
439439
// issue dhcp discover packet to ensure mapping created for dns via wireserver to work
440440
// we do not use the response for anything
441-
numSecs := 15 // we need to wait for the address to be assigned
442-
timeout := time.Duration(numSecs) * time.Second
441+
timeout := 15 * time.Second
443442
ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(timeout))
444443
defer cancel()
445444
logger.Info("Sending DHCP packet", zap.Any("macAddress", mac), zap.String("ifName", ifName))

0 commit comments

Comments
 (0)