66 "regexp"
77 "time"
88
9+ "github.com/Azure/azure-container-networking/cni/log"
910 "github.com/pkg/errors"
1011 "go.uber.org/zap"
1112 "golang.org/x/sys/windows"
@@ -98,7 +99,7 @@ func (c *DHCP) DiscoverRequest(ctx context.Context, macAddress net.HardwareAddr,
9899 // delete dummy ip off the interface if it already exists
99100 ret , err := c .execClient .ExecuteCommand (ctx , "netsh" , "interface" , "ipv4" , "delete" , "address" , ifName , dummyIPAddressStr )
100101 if err != nil {
101- c .logger .Info ("Could not remove dummy ip, likely because it doesn't exist" , zap .String ("output" , ret ), zap .Error (err ))
102+ c .logger .Info ("Could not remove dummy ip, likely because it doesn't exist" , zap .String ("output" , ret ), zap .Error (log . NewErrorWithoutStackTrace ( err ) ))
102103 }
103104 time .Sleep (deleteIPAddressDelay )
104105
@@ -109,7 +110,9 @@ func (c *DHCP) DiscoverRequest(ctx context.Context, macAddress net.HardwareAddr,
109110 }
110111 // ensure we always remove the dummy ip we added from the interface
111112 defer func () {
112- ret , cleanupErr := c .execClient .ExecuteCommand (ctx , "netsh" , "interface" , "ipv4" , "delete" , "address" , ifName , dummyIPAddressStr )
113+ // we always want to try to remove the dummy ip, even if the deadline was reached
114+ // so we have context.Background()
115+ ret , cleanupErr := c .execClient .ExecuteCommand (context .Background (), "netsh" , "interface" , "ipv4" , "delete" , "address" , ifName , dummyIPAddressStr )
113116 if cleanupErr != nil {
114117 c .logger .Info ("Failed to remove dummy ip on leaving function" , zap .String ("output" , ret ), zap .Error (err ))
115118 }
0 commit comments