File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -193,7 +193,7 @@ func (plugin *ipamPlugin) Add(args *cniSkel.CmdArgs) error {
193193 defer func () {
194194 if err != nil && address != "" {
195195 log .Printf ("[cni-ipam] Releasing address %v." , address )
196- plugin .am .ReleaseAddress (nwCfg .Ipam .AddrSpace , nwCfg .Ipam .Subnet , address )
196+ plugin .am .ReleaseAddress (nwCfg .Ipam .AddrSpace , nwCfg .Ipam .Subnet , address , nil )
197197 }
198198 }()
199199
@@ -274,7 +274,7 @@ func (plugin *ipamPlugin) Delete(args *cniSkel.CmdArgs) error {
274274 // If an address is specified, release that address. Otherwise, release the pool.
275275 if nwCfg .Ipam .Address != "" {
276276 // Release the address.
277- err := plugin .am .ReleaseAddress (nwCfg .Ipam .AddrSpace , nwCfg .Ipam .Subnet , nwCfg .Ipam .Address )
277+ err := plugin .am .ReleaseAddress (nwCfg .Ipam .AddrSpace , nwCfg .Ipam .Subnet , nwCfg .Ipam .Address , nil )
278278 if err != nil {
279279 err = plugin .Errorf ("Failed to release address: %v" , err )
280280 return err
Original file line number Diff line number Diff line change @@ -517,8 +517,8 @@ func (ap *addressPool) releaseAddress(address string, options map[string]string)
517517 var id string
518518 var err error
519519
520- log .Printf ("[ipam] Releasing address %v options:%+v." , address , options )
521- defer func () { log .Printf ("[ipam] Address release completed with err:%v." , err ) }()
520+ log .Printf ("[ipam] Releasing address with address: %v options:%+v." , address , options )
521+ defer func () { log .Printf ("[ipam] Address release completed with address:%v err:%v." , address , err ) }()
522522
523523 if options != nil {
524524 id = options [OptAddressID ]
@@ -535,10 +535,13 @@ func (ap *addressPool) releaseAddress(address string, options map[string]string)
535535 } else if id != "" {
536536 // Release the address with the matching ID.
537537 ar = ap .addrsByID [id ]
538- log .Printf ("[ipam] Releasing address %v." , ar .Addr .String ())
538+ if ar != nil {
539+ address = ar .Addr .String ()
540+ }
539541 }
540542
541- if ar == nil {
543+ // Fail if an address record with a matching ID is not found.
544+ if ar == nil || (id != "" && id != ar .ID ) {
542545 err = errAddressNotFound
543546 return err
544547 }
You can’t perform that action at this time.
0 commit comments