@@ -21,6 +21,11 @@ import (
2121 "go.uber.org/zap"
2222)
2323
24+ var (
25+ errHcnNetworkCreate = errors .New ("failed to create hcn network" )
26+ errHcnNetworkGet = errors .New ("failed to get hcn network" )
27+ )
28+
2429const (
2530 // HNS network types.
2631 hnsL2bridge = "l2bridge"
@@ -365,18 +370,19 @@ func (nm *networkManager) newNetworkImplHnsV2(nwInfo *EndpointInfo, extIf *exter
365370 } else {
366371 if strings .Contains (err .Error (), "already exists" ) {
367372 // fetch the network name again since the parallel CNI Add call has created the HNS network
373+ logger .Error ("Failed to create hcn network.due to error:" , zap .String ("hnsResponse" , hcnNetwork .Name ), zap .String ("hnsResponse" , err .Error ()))
368374 hnsResponse , err = Hnsv2 .GetNetworkByName (hcnNetwork .Name )
369375 if err != nil {
370- return nil , fmt .Errorf ("Failed to get hcn network : %s due to error: %v " , hcnNetwork .Name , err )
376+ return nil , fmt .Errorf ("%w : %s due to error %s " , errHcnNetworkGet , hcnNetwork .Name , err . Error () )
371377 }
372- logger .Info ("Successfully fetched hcn network with response" , zap .Any ("hnsResponse" , hnsResponse ))
378+ logger .Info ("Successfully fetched hcn network with response" , zap .Any ("hnsResponse" , hnsResponse . Id ))
373379 } else {
374- return nil , fmt .Errorf ("Failed to create hcn network : %s due to error: %v " , hcnNetwork .Name , err )
380+ return nil , fmt .Errorf ("%w : %s due to error %s " , errHcnNetworkCreate , hcnNetwork .Name , err . Error () )
375381 }
376382 }
377383 } else {
378384 // we can't validate if the network already exists, don't continue
379- return nil , fmt .Errorf ("Failed to create hcn network : %s, failed to query for existing network with error: %v " , hcnNetwork .Name , err )
385+ return nil , fmt .Errorf ("%w : %s due to error %s " , errHcnNetworkCreate , hcnNetwork .Name , err . Error () )
380386 }
381387 } else {
382388 if hcnNetwork .Type == hcn .Transparent {
0 commit comments