func CleanUpIPAM(conf NetConf, args *skel.CmdArgs, logger *log.Entry) error {
	fmt.Fprintf(os.Stderr, "Calico CNI releasing IP address\n")
	logger.WithFields(log.Fields{"paths": os.Getenv("CNI_PATH"),
		"type": conf.IPAM.Type}).Debug("Looking for IPAM plugin in paths")

	// We need to replace "usePodCidr" with a valid, but dummy podCidr string with "host-local" IPAM.
	if conf.IPAM.Type == "host-local" && strings.EqualFold(conf.IPAM.Subnet, "usePodCidr") {
		// host-local IPAM releases the IP by ContainerID, so podCidr isn't really used to release the IP.
		// It just needs a valid CIDR, but it doesn't have to be the CIDR associated with the host.
		dummyPodCidr := "0.0.0.0/0"
		var stdinData map[string]interface{}

		err := json.Unmarshal(args.StdinData, &stdinData)
		if err != nil {
			return err
		}

		logger.WithField("podCidr", dummyPodCidr).Info("Using a dummy podCidr to release the IP")
		stdinData["ipam"].(map[string]interface{})["subnet"] = dummyPodCidr

		args.StdinData, err = json.Marshal(stdinData)
		if err != nil {
			return err
		}
		logger.WithField("stdin", string(args.StdinData)).Debug("Updated stdin data for Delete Cmd")
	}

	err := ipam.ExecDel(conf.IPAM.Type, args.StdinData)

	if err != nil {
		logger.Error(err)
	}

	return err
}
// CleanUpIPAM calls IPAM plugin to release the IP address.
// It also contains IPAM plugin specific changes needed before calling the plugin.
CleanUpIPAM calls IPAM plugin to release the IP address.
It also contains IPAM plugin specific changes needed before calling the plugin.
// CleanUpIPAM calls IPAM plugin to release the IP address . // It also contains IPAM plugin specific changes needed before calling the plugin .
func CleanUpIPAM(conf NetConf, args *skel.CmdArgs, logger *log.Entry) error {
	fmt.Fprintf(os.Stderr, "Calico CNI releasing IP address\n")
	logger.WithFields(log.Fields{"paths": os.Getenv("CNI_PATH"),
		"type": conf.IPAM.Type}).Debug("Looking for IPAM plugin in paths")
	if conf.IPAM.Type == "host-local" && strings.EqualFold(conf.IPAM.Subnet, "usePodCidr") {
		dummyPodCidr := "0.0.0.0/0"
		var stdinData map[string]interface{}
		err := json.Unmarshal(args.StdinData, &stdinData)
		if err != nil {
			return err
		}
		logger.WithField("podCidr", dummyPodCidr).Info("Using a dummy podCidr to release the IP")
		stdinData["ipam"].(map[string]interface{})["subnet"] = dummyPodCidr
		args.StdinData, err = json.Marshal(stdinData)
		if err != nil {
			return err
		}
		logger.WithField("stdin", string(args.StdinData)).Debug("Updated stdin data for Delete Cmd")
	}
	err := ipam.ExecDel(conf.IPAM.Type, args.StdinData)
	if err != nil {
		logger.Error(err)
	}
	return err
}
func CleanUpIPAM ( conf NetConf , args * skel . CmdArgs , logger * log . Entry ) error { fmt . Fprintf ( os . Stderr , " \n " ) logger . WithFields ( log . Fields { " " : os . Getenv ( " " ) , " " : conf . IPAM . Type } ) . Debug ( " " ) if conf . IPAM . Type == " " && strings . EqualFold ( conf . IPAM . Subnet , " " ) { dummyPodCidr := " " var stdinData map [ string ] interface { } err := json . Unmarshal ( args . StdinData , & stdinData ) if err != nil { return err } logger . WithField ( " " , dummyPodCidr ) . Info ( " " ) stdinData [ " " ] . ( map [ string ] interface { } ) [ " " ] = dummyPodCidr args . StdinData , err = json . Marshal ( stdinData ) if err != nil { return err } logger . WithField ( " " , string ( args . StdinData ) ) . Debug ( " " ) } err := ipam . ExecDel ( conf . IPAM . Type , args . StdinData ) if err != nil { logger . Error ( err ) } return err }
CleanUpIPAM calls IPAM plugin to release the IP address.
CleanUpIPAM calls IPAM plugin to release the IP address .
// We need to replace "usePodCidr" with a valid, but dummy podCidr string with "host-local" IPAM. // host-local IPAM releases the IP by ContainerID, so podCidr isn't really used to release the IP. // It just needs a valid CIDR, but it doesn't have to be the CIDR associated with the host.