Skip to content

Commit 33e3145

Browse files
committed
fix naming and add fields for debugging
1 parent d478dcc commit 33e3145

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

network/networkutils/networkutils_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,14 @@ func (nu NetworkUtils) DisableRAForInterface(ifName string) error {
256256
raFilePath := fmt.Sprintf(acceptRAV6File, ifName)
257257
exist, err := platform.CheckIfFileExists(raFilePath)
258258
if !exist {
259-
logger.Error("accept_ra file doesn't exist with", zap.Error(err))
259+
logger.Error("accept_ra file doesn't exist with", zap.Error(err), zap.String("ifName", ifName))
260260
return nil
261261
}
262262

263263
cmd := fmt.Sprintf(disableRACmd, ifName)
264264
out, err := nu.plClient.ExecuteRawCommand(cmd)
265265
if err != nil {
266-
logger.Error("Diabling ra failed with", zap.Error(err), zap.Any("out", out))
266+
logger.Error("Diabling ra failed with", zap.Error(err), zap.Any("out", out), zap.String("ifName", ifName))
267267
}
268268

269269
return err

network/transparent_vlan_endpointclient_linux.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func NewTransparentVlanEndpointClient(
114114
func (client *TransparentVlanEndpointClient) AddEndpoints(epInfo *EndpointInfo) error {
115115
// VM Namespace
116116
if err := client.ensureCleanPopulateVM(); err != nil {
117-
return errors.Wrap(err, "failed to ensure both network namespace and vlan veth were present or both absent")
117+
return errors.Wrap(err, "failed to ensure both network namespace and vlan interface were present or both absent")
118118
}
119119
if err := client.PopulateVM(epInfo); err != nil {
120120
return err
@@ -131,7 +131,7 @@ func (client *TransparentVlanEndpointClient) AddEndpoints(epInfo *EndpointInfo)
131131
// Called from AddEndpoints, Namespace: VM and Vnet
132132
func (client *TransparentVlanEndpointClient) ensureCleanPopulateVM() error {
133133
// Clean up vlan interface in the VM namespace and ensure the network namespace (if it exists) has a vlan interface
134-
logger.Info("Checking if NS and vlan veth exists...")
134+
logger.Info("Checking if NS and vlan interface exists...")
135135
var existingErr error
136136
client.vnetNSFileDescriptor, existingErr = client.netnsClient.GetFromName(client.vnetNSName)
137137
if existingErr == nil {
@@ -146,7 +146,7 @@ func (client *TransparentVlanEndpointClient) ensureCleanPopulateVM() error {
146146
logger.Info("vlan interface doesn't exist even though network namespace exists, deleting network namespace...", zap.String("message", vlanIfErr.Error()))
147147
delErr := client.netnsClient.DeleteNamed(client.vnetNSName)
148148
if delErr != nil {
149-
return errors.Wrap(delErr, "failed to cleanup/delete ns after noticing vlan veth does not exist")
149+
return errors.Wrap(delErr, "failed to cleanup/delete ns after noticing vlan interface does not exist")
150150
}
151151
}
152152
}
@@ -215,7 +215,7 @@ func (client *TransparentVlanEndpointClient) PopulateVM(epInfo *EndpointInfo) er
215215
var existingErr error
216216
client.vnetNSFileDescriptor, existingErr = client.netnsClient.GetFromName(client.vnetNSName)
217217
// If the ns does not exist, the below code will trigger to create it
218-
// This will also (we assume) mean the vlan veth does not exist
218+
// This will also (we assume) mean the vlan interface does not exist
219219
if existingErr != nil {
220220
// We assume the only possible error is that the namespace doesn't exist
221221
logger.Info("No existing NS detected. Creating the vnet namespace and switching to it", zap.String("message", existingErr.Error()))
@@ -234,15 +234,15 @@ func (client *TransparentVlanEndpointClient) PopulateVM(epInfo *EndpointInfo) er
234234
logger.Info("[transparent vlan] removing vnet ns due to failure...")
235235
err = client.netnsClient.DeleteNamed(client.vnetNSName)
236236
if err != nil {
237-
logger.Error("failed to cleanup/delete ns after failing to create vlan veth")
237+
logger.Error("failed to cleanup/delete ns after failing to create vlan interface")
238238
}
239239
}
240240
}()
241241
if deleteNSIfNotNilErr != nil {
242242
return errors.Wrap(deleteNSIfNotNilErr, "failed to set current ns to vm")
243243
}
244244

245-
// Now create vlan veth
245+
// Now create vlan interface
246246
logger.Info("Create the host vlan link after getting eth0", zap.String("primaryHostIfName", client.primaryHostIfName))
247247
// Get parent interface index. Index is consistent across libraries.
248248
eth0, deleteNSIfNotNilErr := client.netioshim.GetNetworkInterfaceByName(client.primaryHostIfName)
@@ -258,7 +258,7 @@ func (client *TransparentVlanEndpointClient) PopulateVM(epInfo *EndpointInfo) er
258258
VlanId: client.vlanID,
259259
}
260260
logger.Info("Attempting to create link in VM NS", zap.String("vlanIfName", client.vlanIfName))
261-
// Create vlan veth
261+
// Create vlan interface
262262
deleteNSIfNotNilErr = vishnetlink.LinkAdd(link)
263263
if deleteNSIfNotNilErr != nil {
264264
// ignore link already exists error
@@ -271,35 +271,35 @@ func (client *TransparentVlanEndpointClient) PopulateVM(epInfo *EndpointInfo) er
271271
}
272272
defer func() {
273273
if deleteNSIfNotNilErr != nil {
274-
logger.Info("removing vlan veth due to failure...")
274+
logger.Info("removing vlan interface due to failure...")
275275
if delErr := client.netlink.DeleteLink(client.vlanIfName); delErr != nil {
276-
logger.Error("deleting vlan veth failed on addendpoint failure with", zap.Any("error:", delErr.Error()))
276+
logger.Error("deleting vlan interface failed on addendpoint failure with", zap.Any("error:", delErr.Error()))
277277
}
278278
}
279279
}()
280280

281281
// sometimes there is slight delay in interface creation. check if it exists
282282
err = RunWithRetries(func() error {
283283
_, err = client.netioshim.GetNetworkInterfaceByName(client.vlanIfName)
284-
return errors.Wrap(err, "failed to get vlan veth")
284+
return errors.Wrap(err, "failed to get vlan interface")
285285
}, numRetries, sleepInMs)
286286

287287
if err != nil {
288-
deleteNSIfNotNilErr = errors.Wrapf(err, "failed to get vlan veth interface:%s", client.vlanIfName)
288+
deleteNSIfNotNilErr = errors.Wrapf(err, "failed to get vlan interface interface:%s", client.vlanIfName)
289289
return deleteNSIfNotNilErr
290290
}
291291

292292
deleteNSIfNotNilErr = client.netUtilsClient.DisableRAForInterface(client.vlanIfName)
293293
if deleteNSIfNotNilErr != nil {
294294
return errors.Wrap(deleteNSIfNotNilErr, "failed to disable router advertisements for vlan vnet link")
295295
}
296-
// vlan veth was created successfully, so move the vlan veth you created
296+
// vlan interface was created successfully, so move the vlan interface you created
297297
logger.Info("Move vlan link to vnet NS", zap.String("vlanIfName", client.vlanIfName), zap.Any("vnetNSFileDescriptor", uintptr(client.vnetNSFileDescriptor)))
298298
deleteNSIfNotNilErr = client.setLinkNetNSAndConfirm(client.vlanIfName, uintptr(client.vnetNSFileDescriptor), client.vnetNSName)
299299
if deleteNSIfNotNilErr != nil {
300-
return errors.Wrap(deleteNSIfNotNilErr, "failed to move or detect vlan veth inside vnet namespace")
300+
return errors.Wrap(deleteNSIfNotNilErr, "failed to move or detect vlan interface inside vnet namespace")
301301
}
302-
logger.Info("Moving vlan veth into namespace confirmed")
302+
logger.Info("Moving vlan interface into namespace confirmed")
303303
} else {
304304
logger.Info("Existing NS detected. vlan interface should exist or namespace would've been deleted.", zap.String("vnetNSName", client.vnetNSName), zap.String("vlanIfName", client.vlanIfName))
305305
}
@@ -373,7 +373,7 @@ func (client *TransparentVlanEndpointClient) PopulateVM(epInfo *EndpointInfo) er
373373
func (client *TransparentVlanEndpointClient) PopulateVnet(epInfo *EndpointInfo) error {
374374
_, err := client.netioshim.GetNetworkInterfaceByName(client.vlanIfName)
375375
if err != nil {
376-
return errors.Wrap(err, "vlan veth doesn't exist")
376+
return errors.Wrap(err, "vlan interface doesn't exist")
377377
}
378378
vnetVethIf, err := client.netioshim.GetNetworkInterfaceByName(client.vnetVethName)
379379
if err != nil {
@@ -669,7 +669,7 @@ func (client *TransparentVlanEndpointClient) DeleteEndpointsImpl(ep *endpoint, _
669669
// TODO: revist if this require in future.
670670
//nolint gocritic
671671
/* if routesLeft <= numDefaultRoutes {
672-
// Deletes default arp, default routes, vlan veth; there are two default routes
672+
// Deletes default arp, default routes, vlan interface; there are two default routes
673673
// so when we have <= numDefaultRoutes routes left, no containers use this namespace
674674
log.Printf("[transparent vlan] Deleting namespace %s as no containers occupy it", client.vnetNSName)
675675
delErr := client.netnsClient.DeleteNamed(client.vnetNSName)

0 commit comments

Comments
 (0)