// Return: first error is recoverable, 2nd error cannot be recovered
first error is recoverable, 2nd error cannot be recovered
// Return : first error is recoverable 2nd error cannot be recovered
func (c *MizarArktosNetworkController) createVpcAndSubnet(vpc, subnet string, dynamicClient dynamic.Interface) (error, error) {
	_, _, vpcSpec, err, permErr := c.generateVPCSpec(vpc)
	if err != nil || permErr != nil {
		return err, permErr
	}
	vpcData, err := json.Marshal(vpcSpec)
	if err != nil {
		klog.Errorf("Error marshalling VPC %s spec. Error: %v", vpc, err)
		return err, nil
	}
	err = controller.CreateUnstructuredObject(vpcData, dynamicClient)
	if err != nil && !apierrors.IsAlreadyExists(err) {
		klog.Errorf("Error creating VPC %s. Error: %v", vpc, err)
		return err, nil
	}
	subnetSpec, err := generateSubnetSpec(vpc, subnet, vpcSpec.Spec.IP)
	if err != nil {
		klog.Errorf("Error getting Subnet %s spec. Error: %v", subnet, err)
		return err, nil
	}
	err = controller.CreateUnstructuredObject(subnetSpec, dynamicClient)
	if err != nil && !apierrors.IsAlreadyExists(err) {
		klog.Errorf("Error creating Subnet %s for VPC %s. Error: %v", subnetSpec, vpc, err)
		return err, nil
	}
	return nil, nil
}
func ( c * MizarArktosNetworkController ) createVpcAndSubnet ( vpc , subnet string , dynamicClient dynamic . Interface ) ( error , error ) { _ , _ , vpcSpec , err , permErr := c . generateVPCSpec ( vpc ) if err != nil || permErr != nil { return err , permErr } vpcData , err := json . Marshal ( vpcSpec ) if err != nil { klog . Errorf ( " " , vpc , err ) return err , nil } err = controller . CreateUnstructuredObject ( vpcData , dynamicClient ) if err != nil && ! apierrors . IsAlreadyExists ( err ) { klog . Errorf ( " " , vpc , err ) return err , nil } subnetSpec , err := generateSubnetSpec ( vpc , subnet , vpcSpec . Spec . IP ) if err != nil { klog . Errorf ( " " , subnet , err ) return err , nil } err = controller . CreateUnstructuredObject ( subnetSpec , dynamicClient ) if err != nil && ! apierrors . IsAlreadyExists ( err ) { klog . Errorf ( " " , subnetSpec , vpc , err ) return err , nil } return nil , nil }
first error is recoverable, 2nd error cannot be recovered
first error is recoverable 2nd error cannot be recovered
// Create VPC object // Create Subnet object