@@ -3,26 +3,20 @@ package main
33import (
44 "context"
55 "encoding/json"
6- "fmt"
76 "io"
87 "net"
98
109 "github.com/Azure/azure-container-networking/azure-ipam/internal/buildinfo"
1110 "github.com/Azure/azure-container-networking/azure-ipam/ipconfig"
1211 "github.com/Azure/azure-container-networking/cns"
1312 cnscli "github.com/Azure/azure-container-networking/cns/client"
14- "github.com/Azure/azure-container-networking/cns/fsnotify"
1513 cniSkel "github.com/containernetworking/cni/pkg/skel"
1614 cniTypes "github.com/containernetworking/cni/pkg/types"
1715 types100 "github.com/containernetworking/cni/pkg/types/100"
1816 "github.com/pkg/errors"
1917 "go.uber.org/zap"
2018)
2119
22- const (
23- watcherPath = "/var/run/azure-vnet/deleteIDs"
24- )
25-
2620// IPAMPlugin is the struct for the delegated azure-ipam plugin
2721// https://www.cni.dev/docs/spec/#section-4-plugin-delegation
2822type IPAMPlugin struct {
@@ -160,7 +154,6 @@ func (p *IPAMPlugin) CmdAdd(args *cniSkel.CmdArgs) error {
160154
161155// CmdDel handles CNI delete commands.
162156func (p * IPAMPlugin ) CmdDel (args * cniSkel.CmdArgs ) error {
163- var connectionErr * cnscli.ConnectionFailureErr
164157 p .logger .Info ("DEL called" , zap .Any ("args" , args ))
165158
166159 // Create ip config request from args
@@ -188,28 +181,8 @@ func (p *IPAMPlugin) CmdDel(args *cniSkel.CmdArgs) error {
188181 err = p .cnsClient .ReleaseIPAddress (context .TODO (), ipconfigReq )
189182
190183 if err != nil {
191- if errors .As (err , & connectionErr ) {
192- p .logger .Info ("Failed to release IP address from CNS due to connection failure, saving to watcher to delete" )
193- addErr := fsnotify .AddFile (args .ContainerID , args .ContainerID , watcherPath )
194- if addErr != nil {
195- p .logger .Error ("Failed to add file to watcher" , zap .String ("containerID" , args .ContainerID ), zap .Error (addErr ))
196- return cniTypes .NewError (cniTypes .ErrTryAgainLater , addErr .Error (), fmt .Sprintf ("failed to add file to watcher with containerID %s" , args .ContainerID ))
197- } else {
198- p .logger .Info ("File successfully added to watcher directory" )
199- }
200- } else {
201- p .logger .Error ("Failed to release IP address to CNS using ReleaseIPAddress" , zap .Error (err ), zap .Any ("request" , ipconfigReq ))
202- return cniTypes .NewError (ErrRequestIPConfigFromCNS , err .Error (), "failed to release IP address from CNS using ReleaseIPAddress" )
203- }
204- }
205- } else if errors .As (err , & connectionErr ) {
206- p .logger .Info ("Failed to release IP addresses from CNS due to connection failure, saving to watcher to delete" )
207- addErr := fsnotify .AddFile (args .ContainerID , args .ContainerID , watcherPath )
208- if addErr != nil {
209- p .logger .Error ("Failed to add file to watcher" , zap .String ("containerID" , args .ContainerID ), zap .Error (addErr ))
210- return cniTypes .NewError (cniTypes .ErrTryAgainLater , addErr .Error (), fmt .Sprintf ("failed to add file to watcher with containerID %s" , args .ContainerID ))
211- } else {
212- p .logger .Info ("File successfully added to watcher directory" )
184+ p .logger .Error ("Failed to release IP address to CNS using ReleaseIPAddress" , zap .Error (err ), zap .Any ("request" , ipconfigReq ))
185+ return cniTypes .NewError (ErrRequestIPConfigFromCNS , err .Error (), "failed to release IP address from CNS using ReleaseIPAddress" )
213186 }
214187 } else {
215188 p .logger .Error ("Failed to release IP addresses from CNS" , zap .Error (err ), zap .Any ("request" , req ))
0 commit comments