Skip to content

Commit

Permalink
Merge branch 'main' into proj/multicluster-obj
Browse files Browse the repository at this point in the history
  • Loading branch information
zliang-akamai committed Jun 20, 2024
2 parents 6a9a646 + 5ef1b79 commit 60c3e41
Show file tree
Hide file tree
Showing 130 changed files with 23,100 additions and 16,050 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ jobs:
python tod_scripts/test_report_upload_script.py "$REPORT_FILENAME"
env:
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
15 changes: 15 additions & 0 deletions .github/workflows/integration_tests_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ jobs:
with:
ref: ${{ inputs.sha }}

- name: Download kubectl and calicoctl for LKE clusters
run: |
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
curl -LO "https://github.com/projectcalico/calico/releases/download/v3.25.0/calicoctl-linux-amd64"
chmod +x calicoctl-linux-amd64 kubectl
mv calicoctl-linux-amd64 /usr/local/bin/calicoctl
mv kubectl /usr/local/bin/kubectl
- run: make ARGS="-run ${{ inputs.module }}" fixtures
if: ${{ inputs.module != '' && steps.disallowed-char-check.outputs.match == '' }}
env:
Expand All @@ -44,6 +52,13 @@ jobs:
if: ${{ inputs.module == '' }}
env:
LINODE_TOKEN: ${{ secrets.DX_LINODE_TOKEN }}

- name: Apply Calico Rules to LKE
if: always()
run: |
cd scripts && ./lke_calico_rules_e2e.sh
env:
LINODE_TOKEN: ${{ secrets.DX_LINODE_TOKEN }}

