func (alloc *IPAllocator) Release(nameSpace, podName string, releaseFixed bool) error {
	e := alloc.etcdClient
	response, err := concurrency.NewSTM(e, func(s concurrency.STM) error {
		podNetworkKey := fmt.Sprintf(types.Pod_Key, nameSpace, podName)
		podNetworkStr := s.Get(podNetworkKey)
		if podNetworkStr == "" {
			log.Alloc.Errorf("pod  %s,%s is not exist !!!", nameSpace, podName)
			return nil
		}
		podNetwork := &types.PodNetwork{}
		err := json.Unmarshal([]byte(podNetworkStr), podNetwork)
		if err != nil {
			return fmt.Errorf("unmarshal %s to podNetwork %v err  %v", podNetworkStr, podNetwork, err)
		}
		if podNetwork.FixedIP && !releaseFixed {
			podNetwork.StsDeleted = true
			podNetwork.ModifyTime = time.Now()
			podNetworkStr, err := json.Marshal(podNetwork)
			if err != nil {
				return fmt.Errorf("marshal %v to podNetworkStr %s err  %v", podNetwork, podNetworkStr, err)
			}
			s.Put(podNetworkKey, string(podNetworkStr))
			log.Alloc.Infof("pod %s reserved fixed ip %s", podName, podNetwork.PodIP)
			return nil
		}
		var nsPoolName string
		if podNetwork.SvcIPPoolName != "" {
			servicePoolKey := fmt.Sprintf(types.Servicce_Pool_Key, nameSpace, podNetwork.SvcIPPoolName)
			str := s.Get(servicePoolKey)
			serviceIPPool := &types.ServiceIPPool{}
			err := json.Unmarshal([]byte(str), serviceIPPool)
			if err != nil {
				return fmt.Errorf("unmarshal %s to serviceIPPool err ", str)
			}
			serviceIPPool.Used--
			svcPoolStr, err := json.Marshal(serviceIPPool)
			if err != nil {
				return fmt.Errorf("svcPoolStr marshal err %v", err)
			}
			s.Put(servicePoolKey, string(svcPoolStr))
			nsPoolName = serviceIPPool.NSIPPoolName
		} else {
			return nil
		}
		if nsPoolName != "" {
			hcPoolKey := fmt.Sprintf(types.NS_POOL_Key, nameSpace, nsPoolName)
			hcPoolStr := s.Get(hcPoolKey)
			hcPool := &types.NSIPPool{}
			err := json.Unmarshal([]byte(hcPoolStr), hcPool)
			if err != nil {
				return fmt.Errorf("unmarshal %s to hcPool err %v ", hcPoolStr, err)
			}
			temPod := types.PodNetwork{}
			oldPod := hcPool.PodMap[podNetwork.PodIP.String()]
			temPod.PodIP = oldPod.PodIP
			temPod.SvcName = oldPod.SvcName
			temPod.SvcIPPoolName = oldPod.SvcIPPoolName
			temPod.Namespace = oldPod.Namespace
			temPod.StsDeleted = false
			hcPool.PodMap[podNetwork.PodIP.String()] = temPod
			hcPoolStrBytes, err := json.Marshal(hcPool)
			if err != nil {
				return fmt.Errorf("hcPoolS  marshal err %v", err)
			}
			s.Put(fmt.Sprintf(types.NS_POOL_Key, nameSpace, hcPool.Name), string(hcPoolStrBytes))
		}
		s.Del(podNetworkKey)
		return nil
	})
	if err != nil {
		return err
	}
	if response.Succeeded {
		return nil
	}
	return fmt.Errorf("unknown err")
}
Release remove an IP usage record from etcd if not fixed,
for fixed IP, Release tags the IP with "delete" flag
package allocator
import (
	"context"
	"encoding/json"
	"fmt"
	"github.com/containernetworking/cni/pkg/types/current"
	"github.com/containernetworking/plugins/pkg/ip"
	"github.com/harmonycloud/bifrost/pkg/log"
	"github.com/harmonycloud/bifrost/pkg/types"
	"go.etcd.io/etcd/clientv3"
	"go.etcd.io/etcd/clientv3/concurrency"
	"net"
	"strings"
	"time"
)
type IPAllocator struct {
	etcdClient *clientv3.Client
}
func NewIPAllocator(etcdClient *clientv3.Client) *IPAllocator {
	return &IPAllocator{
		etcdClient: etcdClient,
	}
}
func (alloc *IPAllocator) AllocateIP(fixed bool, nameSpace, serviceIPPoolName, podName, stsName string) (*current.IPConfig, *types.NSIPPool, error) {
	var reservedIP *net.IPNet
	var reservedIPAddress *net.IP
	var err error
	var nsIPPool *types.NSIPPool
	reservedIPAddress, nsIPPool, err = alloc.getServiceSpecIP(fixed, nameSpace, serviceIPPoolName, podName, stsName, alloc.etcdClient)
	if err != nil {
		return nil, nil, err
	}
	if reservedIPAddress == nil {
		return nil, nil, fmt.Errorf("no IP addresses available in serviceIPPool  %s", serviceIPPoolName)
	}
	reservedIP = &net.IPNet{IP: *reservedIPAddress, Mask: nsIPPool.Subnet.Mask}
	version := "4"
	log.Alloc.Debugf("get ip succeed %v", reservedIP)
	return &current.IPConfig{
		Version: version,
		Address: *reservedIP,
	}, nsIPPool, nil
}