Skip to content

new: Add support for VM Placement#490

Merged
lgarber-akamai merged 9 commits intolinode:proj/vm-placementfrom
lgarber-akamai:new/vm-placement
Apr 16, 2024
Merged

new: Add support for VM Placement#490
lgarber-akamai merged 9 commits intolinode:proj/vm-placementfrom
lgarber-akamai:new/vm-placement

Conversation

@lgarber-akamai
Copy link
Contributor

@lgarber-akamai lgarber-akamai commented Apr 11, 2024

📝 Description

This pull request adds support for the upcoming Placement Groups feature, including the following changes:

  • New Endpoints:

    • POST placement/groups
    • GET placement/groups
    • GET placement/groups/{pg_id}
    • PUT placement/groups/{pg_id}
    • POST placement/groups/{pg_id}/assign
    • POST placement/groups/{pg_id}/unassign
    • DELETE placement/groups/{pg_id}
  • Updated Endpoints:

    • GET /linode/instances & /linode/instances/{linode_id} - Updated to include PG info
    • POST /linode/instances - Updated to accept a PG to assign the Linode to on creation
    • POST /linode/instances/{linode_id}/migrate - Updated to accept a PG to assign the Linode to on creation
    • POST /linode/instances/{linode_id}/clone - Updated to accept a PG to assign the Linode to on creation
    • GET /regions & /regions/{region_id} - Updated to include PG limits

This pull request also contains the corresponding integration tests and fixtures for these changes.

✔️ How to Test

The following test steps assume you have pulled down this PR locally and have pointed your LINODE_URL and LINODE_TOKEN environment variables accordingly.

Integration Testing

make ARGS="-run TestInstance" fixtures
make ARGS="-run TestPlacementGroup" fixtures
make ARGS="-run TestRegion" fixtures

Manual Testing

  1. In a linodego sandbox environment, run the following:
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/linode/linodego"
)

const targetRegion = "eu-west"

func main() {
	ctx := context.Background()

	client := linodego.NewClient(nil)
	client.SetToken(os.Getenv("LINODE_TOKEN"))

	// Create a PG
	pg, err := client.CreatePlacementGroup(ctx, linodego.PlacementGroupCreateOptions{
		Label:        "test-pg",
		Region:       targetRegion,
		AffinityType: linodego.AffinityTypeAntiAffinityLocal,
		IsStrict:     true,
	})
	if err != nil {
		log.Fatal(err)
	}

	// Provision two instances assigned to the PG
	compliantOnly := true

	for i := 0; i < 2; i++ {
		_, err := client.CreateInstance(ctx, linodego.InstanceCreateOptions{
			Region: targetRegion,
			Type:   "g6-nanode-1",
			Label:  fmt.Sprintf("test-instance-%d", i),
			PlacementGroup: &linodego.InstanceCreatePlacementGroupOptions{
				ID:            pg.ID,
				CompliantOnly: &compliantOnly,
			},
		})
		if err != nil {
			log.Fatal(err)
		}
	}
}
  1. Navigate to Cloud Manager and ensure a new Placement Group has been created with two instances assigned to it.
  2. Modify this code with update logic, assignment logic, etc.
  3. Re-run the file and ensure everything works as expected.

@lgarber-akamai lgarber-akamai added improvement for improvements in existing functionality in the changelog. new-feature for new features in the changelog. labels Apr 11, 2024
@lgarber-akamai lgarber-akamai marked this pull request as ready for review April 11, 2024 19:36
@lgarber-akamai lgarber-akamai requested a review from a team as a code owner April 11, 2024 19:36
@lgarber-akamai lgarber-akamai requested review from yec-akamai and ykim-akamai and removed request for a team April 11, 2024 19:36
github.com/jarcoal/httpmock v1.3.1
github.com/linode/linodego v1.30.0
github.com/linode/linodego/k8s v0.0.0-00010101000000-000000000000
github.com/stretchr/testify v1.9.0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added in the parent/child project branch (which hasn't been merged to main yet)

Copy link
Contributor

@yec-akamai yec-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! All tests passed on my end 🎉

Copy link
Contributor

@ykim-akamai ykim-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, tests pass locally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement for improvements in existing functionality in the changelog. new-feature for new features in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants