@@ -16,6 +16,7 @@ const (
1616 dummySubnetMask = "255.255.128.0"
1717 addIPAddressDelay = 4 * time .Second
1818 deleteIPAddressDelay = 2 * time .Second
19+ returnDelay = 8 * time .Second // time to wait before returning from DiscoverRequest
1920
2021 socketTimeoutMillis = 1000
2122)
@@ -97,7 +98,7 @@ func (c *DHCP) DiscoverRequest(ctx context.Context, macAddress net.HardwareAddr,
9798 // delete dummy ip off the interface if it already exists
9899 ret , err := c .execClient .ExecuteCommand (ctx , "netsh" , "interface" , "ipv4" , "delete" , "address" , ifName , dummyIPAddressStr )
99100 if err != nil {
100- c .logger .Info ("Could not remove dummy ip" , zap .String ("output" , ret ), zap .Error (err ))
101+ c .logger .Info ("Could not remove dummy ip, likely because it doesn't exist " , zap .String ("output" , ret ), zap .Error (err ))
101102 }
102103 time .Sleep (deleteIPAddressDelay )
103104
@@ -110,8 +111,10 @@ func (c *DHCP) DiscoverRequest(ctx context.Context, macAddress net.HardwareAddr,
110111 defer func () {
111112 ret , cleanupErr := c .execClient .ExecuteCommand (ctx , "netsh" , "interface" , "ipv4" , "delete" , "address" , ifName , dummyIPAddressStr )
112113 if cleanupErr != nil {
113- c .logger .Info ("Could not remove dummy ip on leaving function" , zap .String ("output" , ret ), zap .Error (err ))
114+ c .logger .Info ("Failed to remove dummy ip on leaving function" , zap .String ("output" , ret ), zap .Error (err ))
114115 }
116+ // wait for nic to retrieve autoconfiguration ip
117+ time .Sleep (returnDelay )
115118 }()
116119 // it takes time for the address to be assigned
117120 time .Sleep (addIPAddressDelay )
0 commit comments