_get_capacity_info fails when using long mount names or large storage due to multi-line df output

Bug #1336238 reported by Maurice Leeflang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Fix Released
Undecided
Maurice Leeflang

Bug Description

Glance version = 0.12.0 / 2014.1

In python package /usr/lib/python2.6/site-packages/glance/store/filesystem.py
 _get_capacity_info(self, mount_point)

To determine the free space of a store, the python script executes df with option "--block-size=1", in later version (I noticed), this was changed into "-k" to work with kbytes, but in both situations, when the mountpoint name is too long, or the size is to big, the output of df will be multilined, resulting in an IndexError, because only one line is being searched for values.

Fix:
When adding the option -P (or in long form --portability), the output is Posix formatted, resulting in one line per filesystem output.

Regards,

Maurice Leeflang

Tags: filesystem
Revision history for this message
Maurice Leeflang (malicure) wrote :

diff --git a/glance/store/filesystem.py b/glance/store/filesystem.py
index 5ad67f1..6c8ce66 100644
--- a/glance/store/filesystem.py
+++ b/glance/store/filesystem.py
@@ -356,7 +356,7 @@ class Store(glance.store.base.Store):
         """

         #Calculate total available space
- df = processutils.execute("df", "-k",
+ df = processutils.execute("df", "-k","-P",
                                   mount_point)[0].strip("'\n'")
         total_available_space = int(df.split('\n')[1].split()[3]) * units.Ki

Revision history for this message
Maurice Leeflang (malicure) wrote :
Revision history for this message
Erno Kuvaja (jokke) wrote :

Well spotted,

Are you planning to submit the change for this?

Revision history for this message
Maurice Leeflang (malicure) wrote :

Sure, I'll have to check if I am permitted to do so, though

Changed in glance:
assignee: nobody → Maurice Leeflang (malicure)
Revision history for this message
Maurice Leeflang (malicure) wrote :

I took the liberty of assigning the bug to myself, but IMHO I should not confirm the bug as the reporter :)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to glance (master)

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

Changed in glance:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (master)

Reviewed: https://review.openstack.org/103952
Committed: https://git.openstack.org/cgit/openstack/glance/commit/?id=2ae01fbd68afbc84258a5aa00c8f0c8e7a2c1091
Submitter: Jenkins
Branch: master

commit 2ae01fbd68afbc84258a5aa00c8f0c8e7a2c1091
Author: Maurice Leeflang <email address hidden>
Date: Tue Jul 1 19:19:27 2014 +0200

    Added an extra parameter to the df command

    The parameter is needed to avoid multi-line output,
    which results in an IndexError,
    because only one line is being searched for values.

    Change-Id: Ie518c6a3573b7868065501a02cd0bd8565656a71
    Closes-Bug: 1336238

Changed in glance:
status: In Progress → Fix Committed
Changed in glance:
milestone: none → juno-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in glance:
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.