Giter Club home page Giter Club logo

machine-api-provider-ibmcloud's Issues

Error When Using MAPI on a VPC With Greater Than 50 Subnets

ISSUE:

Currently, the IBM Cloud VPC API sets a default to return only 50 subnets per page on an API call if an option is not set on the API call to return more. However, a single VPC can have up to a maximum of 100 subnets.

If a user configures their machine provider config to look for a subnet that is greater than 50 in the returned list, the MAPI will return an error since it's using the default value of 50 provided by the VPC API.

POSSIBLE SOLUTIONS:

  1. When using the IBM Cloud VPC API to return a subnet list, set the default limit to 100 so that all possible subnets are returned for the VPC. Such as:
    subnetOption.SetLimit=100
    https://cloud.ibm.com/apidocs/vpc/latest#list-subnets

  2. Support pagination if we choose to only return 50 results with the default setting

Additional Information:
Here is the code where I believe we could set subnetOption.SetLimit=100 to return the full result. This is also the code where the error is thrown if a subnet name provided in the machine provider config is over 50 in the returned list:

func (c *ibmCloudClient) GetSubnetIDbyName(subnetName string, resourceGroupID string) (string, error) {
	// Initialize List Subnets Options
	subnetOption := c.vpcService.NewListSubnetsOptions()

	// Set Resource Group ID
	subnetOption.SetResourceGroupID(resourceGroupID)

    // Set Limit to 100, ibmcloud limits 100 subnets per vpc <======.  add these 2 lines is my guess
    subnetOption.SetLimit(100)

	// Get a list of all subnets
	subnetList, _, err := c.vpcService.ListSubnets(subnetOption)
	if err != nil {
		return "", err
	}

	if subnetList != nil {
		for _, eachSubnet := range subnetList.Subnets {
			if *eachSubnet.Name == subnetName {
				// Return Subnet ID
				return *eachSubnet.ID, nil
			}
		}
	}
	return "", fmt.Errorf("could not retrieve subnet id of name: %v", subnetName)
}

Link:

func (c *ibmCloudClient) GetSubnetIDbyName(subnetName string, resourceGroupID string) (string, error) {

Current ProviderSpec does not support creating an instance with multiple interfaces

desired functionality
I would like to use Machine API Operator to auto-scale an IBM Cloud instance with multiple network interface attachments and with allow-ip-spoofing attribute.

why the current version does not support this
ProviderSpec does not contain attribute to refer to NetworkIntefaces attribute in vpcv1.instancePrototype when creating an instance.

type IBMCloudMachineProviderSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// vpc type Instance struct
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// VPC name where the instance will be created
VPC string `json:"vpc"`
// Actuator will apply these tags to an virtual server instance if not present in additon
// to default tags applied by the actuator
Tags []TagSpecs `json:"tags,omitempty"`
// Image is the id of the custom OS image in VPC
// Example: rchos-4-4-7 (Image name)
Image string `json:"image"`
// Profile indicates the flavor of instance.
// Example: bx2-8x32 (8 vCPUs, 32 GB RAM)
Profile string `json:"profile"`
// A DedicatedHost is the name of the underlying provisioned host in your VPC on which the instance/s
// will be created with the defined Profile.
// A dedicated host provides a single tenancy ensuring only your Compute/VSI's are provisioned on it.
// Instances provisioned on a dedicated host adds another layer of protection while minimizing latency
// and maximizing performance between the instances provisioned on a single host.
DedicatedHost string `json:"dedicatedHost,omitempty"`
// Region of the virtual machine
Region string `json:"region"`
// Zone where the virtual server instance will be created
Zone string `json:"zone"`
// ResourceGroup of VPC
ResourceGroup string `json:"resourceGroup"`
// PrimaryNetworkInterface is required to specify subnet
PrimaryNetworkInterface NetworkInterface `json:"primaryNetworkInterface"`
// SSHKeys is the SSH pub keys that will be used to access virtual service instance
// SSHKeys []*string `json:"sshKeys,omitempty"`
// UserDataSecret holds reference to a secret which containes Instance Ignition data (User Data)
UserDataSecret *corev1.LocalObjectReference `json:"userDataSecret"`
// CredentialsSecret is a reference to the secret with IBM Cloud credentials.
CredentialsSecret *corev1.LocalObjectReference `json:"credentialsSecret"`
}

solution

  1. add NetworkInterfaces []NetworkInterface to IBMCloudMachineProviderSpec struct.
  2. add AllowIfSpoofing bool to NetworkInterface struct
  3. parse NetworkInterfaces from IBMCloudMachineProviderSpec to vpcv1.InstancePrototype at InstanceCreate function.
  4. update machine.Status.Addresses of NetworkInterfaces at reconcileMachineWithCloudState function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.