- name: Get the hash value of the latest commit from the PR branch
uses: octokit/graphql-action@v2.x
Expand Down
8 changes: 8 additions & 0 deletions account_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ const (
ActionPaymentMethodAdd EventAction = "payment_method_add"
ActionPaymentSubmitted EventAction = "payment_submitted"
ActionPasswordReset EventAction = "password_reset"
ActionPlacementGroupCreate EventAction = "placement_group_create"
ActionPlacementGroupUpdate EventAction = "placement_group_update"
ActionPlacementGroupDelete EventAction = "placement_group_delete"
ActionPlacementGroupAssign EventAction = "placement_group_assign"
ActionPlacementGroupUnassign EventAction = "placement_group_unassign"
ActionPlacementGroupBecameNonCompliant EventAction = "placement_group_became_non_compliant"
ActionPlacementGroupBecameCompliant EventAction = "placement_group_became_compliant"
ActionProfileUpdate EventAction = "profile_update"
ActionStackScriptCreate EventAction = "stackscript_create"
ActionStackScriptDelete EventAction = "stackscript_delete"
Expand Down Expand Up @@ -226,6 +233,7 @@ const (
EntityManagedService EntityType = "managed_service"
EntityNodebalancer EntityType = "nodebalancer"
EntityOAuthClient EntityType = "oauth_client"
EntityPlacementGroup EntityType = "placement_group"
EntityProfile EntityType = "profile"
EntityStackscript EntityType = "stackscript"
EntityTag EntityType = "tag"
Expand Down
8 changes: 0 additions & 8 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -1,8 +0,0 @@
cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA=
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
41 changes: 33 additions & 8 deletions instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ type Instance struct {
Specs *InstanceSpec `json:"specs"`
WatchdogEnabled bool `json:"watchdog_enabled"`
Tags []string `json:"tags"`

// NOTE: Placement Groups may not currently be available to all users.
PlacementGroup *InstancePlacementGroup `json:"placement_group"`
}

// InstanceSpec represents a linode spec
Expand Down Expand Up @@ -104,6 +107,15 @@ type InstanceTransfer struct {
Quota int `json:"quota"`
}

// InstancePlacementGroup represents information about the placement group
// this Linode is a part of.
type InstancePlacementGroup struct {
ID int `json:"id"`
Label string `json:"label"`
AffinityType PlacementGroupAffinityType `json:"affinity_type"`
IsStrict bool `json:"is_strict"`
}

// InstanceMetadataOptions specifies various Instance creation fields
// that relate to the Linode Metadata service.
type InstanceMetadataOptions struct {
Expand All @@ -130,6 +142,9 @@ type InstanceCreateOptions struct {
Metadata *InstanceMetadataOptions `json:"metadata,omitempty"`
FirewallID int `json:"firewall_id,omitempty"`

// NOTE: Placement Groups may not currently be available to all users.
PlacementGroup *InstanceCreatePlacementGroupOptions `json:"placement_group,omitempty"`

// Creation fields that need to be set explicitly false, "", or 0 use pointers
SwapSize *int `json:"swap_size,omitempty"`
Booted *bool `json:"booted,omitempty"`
Expand All @@ -138,6 +153,13 @@ type InstanceCreateOptions struct {
Group string `json:"group,omitempty"`
}

// InstanceCreatePlacementGroupOptions represents the placement group
// to create this Linode under.
type InstanceCreatePlacementGroupOptions struct {
ID int `json:"id"`
CompliantOnly *bool `json:"compliant_only,omitempty"`
}

// InstanceUpdateOptions is an options struct used when Updating an Instance
type InstanceUpdateOptions struct {
Label string `json:"label,omitempty"`
Expand Down Expand Up @@ -190,13 +212,14 @@ type InstanceCloneOptions struct {
Type string `json:"type,omitempty"`

// LinodeID is an optional existing instance to use as the target of the clone
LinodeID int `json:"linode_id,omitempty"`
Label string `json:"label,omitempty"`
BackupsEnabled bool `json:"backups_enabled"`
Disks []int `json:"disks,omitempty"`
Configs []int `json:"configs,omitempty"`
PrivateIP bool `json:"private_ip,omitempty"`
Metadata *InstanceMetadataOptions `json:"metadata,omitempty"`
LinodeID int `json:"linode_id,omitempty"`
Label string `json:"label,omitempty"`
BackupsEnabled bool `json:"backups_enabled"`
Disks []int `json:"disks,omitempty"`
Configs []int `json:"configs,omitempty"`
PrivateIP bool `json:"private_ip,omitempty"`
Metadata *InstanceMetadataOptions `json:"metadata,omitempty"`
PlacementGroup *InstanceCreatePlacementGroupOptions `json:"placement_group,omitempty"`

// Deprecated: group is a deprecated property denoting a group label for the Linode.
Group string `json:"group,omitempty"`
Expand All @@ -211,10 +234,12 @@ type InstanceResizeOptions struct {
AllowAutoDiskResize *bool `json:"allow_auto_disk_resize,omitempty"`
}

// InstanceResizeOptions is an options struct used when resizing an instance
// InstanceMigrateOptions is an options struct used when migrating an instance
type InstanceMigrateOptions struct {
Type InstanceMigrationType `json:"type,omitempty"`
Region string `json:"region,omitempty"`

PlacementGroup *InstanceCreatePlacementGroupOptions `json:"placement_group,omitempty"`
}

// InstancesPagedResponse represents a linode API response for listing
Expand Down
5 changes: 5 additions & 0 deletions lke_clusters_control_plane.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type LKEClusterControlPlaneACLAddresses struct {

// LKEClusterControlPlaneACL describes the ACL configuration
// for an LKE cluster's control plane.
// NOTE: Control Plane ACLs may not currently be available to all users.
type LKEClusterControlPlaneACL struct {
Enabled bool `json:"enabled"`
Addresses *LKEClusterControlPlaneACLAddresses `json:"addresses"`
Expand All @@ -30,6 +31,7 @@ type LKEClusterControlPlaneACLAddressesOptions struct {

// LKEClusterControlPlaneACLOptions represents the options used when
// configuring an LKE cluster's control plane ACL policy.
// NOTE: Control Plane ACLs may not currently be available to all users.
type LKEClusterControlPlaneACLOptions struct {
Enabled *bool `json:"enabled,omitempty"`
Addresses *LKEClusterControlPlaneACLAddressesOptions `json:"addresses,omitempty"`
Expand All @@ -45,6 +47,7 @@ type LKEClusterControlPlaneOptions struct {
// LKEClusterControlPlaneACLUpdateOptions represents the options
// available when updating the ACL configuration of an LKE cluster's
// control plane.
// NOTE: Control Plane ACLs may not currently be available to all users.
type LKEClusterControlPlaneACLUpdateOptions struct {
ACL LKEClusterControlPlaneACLOptions `json:"acl"`
}
Expand All @@ -57,6 +60,7 @@ type LKEClusterControlPlaneACLResponse struct {

// GetLKEClusterControlPlaneACL gets the ACL configuration for the
// given cluster's control plane.
// NOTE: Control Plane ACLs may not currently be available to all users.
func (c *Client) GetLKEClusterControlPlaneACL(ctx context.Context, clusterID int) (*LKEClusterControlPlaneACLResponse, error) {
return doGETRequest[LKEClusterControlPlaneACLResponse](
ctx,
Expand All @@ -67,6 +71,7 @@ func (c *Client) GetLKEClusterControlPlaneACL(ctx context.Context, clusterID int

// UpdateLKEClusterControlPlaneACL updates the ACL configuration for the
// given cluster's control plane.
// NOTE: Control Plane ACLs may not currently be available to all users.
func (c *Client) UpdateLKEClusterControlPlaneACL(
ctx context.Context,
clusterID int,
Expand Down
160 changes: 160 additions & 0 deletions placement_groups.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
package linodego

import "context"

// PlacementGroupAffinityType is an enum that determines the affinity policy
// for Linodes in a placement group.
type PlacementGroupAffinityType string

const (
AffinityTypeAntiAffinityLocal PlacementGroupAffinityType = "anti_affinity:local"
)

// PlacementGroupMember represents a single Linode assigned to a
// placement group.
type PlacementGroupMember struct {
LinodeID int `json:"linode_id"`
IsCompliant bool `json:"is_compliant"`
}

// PlacementGroup represents a Linode placement group.
// NOTE: Placement Groups may not currently be available to all users.
type PlacementGroup struct {
ID int `json:"id"`
Label string `json:"label"`
Region string `json:"region"`
AffinityType PlacementGroupAffinityType `json:"affinity_type"`
IsCompliant bool `json:"is_compliant"`
IsStrict bool `json:"is_strict"`
Members []PlacementGroupMember `json:"members"`
}

// PlacementGroupCreateOptions represents the options to use
// when creating a placement group.
type PlacementGroupCreateOptions struct {
Label string `json:"label"`
Region string `json:"region"`
AffinityType PlacementGroupAffinityType `json:"affinity_type"`
IsStrict bool `json:"is_strict"`
}

// PlacementGroupUpdateOptions represents the options to use
// when updating a placement group.
type PlacementGroupUpdateOptions struct {
Label string `json:"label,omitempty"`
}

// PlacementGroupAssignOptions represents options used when
// assigning Linodes to a placement group.
type PlacementGroupAssignOptions struct {
Linodes []int `json:"linodes"`
CompliantOnly *bool `json:"compliant_only,omitempty"`
}

// PlacementGroupUnAssignOptions represents options used when
// unassigning Linodes from a placement group.
type PlacementGroupUnAssignOptions struct {
Linodes []int `json:"linodes"`
}

// ListPlacementGroups lists placement groups under the current account
// matching the given list options.
// NOTE: Placement Groups may not currently be available to all users.
func (c *Client) ListPlacementGroups(
ctx context.Context,
options *ListOptions,
) ([]PlacementGroup, error) {
return getPaginatedResults[PlacementGroup](
ctx,
c,
"placement/groups",
options,
)
}

// GetPlacementGroup gets a placement group with the specified ID.
// NOTE: Placement Groups may not currently be available to all users.
func (c *Client) GetPlacementGroup(
ctx context.Context,
id int,
) (*PlacementGroup, error) {
return doGETRequest[PlacementGroup](
ctx,
c,
formatAPIPath("placement/groups/%d", id),
)
}

// CreatePlacementGroup creates a placement group with the specified options.
// NOTE: Placement Groups may not currently be available to all users.
func (c *Client) CreatePlacementGroup(
ctx context.Context,
options PlacementGroupCreateOptions,
) (*PlacementGroup, error) {
return doPOSTRequest[PlacementGroup](
ctx,
c,
"placement/groups",
options,
)
}

// UpdatePlacementGroup updates a placement group with the specified ID using the provided options.
// NOTE: Placement Groups may not currently be available to all users.
func (c *Client) UpdatePlacementGroup(
ctx context.Context,
id int,
options PlacementGroupUpdateOptions,
) (*PlacementGroup, error) {
return doPUTRequest[PlacementGroup](
ctx,
c,
formatAPIPath("placement/groups/%d", id),
options,
)
}

// AssignPlacementGroupLinodes assigns the specified Linodes to the given
// placement group.
// NOTE: Placement Groups may not currently be available to all users.
func (c *Client) AssignPlacementGroupLinodes(
ctx context.Context,
id int,
options PlacementGroupAssignOptions,
) (*PlacementGroup, error) {
return doPOSTRequest[PlacementGroup](
ctx,
c,
formatAPIPath("placement/groups/%d/assign", id),
options,
)
}

// UnassignPlacementGroupLinodes un-assigns the specified Linodes from the given
// placement group.
// NOTE: Placement Groups may not currently be available to all users.
func (c *Client) UnassignPlacementGroupLinodes(
ctx context.Context,
id int,
options PlacementGroupUnAssignOptions,
) (*PlacementGroup, error) {
return doPOSTRequest[PlacementGroup](
ctx,
c,
formatAPIPath("placement/groups/%d/unassign", id),
options,
)
}

// DeletePlacementGroup deletes a placement group with the specified ID.
// NOTE: Placement Groups may not currently be available to all users.
func (c *Client) DeletePlacementGroup(
ctx context.Context,
id int,
) error {
return doDELETERequest(
ctx,
c,
formatAPIPath("placement/groups/%d", id),
)
}
Loading

0 comments on commit 60c3e41

Please sign in to comment.