Skip to content

Commit

Permalink
Add nil checks and debug log for CNI client
Browse files Browse the repository at this point in the history
  • Loading branch information
ohsoo committed Aug 22, 2024
1 parent 2cfc68d commit 72d6d1d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ecs-agent/netlib/model/ecscni/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"github.com/containernetworking/cni/pkg/invoke"
"github.com/containernetworking/cni/pkg/types"
"github.com/pkg/errors"

"github.com/aws/amazon-ecs-agent/ecs-agent/logger"
)

const (
Expand All @@ -48,9 +50,10 @@ func NewCNIClient(paths []string) CNI {
func (c *cniClient) Add(ctx context.Context, config PluginConfig) (types.Result, error) {
rt := BuildRuntimeConfig(config)
net, err := BuildNetworkConfig(config)
if err != nil {
if err != nil || net == nil || net.Network == nil {
return nil, err
}
logger.Debug("Built network config", logger.Fields{"Type": net.Network.Type})

return c.cni.AddNetwork(ctx, net, rt)
}
Expand Down

0 comments on commit 72d6d1d

Please sign in to comment.