Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1321675 - CFME log_rotate_freespace_check.sh could awk on wrong field if filesystem name is long and wraps during df
CFME log_rotate_freespace_check.sh could awk on wrong field if filesystem nam...
Status: CLOSED ERRATA
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Appliance (Show other bugs)
5.6.0
Unspecified Unspecified
high Severity high
: GA
: 5.6.0
Assigned To: Nick Carboni
luke couzens
:
Depends On: 1294991
Blocks:
  Show dependency treegraph
 
Reported: 2016-03-28 16:54 EDT by Douglas Jones
Modified: 2016-07-12 11:20 EDT (History)
8 users (show)

See Also:
Fixed In Version: 5.6.0.6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-06-29 11:45:25 EDT
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)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:1348 normal SHIPPED_LIVE CFME 5.6.0 bug fixes and enhancement update 2016-06-29 14:50:04 EDT

  None (edit)
Description Douglas Jones 2016-03-28 16:54:07 EDT
Description of problem: It was discovered that our postgresql.log file in our test environment contained data from the past year and was not being rotated.  Was linked to BZ 1294991 as a possible cause of the problem.  

The proposed solution of updating logrotate_free_space_check.sh to change:
  logvol_free_space=`df -lk $file | awk '{ print $3 }' | tail -n 1`

to awk on $4 instead of $3, is correct in gathering the correct field for free space.  However, because of wrapping on a df output with a filesystem with a longer path, it can cause the wrapped output to awk on the wrong field.


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


How reproducible:


Steps to Reproduce:
1. df -lk <file on filesystem with long name that forces a wrap> 
  example:
    df -lk /opt/rh/postgresql92/root/var/lib/pgsql/data/pg_log/postgresql.log 
      Filesystem           1K-blocks     Used Available Use% Mounted on
      /dev/mapper/vg_data-lv_pg
                           102176096 24228016  72758540  25% 
2. df -lk <file on filesystem with long name that forces a wrap> | awk '{ print $4 }'
3. in this case, field 3 would be the correct free space.

Actual results:


Expected results:


Additional info: My suggestion would be to use the "-P" flag with df to force the POSIX output format and output with no wrapping.

 example:

  df -Plk /opt/rh/postgresql92/root/var/lib/pgsql/data/pg_log/postgresql.log 
  Filesystem                1024-blocks     Used Available Capacity Mounted on
  /dev/mapper/vg_data-lv_pg   102176096 24228056  72758500      25% /opt/rh/postgresql92/root/var/lib/pgsql/data

Suggested change:
  logvol_free_space=`df -Plk $file | awk '{ print $4 }' | tail -n 1`
Comment 2 Nick Carboni 2016-04-21 14:57:59 EDT
This wrapping behavior no longer happens as of GNU coreutils version 8.10 (we run 8.22 in 5.6) so this is not an issue on current appliances.

I am for reclassifying this as refactoring to clean up how that command is run to make what we are doing more explicit though.  Maybe:

df -lk --output=avail <filename> | tail -n 1

This way it is more explicit with df and can drop the awk because there will be no extraneous whitespace.
Comment 4 Nandini Chandra 2016-05-06 17:23:13 EDT
This issue occurs in 5.5 as well.

Can this BZ be cloned to 5.5?

Also, https://bugzilla.redhat.com/show_bug.cgi?id=1294991 needs to be cloned to 5.5 as well.
Comment 5 CFME Bot 2016-05-09 17:36:11 EDT
New commit detected on ManageIQ/manageiq-appliance/master:
https://github.com/ManageIQ/manageiq-appliance/commit/4eab5bc5e64d1bb24f6ee669dabef4795a4df398

commit 4eab5bc5e64d1bb24f6ee669dabef4795a4df398
Author:     Nick Carboni <ncarboni@redhat.com>
AuthorDate: Thu Apr 21 15:09:06 2016 -0400
Commit:     Nick Carboni <ncarboni@redhat.com>
CommitDate: Thu Apr 21 15:09:06 2016 -0400

    Use reliable output formatting in df
    
    This avoids dealing with column counts and is more explicit about
    the value we are looking for.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1321675

 logrotate_free_space_check.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 6 Nick Carboni 2016-05-10 08:50:22 EDT
This should not be an issue in 5.5. The fix made here is strictly an enhancement to make the intention of the script more clear and less error prone in the future.

As I said in comment 2 (https://bugzilla.redhat.com/show_bug.cgi?id=1321675#c2) this wrapping behavior is no longer seen in the version of coreutils shipped with RHEL 7, but would have been an issue in 5.3 (where this bug was reported).

I'm not sure a clone is necessary for this issue, but it is no trouble if you really think we need it.
Comment 7 Nandini Chandra 2016-05-10 14:48:49 EDT
Nick,

On one of me 5.5 appliances, evm.log failed to rotate and I was told that this bug and bug 1294991 would have to be backported to 5.5.z.

If this issue doesn't impact coreutils shipped with RHEL 7 and hence CFME 5.5, cloning this bug to 5.5.z is not necessary.
Comment 8 luke couzens 2016-05-13 11:41:28 EDT
Verified in 5.6.0.6
Comment 10 errata-xmlrpc 2016-06-29 11:45:25 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2016:1348

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