Bug 1278767 - parted doesnt tokenize "free" keyword when there is a warning for the partition
parted doesnt tokenize "free" keyword when there is a warning for the partition
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: parted (Show other bugs)
6.7
Unspecified Unspecified
unspecified Severity high
: rc
: ---
Assigned To: Brian Lane
Release Test Team
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-11-06 06:28 EST by nikhil
Modified: 2015-11-09 17:43 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-11-06 11:50:47 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description nikhil 2015-11-06 06:28:22 EST
Description of problem:
parted doesnt tokenize "free" keyword when there is a warning for the partition. 
Example of issue faced

[root@slab290vm4 omc]# parted /dev/disk/by-path/pci-0000:03:00.0-scsi-0:0:8:0 unit MB print free
Warning: Not all of the space available to /dev/sde appears to be used, you can fix the GPT to use all of the space (an extra 20971520 blocks) or continue with the
current setting?
parted: invalid token: free

Why is free an invalid token ? its valid if there is no warning associated with the partition.

[root@nkshirsa nkshirsa]# parted /dev/sda unit MB print free
Model: ATA SAMSUNG MZ7TE256 (scsi)
Disk /dev/sda: 256061MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start     End       Size      Type     File system  Flags
        0.03MB    1.05MB    1.02MB             Free Space
 1      1.05MB    3222MB    3221MB    primary  ext4         boot
 2      3222MB    256060MB  252838MB  primary
        256060MB  256061MB  0.35MB             Free Space


Version-Release number of selected component (if applicable):



[root@slab290vm4 omc]# rpm -qa | grep parted
parted-2.1-29.el6.x86_64


[root@slab290vm4 omc]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.7 (Santiago)
How reproducible:


Steps to Reproduce:
1. run parted with "free" or possible any other supported token for a partition which has some warning associate with it, for instance, Warning: Not all of the space a appears to be used, or in case there is no backup partition table stored at the end of the disk.

current setting?

Actual results:


Expected results:
parted should not claim free is an invalid token even if there is an associated warning for the partition.

Additional info:
I also would like a feature to suppress warnings in parted, in case the user tries to automate parted using the -s switch, the warnings require intervention and defeat the automation..


[root@sprintlab423vm4 ~]# /sbin/parted -s /dev/disk/by-path/pci-0000:03:00.0-scsi-0:0:2:0 mkpart primary 65927MB 68075MB
Error: The backup GPT table is not at the end of the disk, as it should be.  This might mean that another operating system believes the disk is smaller.  Fix, by moving the backup to the end (and removing the old backup)?
Warning: Not all of the space available to /dev/sdc appears to be used, you can fix the GPT to use all of the space (an extra 4194304 blocks) or continue with the current setting?
Error: Unable to satisfy all constraints on the partition.  <--------
Comment 3 Brian Lane 2015-11-06 11:50:47 EST
You need to pass -s on the cmdline when using multiple commands. Also note that you are still prompted to fix/ignore when this happens.
Comment 5 nikhil 2015-11-08 23:20:58 EST
is there also a way to suppress the parted warnings that break the automation ? 

for instance, as soon as there is a warning and parted expected ignore/fix responses, the automation breaks.. how do we supress this warning to always ignore?
Comment 6 Brian Lane 2015-11-09 17:43:11 EST
parted reads the commands from the cmdline as needed, the warning interrupts this and when not using -s it is processed as an invalid response.

You cannot suppress the warnings, and even if you could you wouldn't want to -- you'd end up losing data or with unexpected results. When -s is used any error or warning fails safe, preventing data loss.

If you are going to automate things by scripting with parted you need to use -s and check parted's return code.

Note You need to log in before you can comment on or make changes to this bug.