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
11 changes: 9 additions & 2 deletions cni/network/invoker_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,21 @@ import (
"github.com/Azure/azure-container-networking/log"
"github.com/Azure/azure-container-networking/network"
cniSkel "github.com/containernetworking/cni/pkg/skel"
cniTypes "github.com/containernetworking/cni/pkg/types"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
)

type AzureIPAMInvoker struct {
plugin *netPlugin
plugin delegatePlugin
nwInfo *network.NetworkInfo
}

type delegatePlugin interface {
DelegateAdd(pluginName string, nwCfg *cni.NetworkConfig) (*cniTypesCurr.Result, error)
DelegateDel(pluginName string, nwCfg *cni.NetworkConfig) error
Errorf(format string, args ...interface{}) *cniTypes.Error
}

func NewAzureIpamInvoker(plugin *netPlugin, nwInfo *network.NetworkInfo) *AzureIPAMInvoker {
return &AzureIPAMInvoker{
plugin: plugin,
Expand Down Expand Up @@ -51,7 +58,7 @@ func (invoker *AzureIPAMInvoker) Add(nwCfg *cni.NetworkConfig, _ *cniSkel.CmdArg
defer func() {
if err != nil {
if len(result.IPs) > 0 {
if er := invoker.plugin.ipamInvoker.Delete(&result.IPs[0].Address, nwCfg, nil, options); er != nil {
if er := invoker.Delete(&result.IPs[0].Address, nwCfg, nil, options); er != nil {
err = invoker.plugin.Errorf("Failed to clean up IP's during Delete with error %v, after Add failed with error %w", er, err)
}
} else {
Expand Down
Loading