Skip to content

Commit 46ed578

Browse files
committed
fix: addressing the comments
1 parent 859f4e4 commit 46ed578

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

network/network_windows.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ const (
4545
defaultIPv6NextHop = "fe80::1234:5678:9abc"
4646
)
4747

48+
var errHcnNetworkCreate = errors.New("Failed to create hcn network ")
49+
4850
// Windows implementation of route.
4951
type route interface{}
5052

@@ -365,18 +367,19 @@ func (nm *networkManager) newNetworkImplHnsV2(nwInfo *EndpointInfo, extIf *exter
365367
} else {
366368
if strings.Contains(err.Error(), "already exists") {
367369
// fetch the network name again since the parallel CNI Add call has created the HNS network
370+
logger.Error("Failed to create hcn network.due to error:", zap.String("hnsResponse", hcnNetwork.Name), zap.String("hnsResponse", err.Error()))
368371
hnsResponse, err = Hnsv2.GetNetworkByName(hcnNetwork.Name)
369372
if err != nil {
370-
return nil, fmt.Errorf("Failed to get hcn network: %s due to error: %v", hcnNetwork.Name, err)
373+
return nil, fmt.Errorf("Failed to get hcn network: %s due to error %s: %v", hcnNetwork.Name, err.Error())
371374
}
372-
logger.Info("Successfully fetched hcn network with response", zap.Any("hnsResponse", hnsResponse))
375+
logger.Info("Successfully fetched hcn network with response", zap.Any("hnsResponse", hnsResponse.Id))
373376
} else {
374-
return nil, fmt.Errorf("Failed to create hcn network: %s due to error: %v", hcnNetwork.Name, err)
377+
return nil, fmt.Errorf("%w %s: %s", errHcnNetworkCreate, hcnNetwork.Name, err.Error())
375378
}
376379
}
377380
} else {
378381
// 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)
382+
return nil, fmt.Errorf("%w %s: %s", errHcnNetworkCreate, hcnNetwork.Name, err.Error())
380383
}
381384
} else {
382385
if hcnNetwork.Type == hcn.Transparent {

0 commit comments

Comments
 (0)