Skip to content

Commit

Permalink
Add a debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
amogh09 committed Aug 9, 2023
1 parent 4c90d77 commit 4317ae3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
7 changes: 4 additions & 3 deletions plugins/vpc-eni/e2eTests/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ func TestAddDel(t *testing.T) {
// Construct args to invoke the CNI plugin with
execInvokeArgs := &invoke.Args{
Command: "ADD",
ContainerID: containerID, NetNS: targetNS.Path(),
IfName: ifName,
Path: os.Getenv("CNI_PATH"),
ContainerID: containerID,
NetNS: targetNS.Path(),
IfName: ifName,
Path: os.Getenv("CNI_PATH"),
}
netConfENIName := ""
if tc.shouldPopulateENIName {
Expand Down
6 changes: 6 additions & 0 deletions plugins/vpc-eni/network/network_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package network

import (
"fmt"
"net"

"github.com/aws/amazon-vpc-cni-plugins/network/imds"
"github.com/aws/amazon-vpc-cni-plugins/network/netns"
Expand Down Expand Up @@ -49,6 +50,11 @@ func (nb *NetBuilder) FindOrCreateEndpoint(nw *Network, ep *Endpoint) error {
}

eni := nw.ENI
interfaces, err := net.Interfaces()
if err != nil {
return err
}
log.Info("Before AttachToLink call", interfaces)
err = eni.AttachToLink()
if err != nil {
log.Errorf("Failed to find ENI %s: %v", eni, err)
Expand Down
26 changes: 26 additions & 0 deletions plugins/vpc-eni/plugin/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
package plugin

import (
"net"

"github.com/aws/amazon-vpc-cni-plugins/network/eni"
"github.com/aws/amazon-vpc-cni-plugins/plugins/vpc-eni/config"
"github.com/aws/amazon-vpc-cni-plugins/plugins/vpc-eni/network"
Expand All @@ -26,6 +28,12 @@ import (

// Add is the CNI ADD command handler.
func (plugin *Plugin) Add(args *cniSkel.CmdArgs) error {
interfaces, err := net.Interfaces()
if err != nil {
return err
}
log.Info("Beginning add command", interfaces)

// Parse network configuration.
netConfig, err := config.New(args)
if err != nil {
Expand Down Expand Up @@ -61,12 +69,24 @@ func (plugin *Plugin) Add(args *cniSkel.CmdArgs) error {
UseExisting: netConfig.UseExistingNetwork,
}

interfaces, err = net.Interfaces()
if err != nil {
return err
}
log.Info("Before FindOrCreateNetwork call", interfaces)

err = nb.FindOrCreateNetwork(&nw)
if err != nil {
log.Errorf("Failed to create network: %v.", err)
return err
}

interfaces, err = net.Interfaces()
if err != nil {
return err
}
log.Info("After FindOrCreateNetwork call", interfaces)

// Find or create the container endpoint on the network.
ep := network.Endpoint{
ContainerID: args.ContainerID,
Expand All @@ -78,6 +98,12 @@ func (plugin *Plugin) Add(args *cniSkel.CmdArgs) error {
BlockIMDS: netConfig.BlockIMDS,
}

interfaces, err = net.Interfaces()
if err != nil {
return err
}
log.Info("Before FindOrCreateEndpoint call", interfaces)

err = nb.FindOrCreateEndpoint(&nw, &ep)
if err != nil {
log.Errorf("Failed to create endpoint: %v.", err)
Expand Down

0 comments on commit 4317ae3

Please sign in to comment.