Skip to content

Commit

Permalink
Differentiate between migration types for instance resize
Browse files Browse the repository at this point in the history
  • Loading branch information
ezilber-akamai committed Jan 16, 2025
1 parent d588e28 commit 90f1bd6
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions linode/instance/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,9 +754,21 @@ func changeInstanceType(
diskResize bool,
d *schema.ResourceData,
) (*linodego.Instance, error) {
instance, err := ensureInstanceOffline(ctx, client, instanceID, getDeadlineSeconds(ctx, d))
if err != nil {
return nil, err
var err error
var instance *linodego.Instance

if migrationType == linodego.ColdMigration {
// Cold migration: Ensure instance is offline
instance, err = ensureInstanceOffline(ctx, client, instanceID, getDeadlineSeconds(ctx, d))
if err != nil {
return nil, fmt.Errorf("failed to shut down instance for cold migration: %w", err)
}
} else {
// Warm migration: Get the current instance state
instance, err = client.GetInstance(ctx, instanceID)
if err != nil {
return nil, fmt.Errorf("failed to fetch instance details for warm migration: %w", err)
}
}

var primaryDisk *linodego.InstanceDisk
Expand Down

0 comments on commit 90f1bd6

Please sign in to comment.