func del()

in plugins/ipam/commands/commands.go [116:144]


func del(ipManager ipstore.IPAllocator, ipamConf *config.IPAMConfig) error {
	var releasedIP string

	if ipamConf.IPV4Address.IP != nil && net.ParseIP(ipamConf.IPV4Address.IP.String()) != nil {
		// Release the ip by ip address
		err := ipManager.Release(ipamConf.IPV4Address.IP.String())
		if err != nil {
			return err
		}
		releasedIP = ipamConf.IPV4Address.IP.String()
	} else {
		// Release the ip by unique id associated with the ip
		ip, err := ipManager.ReleaseByID(ipamConf.ID)
		if err != nil {
			return nil
		}
		releasedIP = ip
	}

	// Update the last known ip
	err := ipManager.Update("lastKnownIP", releasedIP)
	if err != nil {
		// This error will only impact how the next ip will be find, it shouldn't cause
		// the command to fail
		seelog.Warnf("Del commands: update the last known ip failed: %v", err)
	}

	return nil
}