func (az *Cloud) reconcilePublicIP(clusterName string, service *v1.Service, wantLb bool) (*network.PublicIPAddress, error) {
	isInternal := requiresInternalLoadBalancer(service)
	serviceName := getServiceName(service)
	var desiredPipName string
	var err error
	if !isInternal && wantLb {
		desiredPipName, err = az.determinePublicIPName(clusterName, service)
		if err != nil {
			return nil, err
		}
	}

	pipResourceGroup := az.getPublicIPAddressResourceGroup(service)

	pips, err := az.ListPIPWithRetry(pipResourceGroup)
	if err != nil {
		return nil, err
	}

	for _, pip := range pips {
		if pip.Tags != nil &&
			(*pip.Tags)["service"] != nil &&
			*(*pip.Tags)["service"] == serviceName {
			// We need to process for pips belong to this service
			pipName := *pip.Name
			if wantLb && !isInternal && pipName == desiredPipName {
				// This is the only case we should preserve the
				// Public ip resource with match service tag
			} else {
				glog.V(2).Infof("ensure(%s): pip(%s) - deleting", serviceName, pipName)
				glog.V(10).Infof("DeletePublicIPWithRetry(%s, %q): start", pipResourceGroup, pipName)
				err = az.DeletePublicIPWithRetry(pipResourceGroup, pipName)
				if err != nil {
					glog.V(2).Infof("ensure(%s) abort backoff: pip(%s) - deleting", serviceName, pipName)
					// We let err to pass through
					// It may be ignorable
				}
				glog.V(10).Infof("DeletePublicIPWithRetry(%s, %q): end", pipResourceGroup, pipName) // response not read yet...

				err = ignoreStatusNotFoundFromError(err)
				if err != nil {
					return nil, err
				}
				glog.V(2).Infof("ensure(%s): pip(%s) - finished", serviceName, pipName)
			}
		}

	}

	if !isInternal && wantLb {
		// Confirm desired public ip resource exists
		var pip *network.PublicIPAddress
		domainNameLabel := getPublicIPDomainNameLabel(service)
		if pip, err = az.ensurePublicIPExists(service, desiredPipName, domainNameLabel); err != nil {
			return nil, err
		}
		return pip, nil
	}
	return nil, nil
}
// This reconciles the PublicIP resources similar to how the LB is reconciled.
This reconciles the PublicIP resources similar to how the LB is reconciled.
// This reconciles the PublicIP resources similar to how the LB is reconciled .
func (az *Cloud) reconcilePublicIP(clusterName string, service *v1.Service, wantLb bool) (*network.PublicIPAddress, error) {
	isInternal := requiresInternalLoadBalancer(service)
	serviceName := getServiceName(service)
	var desiredPipName string
	var err error
	if !isInternal && wantLb {
		desiredPipName, err = az.determinePublicIPName(clusterName, service)
		if err != nil {
			return nil, err
		}
	}
	pipResourceGroup := az.getPublicIPAddressResourceGroup(service)
	pips, err := az.ListPIPWithRetry(pipResourceGroup)
	if err != nil {
		return nil, err
	}
	for _, pip := range pips {
		if pip.Tags != nil &&
			(*pip.Tags)["service"] != nil &&
			*(*pip.Tags)["service"] == serviceName {
			pipName := *pip.Name
			if wantLb && !isInternal && pipName == desiredPipName {
			} else {
				glog.V(2).Infof("ensure(%s): pip(%s) - deleting", serviceName, pipName)
				glog.V(10).Infof("DeletePublicIPWithRetry(%s, %q): start", pipResourceGroup, pipName)
				err = az.DeletePublicIPWithRetry(pipResourceGroup, pipName)
				if err != nil {
					glog.V(2).Infof("ensure(%s) abort backoff: pip(%s) - deleting", serviceName, pipName)
				}
				glog.V(10).Infof("DeletePublicIPWithRetry(%s, %q): end", pipResourceGroup, pipName) 
				err = ignoreStatusNotFoundFromError(err)
				if err != nil {
					return nil, err
				}
				glog.V(2).Infof("ensure(%s): pip(%s) - finished", serviceName, pipName)
			}
		}
	}
	if !isInternal && wantLb {
		var pip *network.PublicIPAddress
		domainNameLabel := getPublicIPDomainNameLabel(service)
		if pip, err = az.ensurePublicIPExists(service, desiredPipName, domainNameLabel); err != nil {
			return nil, err
		}
		return pip, nil
	}
	return nil, nil
}
func ( az * Cloud ) reconcilePublicIP ( clusterName string , service * v1 . Service , wantLb bool ) ( * network . PublicIPAddress , error ) { isInternal := requiresInternalLoadBalancer ( service ) serviceName := getServiceName ( service ) var desiredPipName string var err error if ! isInternal && wantLb { desiredPipName , err = az . determinePublicIPName ( clusterName , service ) if err != nil { return nil , err } } pipResourceGroup := az . getPublicIPAddressResourceGroup ( service ) pips , err := az . ListPIPWithRetry ( pipResourceGroup ) if err != nil { return nil , err } for _ , pip := range pips { if pip . Tags != nil && ( * pip . Tags ) [ " " ] != nil && * ( * pip . Tags ) [ " " ] == serviceName { pipName := * pip . Name if wantLb && ! isInternal && pipName == desiredPipName { } else { glog . V ( 2 ) . Infof ( " " , serviceName , pipName ) glog . V ( 10 ) . Infof ( " " , pipResourceGroup , pipName ) err = az . DeletePublicIPWithRetry ( pipResourceGroup , pipName ) if err != nil { glog . V ( 2 ) . Infof ( " " , serviceName , pipName ) } glog . V ( 10 ) . Infof ( " " , pipResourceGroup , pipName ) err = ignoreStatusNotFoundFromError ( err ) if err != nil { return nil , err } glog . V ( 2 ) . Infof ( " " , serviceName , pipName ) } } } if ! isInternal && wantLb { var pip * network . PublicIPAddress domainNameLabel := getPublicIPDomainNameLabel ( service ) if pip , err = az . ensurePublicIPExists ( service , desiredPipName , domainNameLabel ) ; err != nil { return nil , err } return pip , nil } return nil , nil }
This reconciles the PublicIP resources similar to how the LB is reconciled.
This reconciles the PublicIP resources similar to how the LB is reconciled .
// We need to process for pips belong to this service // This is the only case we should preserve the // Public ip resource with match service tag // We let err to pass through // It may be ignorable // response not read yet... // Confirm desired public ip resource exists