Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cni/network/invoker_cns.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ func (invoker *CNSIPAMInvoker) Add(addConfig IPAMAddConfig) (IPAMAddResult, erro
PodNamespace: invoker.podNamespace,
}

logger.Info(podInfo.PodName)
orchestratorContext, err := json.Marshal(podInfo)
if err != nil {
logger.Info(podInfo.PodName)
return IPAMAddResult{}, errors.Wrap(err, "Failed to unmarshal orchestrator context during add: %w")
}

Expand Down
10 changes: 1 addition & 9 deletions cni/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -980,9 +980,6 @@ func (plugin *NetPlugin) Delete(args *cniSkel.CmdArgs) error {

logger.Info("Execution mode", zap.String("mode", nwCfg.ExecutionMode))
if nwCfg.ExecutionMode == string(util.Baremetal) {

logger.Info("Baremetal mode. Calling vnet agent for delete container")

// schedule send metric before attempting delete
defer sendMetricFunc()
_, err = plugin.nnsClient.DeleteContainerNetworking(context.Background(), k8sPodName, args.Netns)
Expand Down Expand Up @@ -1254,16 +1251,12 @@ func (plugin *NetPlugin) Update(args *cniSkel.CmdArgs) error {
targetEpInfo := &network.EndpointInfo{}

// get the target routes that should replace existingEpInfo.Routes inside the network namespace
logger.Info("Going to collect target routes for from targetNetworkConfig",
zap.String("pod", k8sPodName),
zap.String("namespace", k8sNamespace))
if targetNetworkConfig.Routes != nil && len(targetNetworkConfig.Routes) > 0 {
for _, route := range targetNetworkConfig.Routes {
logger.Info("Adding route from routes to targetEpInfo", zap.Any("route", route))
logger.Info("Adding route from routes from targetNetworkConfig to targetEpInfo", zap.Any("route", route))
_, dstIPNet, _ := net.ParseCIDR(route.IPAddress)
gwIP := net.ParseIP(route.GatewayIPAddress)
targetEpInfo.Routes = append(targetEpInfo.Routes, network.RouteInfo{Dst: *dstIPNet, Gw: gwIP, DevName: existingEpInfo.IfName})
logger.Info("Successfully added route from routes to targetEpInfo", zap.Any("route", route))
}
}

Expand All @@ -1278,7 +1271,6 @@ func (plugin *NetPlugin) Update(args *cniSkel.CmdArgs) error {
gwIP := net.ParseIP(ipconfig.GatewayIPAddress)
route := network.RouteInfo{Dst: dstIPNet, Gw: gwIP, DevName: existingEpInfo.IfName}
targetEpInfo.Routes = append(targetEpInfo.Routes, route)
logger.Info("Successfully added route from cnetAddressspace to targetEpInfo", zap.Any("subnet", ipRouteSubnet))
}

logger.Info("Finished collecting new routes in targetEpInfo", zap.Any("route", targetEpInfo.Routes))
Expand Down
17 changes: 6 additions & 11 deletions network/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,48 +309,43 @@ func (ep *endpoint) detach() error {
}

// updateEndpoint updates an existing endpoint in the network.
func (nm *networkManager) updateEndpoint(nw *network, exsitingEpInfo *EndpointInfo, targetEpInfo *EndpointInfo) error {
func (nm *networkManager) updateEndpoint(nw *network, existingEpInfo, targetEpInfo *EndpointInfo) error {
var err error

logger.Info("Updating existing endpoint in network to target", zap.Any("exsitingEpInfo", exsitingEpInfo),
logger.Info("Updating existing endpoint in network to target", zap.Any("existingEpInfo", existingEpInfo),
zap.String("id", nw.Id), zap.Any("targetEpInfo", targetEpInfo))
defer func() {
if err != nil {
logger.Error("Failed to update endpoint with err", zap.String("id", exsitingEpInfo.Id), zap.Error(err))
logger.Error("Failed to update endpoint with err", zap.String("id", existingEpInfo.Id), zap.Error(err))
}
}()

logger.Info("Trying to retrieve endpoint id", zap.String("id", exsitingEpInfo.Id))

ep := nw.Endpoints[exsitingEpInfo.Id]
ep := nw.Endpoints[existingEpInfo.Id]
if ep == nil {
return errEndpointNotFound
}

logger.Info("Retrieved endpoint to update", zap.Any("ep", ep))

// Call the platform implementation.
ep, err = nm.updateEndpointImpl(nw, exsitingEpInfo, targetEpInfo)
ep, err = nm.updateEndpointImpl(nw, existingEpInfo, targetEpInfo)
if err != nil {
return err
}

// Update routes for existing endpoint
nw.Endpoints[exsitingEpInfo.Id].Routes = ep.Routes
nw.Endpoints[existingEpInfo.Id].Routes = ep.Routes

return nil
}

func GetPodNameWithoutSuffix(podName string) string {
nameSplit := strings.Split(podName, "-")
logger.Info("namesplit", zap.Any("nameSplit", nameSplit))
if len(nameSplit) > 2 {
nameSplit = nameSplit[:len(nameSplit)-2]
} else {
return podName
}

logger.Info("Pod name after splitting based on", zap.Any("nameSplit", nameSplit))
return strings.Join(nameSplit, "-")
}

Expand Down
7 changes: 2 additions & 5 deletions network/endpoint_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,9 @@ func (nw *network) newEndpointImpl(

if epInfo.IPV6Mode != "" {
// Enable ipv6 setting in container
logger.Info("Enable ipv6 setting in container.")
nuc := networkutils.NewNetworkUtils(nl, plc)
if epErr := nuc.UpdateIPV6Setting(0); epErr != nil {
return fmt.Errorf("Enable ipv6 in container failed:%w", epErr)
return fmt.Errorf("enable ipv6 in container failed:%w", epErr)
}
}

Expand Down Expand Up @@ -270,7 +269,6 @@ func (nw *network) deleteEndpointImpl(nl netlink.NetlinkInterface, plc platform.
if ep.VlanID != 0 {
epInfo := ep.getInfo()
if nw.Mode == opModeTransparentVlan {
logger.Info("Transparent vlan client")
epClient = NewTransparentVlanEndpointClient(nw, epInfo, ep.HostIfName, "", ep.VlanID, ep.LocalIP, nl, plc, nsc, iptc)

} else {
Expand Down Expand Up @@ -462,7 +460,7 @@ func (nm *networkManager) updateRoutes(existingEp *EndpointInfo, targetEp *Endpo
// we do not support enable/disable snat for now
defaultDst := net.ParseIP("0.0.0.0")

logger.Info("Going to collect routes and skip default and infravnet routes if applicable.")
// collect routes and skip default and infravnet routes if applicable
logger.Info("Key for default route", zap.String("route", defaultDst.String()))

infraVnetKey := ""
Expand All @@ -476,7 +474,6 @@ func (nm *networkManager) updateRoutes(existingEp *EndpointInfo, targetEp *Endpo
logger.Info("Key for route to infra vnet", zap.String("infraVnetKey", infraVnetKey))
for _, route := range existingEp.Routes {
destination := route.Dst.IP.String()
logger.Info("Checking destination as to skip or not", zap.String("destination", destination))
isDefaultRoute := destination == defaultDst.String()
isInfraVnetRoute := targetEp.EnableInfraVnet && (destination == infraVnetKey)
if !isDefaultRoute && !isInfraVnetRoute {
Expand Down
26 changes: 8 additions & 18 deletions network/network_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,13 @@ func (nm *networkManager) newNetworkImpl(nwInfo *NetworkInfo, extIf *externalInt
if err := nu.EnableIPV4Forwarding(); err != nil {
return nil, errors.Wrap(err, "ipv4 forwarding failed")
}
logger.Info("Ipv4 forwarding enabled")
if err := nu.UpdateIPV6Setting(1); err != nil {
return nil, errors.Wrap(err, "failed to disable ipv6 on vm")
}
logger.Info("Disabled ipv6")
// Blocks wireserver traffic from apipa nic
if err := nu.BlockEgressTrafficFromContainer(nm.iptablesClient, iptables.V4, networkutils.AzureDNS, iptables.TCP, iptables.HTTPPort); err != nil {
return nil, errors.Wrap(err, "unable to insert vm iptables rule drop wireserver packets")
}
logger.Info("Block wireserver traffic rule added")
default:
return nil, errNetworkModeInvalid
}
Expand Down Expand Up @@ -469,7 +466,6 @@ func (nm *networkManager) connectExternalInterface(extIf *externalInterface, nwI
networkClient NetworkClient
)

logger.Info("Connecting interface", zap.String("Name", extIf.Name))
defer func() {
logger.Info("Connecting interface completed", zap.String("Name", extIf.Name), zap.Error(err))
}()
Expand Down Expand Up @@ -548,37 +544,35 @@ func (nm *networkManager) connectExternalInterface(extIf *externalInterface, nwI
}
}

logger.Info("Modifying interfaces", zap.String("Name", hostIf.Name))

// External interface down.
logger.Info("Setting link state down", zap.String("Name", hostIf.Name))
err = nm.netlink.SetLinkState(hostIf.Name, false)
if err != nil {
return err
return errors.Wrap(err, "failed to set external interface down")
}

// Connect the external interface to the bridge.
logger.Info("Setting link master", zap.String("Name", hostIf.Name), zap.String("bridgeName", bridgeName))
if err = networkClient.SetBridgeMasterToHostInterface(); err != nil {
return err
return errors.Wrap(err, "failed to connect external interface to bridge")
}

// External interface up.
logger.Info("Setting link state up", zap.String("Name", hostIf.Name))
err = nm.netlink.SetLinkState(hostIf.Name, true)
if err != nil {
return err
return errors.Wrap(err, "failed to set external interface up")
}

// Bridge up.
logger.Info("Setting link state up", zap.String("bridgeName", bridgeName))
err = nm.netlink.SetLinkState(bridgeName, true)
if err != nil {
return err
return errors.Wrap(err, "failed to set bridge link state up")
}

// Add the bridge rules.
err = networkClient.AddL2Rules(extIf)
if err != nil {
return err
return errors.Wrap(err, "failed to add bridge rules")
}

// External interface hairpin on.
Expand All @@ -597,8 +591,6 @@ func (nm *networkManager) connectExternalInterface(extIf *externalInterface, nwI
}

if isGreaterOrEqualUbuntu17 && isSystemdResolvedActive {
logger.Info("Applying dns config on", zap.String("bridgeName", bridgeName))

if err = nm.applyDNSConfig(extIf, bridgeName); err != nil {
logger.Error("Failed to apply DNS configuration with", zap.Error(err))
return err
Expand Down Expand Up @@ -635,9 +627,7 @@ func (nm *networkManager) connectExternalInterface(extIf *externalInterface, nwI

// DisconnectExternalInterface disconnects a host interface from its bridge.
func (nm *networkManager) disconnectExternalInterface(extIf *externalInterface, networkClient NetworkClient) {
logger.Info("Disconnecting interface", zap.String("Name", extIf.Name))

logger.Info("Deleting bridge rules")
logger.Info("Disconnecting interface and deleting bridge rules", zap.String("Name", extIf.Name))
// Delete bridge rules set on the external interface.
networkClient.DeleteL2Rules(extIf)

Expand Down
3 changes: 0 additions & 3 deletions network/networkutils/networkutils_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func (nu NetworkUtils) CreateEndpoint(hostVethName, containerVethName string, ma
return newErrorNetworkUtils(err.Error())
}

logger.Info("Setting link state up", zap.String("hostVethName", hostVethName))
err = nu.netlink.SetLinkState(hostVethName, true)
if err != nil {
return newErrorNetworkUtils(err.Error())
Expand All @@ -97,7 +96,6 @@ func (nu NetworkUtils) CreateEndpoint(hostVethName, containerVethName string, ma

func (nu NetworkUtils) SetupContainerInterface(containerVethName, targetIfName string) error {
// Interface needs to be down before renaming.
logger.Info("Setting link state down", zap.String("containerVethName", containerVethName))
if err := nu.netlink.SetLinkState(containerVethName, false); err != nil {
return newErrorNetworkUtils(err.Error())
}
Expand All @@ -113,7 +111,6 @@ func (nu NetworkUtils) SetupContainerInterface(containerVethName, targetIfName s
}

// Bring the interface back up.
logger.Info("Setting link state up.", zap.String("targetIfName", targetIfName))
err := nu.netlink.SetLinkState(targetIfName, true)
if err != nil {
return newErrorNetworkUtils(err.Error())
Expand Down
3 changes: 0 additions & 3 deletions network/snat/snat_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func NewSnatClient(hostIfName string,
plClient platform.ExecClient,
iptc ipTablesClient,
) Client {
logger.Info("Initialize new snat client")
snatClient := Client{
hostSnatVethName: hostIfName,
containerSnatVethName: contIfName,
Expand Down Expand Up @@ -446,8 +445,6 @@ func (client *Client) createSnatBridge(snatBridgeIP, hostPrimaryMac string) erro
return err
}

logger.Info("Setting snat bridge mac", zap.String("hostPrimaryMac", hostPrimaryMac))

ip, addr, _ := net.ParseCIDR(snatBridgeIP)
err = client.netlink.AddIPAddress(SnatBridgeName, ip, addr)
if err != nil && !strings.Contains(strings.ToLower(err.Error()), "file exists") {
Expand Down
4 changes: 1 addition & 3 deletions network/transparent_endpointclient_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,6 @@ func (client *TransparentEndpointClient) ConfigureContainerInterfacesAndRoutes(e
}

func (client *TransparentEndpointClient) setupIPV6Routes() error {
logger.Info("Setting up ipv6 routes in container")

// add route for virtualgwip
// ip -6 route add fe80::1234:5678:9abc/128 dev eth0
virtualGwIP, virtualGwNet, _ := net.ParseCIDR(virtualv6GwString)
Expand All @@ -298,7 +296,7 @@ func (client *TransparentEndpointClient) setupIPV6Routes() error {

// ip -6 route add default via fe80::1234:5678:9abc dev eth0
_, defaultIPNet, _ := net.ParseCIDR(defaultv6Cidr)
logger.Info("defaultv6ipnet", zap.Any("defaultIPNet", defaultIPNet))
logger.Info("Setting up ipv6 routes in container", zap.Any("defaultIPNet", defaultIPNet))
defaultRoute := RouteInfo{
Dst: *defaultIPNet,
Gw: virtualGwIP,
Expand Down
3 changes: 1 addition & 2 deletions network/transparent_vlan_endpointclient_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ func (client *TransparentVlanEndpointClient) PopulateVM(epInfo *EndpointInfo) er
return errors.Wrap(err, "failed to get vm ns handle")
}

logger.Info("Checking if NS exists...")
var existingErr error
client.vnetNSFileDescriptor, existingErr = client.netnsClient.GetFromName(client.vnetNSName)
// If the ns does not exist, the below code will trigger to create it
Expand Down Expand Up @@ -308,7 +307,7 @@ func (client *TransparentVlanEndpointClient) PopulateVM(epInfo *EndpointInfo) er
// Get the default constant host veth mac
mac, err := net.ParseMAC(defaultHostVethHwAddr)
if err != nil {
logger.Info("Failed to parse the mac addrress", zap.String("defaultHostVethHwAddr", defaultHostVethHwAddr))
logger.Info("Failed to parse the mac address", zap.String("defaultHostVethHwAddr", defaultHostVethHwAddr))
}

// Create veth pair
Expand Down