Skip to content

Commit

Permalink
fix: addressing the comments
Browse files Browse the repository at this point in the history
  • Loading branch information
behzad-mir committed Jan 3, 2025
1 parent 859f4e4 commit 46ed578
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions network/network_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const (
defaultIPv6NextHop = "fe80::1234:5678:9abc"
)

var errHcnNetworkCreate = errors.New("Failed to create hcn network ")

// Windows implementation of route.
type route interface{}

Expand Down Expand Up @@ -365,18 +367,19 @@ func (nm *networkManager) newNetworkImplHnsV2(nwInfo *EndpointInfo, extIf *exter
} else {
if strings.Contains(err.Error(), "already exists") {
// fetch the network name again since the parallel CNI Add call has created the HNS network
logger.Error("Failed to create hcn network.due to error:", zap.String("hnsResponse", hcnNetwork.Name), zap.String("hnsResponse", err.Error()))
hnsResponse, err = Hnsv2.GetNetworkByName(hcnNetwork.Name)
if err != nil {
return nil, fmt.Errorf("Failed to get hcn network: %s due to error: %v", hcnNetwork.Name, err)
return nil, fmt.Errorf("Failed to get hcn network: %s due to error %s: %v", hcnNetwork.Name, err.Error())

Check failure on line 373 in network/network_windows.go

View workflow job for this annotation

GitHub Actions / Lint (1.22.x, windows-latest)

do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf(\"Failed to get hcn network: %s due to error %s: %v\", hcnNetwork.Name, err.Error())" (err113)

Check failure on line 373 in network/network_windows.go

View workflow job for this annotation

GitHub Actions / Lint (1.23.x, windows-latest)

do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf(\"Failed to get hcn network: %s due to error %s: %v\", hcnNetwork.Name, err.Error())" (err113)
}
logger.Info("Successfully fetched hcn network with response", zap.Any("hnsResponse", hnsResponse))
logger.Info("Successfully fetched hcn network with response", zap.Any("hnsResponse", hnsResponse.Id))
} else {
return nil, fmt.Errorf("Failed to create hcn network: %s due to error: %v", hcnNetwork.Name, err)
return nil, fmt.Errorf("%w %s: %s", errHcnNetworkCreate, hcnNetwork.Name, err.Error())
}
}
} else {
// we can't validate if the network already exists, don't continue
return nil, fmt.Errorf("Failed to create hcn network: %s, failed to query for existing network with error: %v", hcnNetwork.Name, err)
return nil, fmt.Errorf("%w %s: %s", errHcnNetworkCreate, hcnNetwork.Name, err.Error())
}
} else {
if hcnNetwork.Type == hcn.Transparent {
Expand Down

0 comments on commit 46ed578

Please sign in to comment.