Bug 1321675 - CFME log_rotate_freespace_check.sh could awk on wrong field if filesystem name is long and wraps during df
Summary: CFME log_rotate_freespace_check.sh could awk on wrong field if filesystem nam...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Appliance
Version: 5.6.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: GA
: 5.6.0
Assignee: Nick Carboni
QA Contact: luke couzens
URL:
Whiteboard:
Depends On: 1294991
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-03-28 20:54 UTC by Douglas Jones
Modified: 2016-07-12 15:20 UTC (History)
8 users (show)

Fixed In Version: 5.6.0.6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-06-29 15:45:25 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1294991 0 high CLOSED CFME log_rotate_freespace_check.sh uses wrong value to determine volume freespace causing logrotate to fail 2021-02-22 00:41:40 UTC
Red Hat Product Errata RHBA-2016:1348 0 normal SHIPPED_LIVE CFME 5.6.0 bug fixes and enhancement update 2016-06-29 18:50:04 UTC

Internal Links: 1294991

Description Douglas Jones 2016-03-28 20:54:07 UTC
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 18:57:59 UTC
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 21:23:13 UTC
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 21:36:11 UTC
New commit detected on ManageIQ/manageiq-appliance/master:
https://github.com/ManageIQ/manageiq-appliance/commit/4eab5bc5e64d1bb24f6ee669dabef4795a4df398

commit 4eab5bc5e64d1bb24f6ee669dabef4795a4df398
Author:     Nick Carboni <ncarboni>
AuthorDate: Thu Apr 21 15:09:06 2016 -0400
Commit:     Nick Carboni <ncarboni>
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 12:50:22 UTC
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 18:48:49 UTC
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 15:41:28 UTC
Verified in 5.6.0.6

Comment 10 errata-xmlrpc 2016-06-29 15:45:25 UTC
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.