cc_growpart broken if parted resizefs found

Bug #1212492 reported by Scott Moser
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Won't Fix
Medium
Unassigned
cloud-init (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

As reported in bug 1212444, the partition growing is broken if growpart is found to be usable.
There are 2 things that are broken,
 a.) we invoke parted wrong (passing device after 'resizepart' rather than before)
 b.) parted seems somewhat broken, and I dont know how to force it to do what we want. See:

$ sudo parted /dev/vda resizepart --script 1 </dev/null; echo $?
Warning: Partition /dev/vda1 is being used. Are you sure you want to continue?
1

Um... yes, parted, i want you to do what I told you to do.

Related bugs:
 * bug 1212444: cc_growpart failed in auto grow mode with "Error: Could not stat device resizepart - No such file or directory." with parted 2.3-14
 * bug 1270203: [parted] no way to use resizepart non-interactively on busy partition

Tags: cloud-images

Related branches

Scott Moser (smoser)
Changed in cloud-init:
status: New → Confirmed
Changed in cloud-init (Ubuntu):
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Scott Moser (smoser) wrote :

So it looks like we need some way to specify '--force' to parted. The use case we have is known to have 'in use' partition that we're trying to grow.

Revision history for this message
Phillip Susi (psusi) wrote :

 Currently the only way to have parted resize a busy partition is to use interactive mode rather than script mode and say yes at the prompt.

Revision history for this message
Scott Moser (smoser) wrote :

Phillip,
  I guess that basically means I can't use this. :-(
  It also seems generally broken as the primary reason for 'resizepart' is to allow modifying a busy partition table and telling the kernel about it.

  Any ideas on how to proceed? Should I file a bug/feature request upstream by sending mail to bug-parted mailing list ?
  It looks like this has been raised before at http://lists.gnu.org/archive/html/bug-parted/2008-02/msg00019.html .

Revision history for this message
Phillip Susi (psusi) wrote :

You have to not use --script and parse the output for the warning and answer yes. I have been mulling over a --force-things system to allow a script to specify that it expects a specific error and how it should be handled but it isn't easy the way libparted is structured.

Scott Moser (smoser)
description: updated
Revision history for this message
Scott Moser (smoser) wrote :

I dont think i follow what you meant by "parse the output for the warning and answer yes".

Example:
$ echo "1,1000,L" | sudo sfdisk /dev/vdb
$ grep "vdb" /proc/partitions
 253 16 20971520 vdb
 253 17 504000 vdb1
$ sudo mkfs /dev/vdb1
$ sudo mount /dev/vdb1 /mnt

## now /dev/vdb is busy (mounted) try to resizepart on it.

$ sudo parted /dev/vdb resizepart 1 </dev/null
Warning: Partition /dev/vdb1 is being used. Are you sure you want to continue?
$ echo $?
1

# so that didn't resize (reading from /dev/null). Not surprising.
# try with 'Yes' to stdin.
echo "Yes" | sudo parted /dev/vdb resizepart 1; echo $?
Warning: Partition /dev/vdb1 is being used. Are you sure you want to continue?
1

I also failed in an attempt with 'expect', but not sure thats relevant as I dont want to use expect anyway, and I might have done something wrong.

Revision history for this message
Phillip Susi (psusi) wrote :

IIRC, parted assumes --script mode when stdin is not a tty. There was an undocumented switch that the test suite uses to override this, or I thought that expect allocates a pseudo tty (might need a switch) and that should also do the trick.

Revision history for this message
Scott Moser (smoser) wrote :

I'm not using '--script' above. It seems to make no difference in my testing.
Thus the test with 'expect' to try to trick it into using a tty and feed it info that way.

Revision history for this message
Scott Moser (smoser) wrote :

Ok.
  I'm not even sure if resizepart can be made to work, at all.

$ parted --help | grep resizepart
  resizepart NUMBER END resize partition NUMBER

the END seems to be in MB, which is insufficient for my needs. I'd like it to grow it to the next partition.
There isn't a way to just say "make it as big as possible".

The undocumented flag for --script is '---pretend-input-tty', but I can't even seem to make that work.

It just seems to ignore things like this:

$ echo "Yes" | sudo parted ---pretend-input-tty /dev/vdb resizepart 1 1000 --machine --script
Warning: Shrinking a partition can cause data loss, are you sure you want to continue?
$ echo $?
0

but it doesn't shrink the partition table

I'm going to remove the support for parted from cloud-init entirely.

Scott Moser (smoser)
Changed in cloud-init:
status: Confirmed → Won't Fix
Changed in cloud-init (Ubuntu):
status: Confirmed → Won't Fix
no longer affects: parted (Ubuntu)
Scott Moser (smoser)
description: updated
Revision history for this message
Phillip Susi (psusi) wrote :

You don't use ---pretend-input-tty in conjunction with --script. The point is to pretend that you are a human, not a script.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cloud-init - 0.7.5~bzr933-0ubuntu1

---------------
cloud-init (0.7.5~bzr933-0ubuntu1) trusty; urgency=medium

  * debian/control: bump Standards-Version to 3.9.5
  * debian/control: drop boto dependency no longer required in trunk.
  * New upstream snapshot.
    * ConfigDrive: consider partitions labelled correctly as possible sources.
    * find root filesystem for resizing in cases where there is no initramfs
    * removal of dependency on python-boto
    * vendor-data support, and usage of that in Joyent datasource.
    * change default output to be logged to /var/log/cloud-init-output.log
    * SeLinuxGuard: Cast file path to string. (LP: #1260072)
    * drop support for resizing via parted (LP: #1212492)
    * SmartOS: changes to address changes in platform (LP: #1272115)
    * FreeBSD support.
 -- Scott Moser <email address hidden> Fri, 24 Jan 2014 22:41:57 -0500

Changed in cloud-init (Ubuntu):
status: Won't Fix → Fix Released
Revision history for this message
James Falcon (falcojr) wrote :
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.