nova-resize does not resize swap disk

Bug #1244222 reported by JuanFra Rodriguez Cardoso
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Thang Pham

Bug Description

Hi:

During resizing operation of an instance, its swap disk is not resized to target flavor.

OS: CentOS
Hypervisor: KVM
Nova release: Grizzly 2013.1.3

Steps:

  1) Launch instance with flavor (1 VCPU | 1GB RAM | 20GB DISK | 512MB SWAP)
  2) Resize instance to new flavor (2 VCPU | 2GB RAM | 40GB DISK | 1024MB SWAP)
  3) New request is scheduled.
  4) Nova creates new instance with bigger vcpu, ram and root disk succesfully.
  4) Swap disk is not resized. New flavored instance keeps the same 512MB disk instead of the new 1024MB disk.

Regards,
JuanFra

Tags: resize swap
Revision history for this message
Tiago Mello (timello) wrote :

Can you provide more details... which hypervisor.... maybe some steps to reproduce...

Changed in nova:
status: New → Incomplete
description: updated
Changed in nova:
status: Incomplete → New
description: updated
description: updated
description: updated
description: updated
Thang Pham (thang-pham)
Changed in nova:
status: New → Confirmed
Thang Pham (thang-pham)
Changed in nova:
assignee: nobody → Thang Pham (thang-pham)
Revision history for this message
Thang Pham (thang-pham) wrote :

There are a few ways to extend the swap partition:
1. Create a new swap partition
2. Create a new swap file
3. Extend swap on an existing LVM2 logical volume

When you resize an instance, it is powered off and the root and ephemeral disks are resized (not swap). You can only add more space to the swap partition using one of the methods above, but not resize one that already exists. Hence, nova does not attempt to resize swap (i.e. disk.swap).

It can be easily fixed by deleting the disk.swap in driver.finish_migration and allowing nova to re-create disk.swap in driver._create_image. This seems valid because when an OS is shut down, the contents of the swap space are just garbage, the OS doesn't bother about what is in it.

Thang Pham (thang-pham)
Changed in nova:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/82201

Thang Pham (thang-pham)
Changed in nova:
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/82201
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=400f3705264904ac266c748b4ba2bb44fa172b2c
Submitter: Jenkins
Branch: master

commit 400f3705264904ac266c748b4ba2bb44fa172b2c
Author: Thang Pham <email address hidden>
Date: Fri Mar 21 16:34:48 2014 -0400

    Enabled swap disk to be resized when resizing instance.

    When you resize an instance, it is powered off and the root and
    ephemeral disks are resized (not swap). Swap is not resized
    because it is a partition. To allow the swap disk to be resized,
    we have to delete it and re-create it with the correct size.
    We do not care about the contents of the swap disk because
    when an instance is shut down, the contents of the swap space
    are just garbage, the OS doesn't bother about what is in it.

    Change-Id: I2bb05f01af6c97e6860dcd79a68884101a13c7d4
    Closes-Bug: #1244222

Changed in nova:
status: In Progress → Fix Committed
Changed in nova:
milestone: none → juno-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: juno-2 → 2014.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.