Skip to content

Commit 83f8896

Browse files
committed
add error logs
1 parent 292af71 commit 83f8896

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

cns/middlewares/k8sSwiftV2.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,42 +259,42 @@ func (k *K8sSWIFTv2Middleware) addRoutes(cidrs []string, gatewayIP string) []cns
259259
return routes
260260
}
261261

262-
func (k *K8sSWIFTv2Middleware) SetInfraRoutes() []cns.Route {
262+
func (k *K8sSWIFTv2Middleware) SetInfraRoutes() ([]cns.Route, error) {
263263
var routes []cns.Route
264264

265265
// Get and parse infraVNETCIDRs from env
266266
infraVNETCIDRs, err := configuration.InfraVNETCIDRs()
267267
if err != nil {
268-
return errors.Wrapf(err, "failed to get infraVNETCIDRs from env")
268+
return nil, errors.Wrapf(err, "failed to get infraVNETCIDRs from env")
269269
}
270270
infraVNETCIDRsv4, infraVNETCIDRsv6, err := utils.ParseCIDRs(infraVNETCIDRs)
271271
if err != nil {
272-
return errors.Wrapf(err, "failed to parse infraVNETCIDRs")
272+
return nil, errors.Wrapf(err, "failed to parse infraVNETCIDRs")
273273
}
274274

275275
// Get and parse podCIDRs from env
276276
podCIDRs, err := configuration.PodCIDRs()
277277
if err != nil {
278-
return errors.Wrapf(err, "failed to get podCIDRs from env")
278+
return nil, errors.Wrapf(err, "failed to get podCIDRs from env")
279279
}
280280
podCIDRsV4, podCIDRv6, err := utils.ParseCIDRs(podCIDRs)
281281
if err != nil {
282-
return errors.Wrapf(err, "failed to parse podCIDRs")
282+
return nil, errors.Wrapf(err, "failed to parse podCIDRs")
283283
}
284284

285285
// Get and parse serviceCIDRs from env
286286
serviceCIDRs, err := configuration.ServiceCIDRs()
287287
if err != nil {
288-
return errors.Wrapf(err, "failed to get serviceCIDRs from env")
288+
return nil, errors.Wrapf(err, "failed to get serviceCIDRs from env")
289289
}
290290
serviceCIDRsV4, serviceCIDRsV6, err := utils.ParseCIDRs(serviceCIDRs)
291291
if err != nil {
292-
return errors.Wrapf(err, "failed to parse serviceCIDRs")
292+
return nil, errors.Wrapf(err, "failed to parse serviceCIDRs")
293293
}
294294

295295
ip, err := netip.ParseAddr(podIPInfo.PodIPConfig.IPAddress)
296296
if err != nil {
297-
return errors.Wrapf(err, "failed to parse podIPConfig IP address %s", podIPInfo.PodIPConfig.IPAddress)
297+
return nil, errors.Wrapf(err, "failed to parse podIPConfig IP address %s", podIPInfo.PodIPConfig.IPAddress)
298298
}
299299

300300
if ip.Is4() {
@@ -307,5 +307,5 @@ func (k *K8sSWIFTv2Middleware) SetInfraRoutes() []cns.Route {
307307
routes = append(routes, k.addRoutes(infraVNETCIDRsv6, overlayGatewayV6)...)
308308
}
309309

310-
return routes
310+
return routes, nil
311311
}

cns/middlewares/k8sSwiftV2_linux.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/Azure/azure-container-networking/cns"
77
"github.com/Azure/azure-container-networking/cns/logger"
88
"github.com/Azure/azure-container-networking/crd/multitenancy/api/v1alpha1"
9+
"github.com/pkg/errors"
910
)
1011

1112
// setRoutes sets the routes for podIPInfo used in SWIFT V2 scenario.
@@ -26,7 +27,11 @@ func (k *K8sSWIFTv2Middleware) setRoutes(podIPInfo *cns.PodIpInfo) error {
2627
routes = append(routes, virtualGWRoute, route)
2728

2829
case cns.InfraNIC:
29-
routes = k.SetInfraRoutes()
30+
infraRoutes, err := k.SetInfraRoutes()
31+
if err != nil {
32+
return errors.Wrap("failed to set infra routes")
33+
}
34+
routes = append(routes, infraRoutes)
3035
podIPInfo.SkipDefaultRoutes = true
3136

3237
case cns.NodeNetworkInterfaceBackendNIC: //nolint:exhaustive // ignore exhaustive types check

cns/middlewares/k8sSwiftV2_windows.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ func (k *K8sSWIFTv2Middleware) setRoutes(podIPInfo *cns.PodIpInfo) error {
2323
podIPInfo.Routes = append(podIPInfo.Routes, route)
2424

2525
// add routes for infraNIC
26-
podIPInfo.Routes = append(podIPInfo.Routes, k.SetInfraRoutes())
26+
routes, err := k.SetInfraRoutes()
27+
if err != nil {
28+
return errors.Wrap("failed to set infra routes")
29+
}
30+
podIPInfo.Routes = append(podIPInfo.Routes, routes)
2731
podIPInfo.SkipDefaultRoutes = true
2832
}
2933
return nil

0 commit comments

Comments
 (0)