// manageNonFlatNetwork is the core logic to manage a non-flat typed network object
manageNonFlatNetwork is the core logic to manage a non-flat typed network object
// manageNonFlatNetwork is the core logic to manage a non - flat typed network object
func manageNonFlatNetwork(net *v1.Network, netClient arktos.Interface, svcClient kubernetes.Interface, toDeployDNS bool, domainName, kubeAPIServerIP, kubeAPIServerPort, saltSuffix string) error {
	if net.DeletionTimestamp != nil {
		return ensureTerminatingPhase(net, netClient)
	}
	var dnsSvc *corev1.Service
	var err error
	if len(net.Status.DNSServiceIP) == 0 {
		if dnsSvc, err = createOrGetDNSService(net, svcClient); err != nil {
			return fmt.Errorf("failed to get or create per-network DNS service: %v", err)
		}
	}
	if toDeployDNS {
		if err = deployDNSForNetwork(net, svcClient, saltSuffix, domainName, kubeAPIServerIP, kubeAPIServerPort); err != nil {
			return fmt.Errorf("failed to deploy per-network DNS: %v", err)
		}
	}
	if _, err = createOrGetKubernetesService(net, svcClient); err != nil {
		return fmt.Errorf("failed to get or create per-network Kubernetes service: %v", err)
	}
	if len(net.Status.DNSServiceIP) == 0 {
		if len(dnsSvc.Spec.ClusterIP) == 0 && net.Status.Phase == v1.NetworkPending {
			return nil
		}
		netReady := net.DeepCopy()
		if len(dnsSvc.Spec.ClusterIP) > 0 {
			netReady.Status.DNSServiceIP = dnsSvc.Spec.ClusterIP
			netReady.Status.Message = "DNS service IP allocated"
			netReady.Status.Phase = v1.NetworkReady
		} else {
			netReady.Status.Phase = v1.NetworkPending
			netReady.Status.Message = "waiting for DNS service IP assigned"
		}
		_, err = netClient.ArktosV1().NetworksWithMultiTenancy(netReady.Tenant).UpdateStatus(netReady)
	} else {
		if len(net.Status.Phase) == 0 || net.Status.Phase == v1.NetworkPending {
			netReady := net.DeepCopy()
			netReady.Status.Phase = v1.NetworkReady
			netReady.Status.Message = "DNS service IP allocated"
			_, err = netClient.ArktosV1().NetworksWithMultiTenancy(netReady.Tenant).UpdateStatus(netReady)
		}
	}
	return err
}
func manageNonFlatNetwork ( net * v1 . Network , netClient arktos . Interface , svcClient kubernetes . Interface , toDeployDNS bool , domainName , kubeAPIServerIP , kubeAPIServerPort , saltSuffix string ) error { if net . DeletionTimestamp != nil { return ensureTerminatingPhase ( net , netClient ) } var dnsSvc * corev1 . Service var err error if len ( net . Status . DNSServiceIP ) == 0 { if dnsSvc , err = createOrGetDNSService ( net , svcClient ) ; err != nil { return fmt . Errorf ( " " , err ) } } if toDeployDNS { if err = deployDNSForNetwork ( net , svcClient , saltSuffix , domainName , kubeAPIServerIP , kubeAPIServerPort ) ; err != nil { return fmt . Errorf ( " " , err ) } } if _ , err = createOrGetKubernetesService ( net , svcClient ) ; err != nil { return fmt . Errorf ( " " , err ) } if len ( net . Status . DNSServiceIP ) == 0 { if len ( dnsSvc . Spec . ClusterIP ) == 0 && net . Status . Phase == v1 . NetworkPending { return nil } netReady := net . DeepCopy ( ) if len ( dnsSvc . Spec . ClusterIP ) > 0 { netReady . Status . DNSServiceIP = dnsSvc . Spec . ClusterIP netReady . Status . Message = " " netReady . Status . Phase = v1 . NetworkReady } else { netReady . Status . Phase = v1 . NetworkPending netReady . Status . Message = " " } _ , err = netClient . ArktosV1 ( ) . NetworksWithMultiTenancy ( netReady . Tenant ) . UpdateStatus ( netReady ) } else { if len ( net . Status . Phase ) == 0 || net . Status . Phase == v1 . NetworkPending { netReady := net . DeepCopy ( ) netReady . Status . Phase = v1 . NetworkReady netReady . Status . Message = " " _ , err = netClient . ArktosV1 ( ) . NetworksWithMultiTenancy ( netReady . Tenant ) . UpdateStatus ( netReady ) } } return err }
manageNonFlatNetwork is the core logic to manage a non-flat typed network object
manageNonFlatNetwork is the core logic to manage a non - flat typed network object
// dns service IP might be empty if it is of external IPAM and the external provider has not assign one yet // network status is already pending // since dns service gets IP addr allocated, we need to update network object with the DNS service IP // got dns service IP assigned; make request to ready phase if applicable