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 7554aaa
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions linode/instance/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,9 +754,23 @@ 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
tflog.Info(ctx, "Cold migration selected: shutting down instance before resize")
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
tflog.Info(ctx, "Warm migration selected: instance will resize while running")
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 7554aaa

Please sign in to comment.