Bug 1109935 - rhc show <appname> --gear quota and ssh'ed quota -s show different results
Summary: rhc show <appname> --gear quota and ssh'ed quota -s show different results
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: OpenShift Online
Classification: Red Hat
Component: oc
Version: 2.x
Hardware: All
OS: All
unspecified
high
Target Milestone: ---
: 2.x
Assignee: Sally
QA Contact: libra bugs
URL:
Whiteboard:
: 1273140 (view as bug list)
Depends On:
Blocks: 1277547 1310810
TreeView+ depends on / blocked
 
Reported: 2014-06-16 16:39 UTC by Nick Harvey
Modified: 2019-09-12 07:54 UTC (History)
14 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1310810 (view as bug list)
Environment:
Last Closed: 2017-05-31 18:22:11 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1329053 0 medium CLOSED rhc-1.38.6 is not provided by rvm 2021-02-22 00:41:40 UTC

Internal Links: 1329053

Description Nick Harvey 2014-06-16 16:39:14 UTC
Description of problem: When a user runs "rhc app show <appname> --gear quota" and then ssh into the application and run quota -s, different results will be shown. 

rhc app show devcenter2 --gear quota 
Gear                     Cartridges             Used Limit
------------------------ -------------------- ------ -----
53970fda5973ca16040001c9 haproxy-1.4 ruby-1.9 189 MB  1 GB
➜  ~  rhc ssh devcenter2
Connecting to 53970fda5973ca16040001c9.com ...

    *********************************************************************

    You are accessing a service that is for use only by authorized users.
    If you do not have authorization, discontinue use at once.
    Any use of the services is subject to the applicable terms of the
    agreement which can be found at:
    https://www.openshift.com/legal

    *********************************************************************

    Welcome to OpenShift shell

    This shell will assist you in managing OpenShift applications.

    !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!
    Shell access is quite powerful and it is possible for you to
    accidentally damage your application.  Proceed with care!
    If worse comes to worst, destroy your application with "rhc app delete"
    and recreate it
    !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!

    Type "help" for more info.


    ***  This gear has been temporarily unidled. To keep it active, access
    ***  your app @ http://devcenter2-niharvey.rhcloud.com/

[devcenter2-niharvey.rhcloud.com 53970fda5973ca16040001c9]\> quota -s
Disk quotas for user 53970fda5973ca16040001c9 (uid 4640): 
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
/dev/mapper/EBSStore01-user_home01
                   180M       0   1024M           14646       0   80000 


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


How reproducible:


Steps to Reproduce:
1. rhc app show <Appname> --gear quota
2. ssh into app
3. run quota -s 
4. compare results

Actual results:
amount of reported space used will be different. 

Expected results:


Additional info:
Looks like this might be a dup of 992942, however this one is closed. 
Also, my rhc version is 1.25.3

Comment 1 Rajat Chopra 2014-06-16 22:05:45 UTC
Its divide by 1024 vs 1000 error.

in this line : 
https://github.com/openshift/rhc/blob/master/lib/rhc/helpers.rb#L46
in function human_size(),
called from https://github.com/openshift/rhc/blob/master/lib/rhc/commands/app.rb#L397

If the code has to use 'PREFIX = %W(TB GB MB KB B).freeze' on L38, then L46 should be definitely be fixed.

Comment 2 Jordan Liggitt 2014-06-17 14:21:18 UTC
Will merge in https://github.com/openshift/rhc/pull/605

Comment 3 Jordan Liggitt 2014-06-18 15:24:04 UTC
Actually, after looking at it more, I think we'll cantfix this. Some remote systems divide by 1000 for 'quota -s', some divide by 1024. Whichever we pick, we'll be inconsistent some of the time.

RHC will divide by 1000 for both quota and usage.

Comment 4 sobakieko 2014-06-18 17:31:37 UTC
(In reply to Rajat Chopra from comment #1)
> Its divide by 1024 vs 1000 error.
> 
> in this line : 
> https://github.com/openshift/rhc/blob/master/lib/rhc/helpers.rb#L46
> in function human_size(),
> called from
> https://github.com/openshift/rhc/blob/master/lib/rhc/commands/app.rb#L397
> 
> If the code has to use 'PREFIX = %W(TB GB MB KB B).freeze' on L38, then L46
> should be definitely be fixed.

Hi,

I'm the one who filed the bug initially (via e-mail).

I should have made it perhaps a bit more clear. This is not (necessarily) a division error. 

My "rhc app show PHP --gear quota" shows 325 MB is in use 1 GB, yet "rhc app tidy <gearname>" shows I'm above 90% of quota. 

At the same time "quota -s" shows 927M out of 1024M but "du -ms ." issued from home directory gives 311, which (along with 325 above) is consistent with what I use.

Honestly I don't care too much of the minor Mb/Gb rounding issues, but the gear just fails when I get supposedly over quota, which in fact is not true.

Comment 5 Jordan Liggitt 2014-06-18 17:35:12 UTC
Gotcha, thanks for the additional info. Reopening to look into the big difference between "du -sh" and "quota -s" run on the gear itself.

Comment 6 Jordan Liggitt 2014-06-18 17:37:22 UTC
Can you provide the login, app, and gear id you are seeing the discrepancy on?

Comment 8 Jhon Honce 2014-06-18 18:06:52 UTC
$(rhc quota) needs to use unix quota command not du, to meet expected results.

Comment 10 sobakieko 2014-06-20 23:55:33 UTC
Whatever's been done (if anything) - it worked.

quota -s correctly shows the amount of used space and that's almost consistent with 

rhc app show <gearname> --gear quota

and with du comamnd. 

'almost consistent' - being quota -s shows 297M, (at least not 950M as before), whereas rhc app show <gearname> --gear quota shows 327 MB. du -ms comes second - 313M :)

Comment 11 sobakieko 2014-07-01 21:14:04 UTC
Sure enough, it did not last. 

While rhc shows:

Gear  Cartridges                                Used Limit
----- --------------------------------------- ------ -----
***** php-5.3 mysql-5.1 phpmyadmin-4 cron-1.4 389 MB  1 GB



quota -s shows: 

     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
/dev/mapper/EBSStore01-user_home01
                   581M       0   1024M            4040       0   80000

Comment 12 Jordan Liggitt 2014-07-11 13:42:11 UTC
RHC is measuring usage of accessible files in the home directory, which is not the same as what the quota tool looks at. Will re-raise to ops team to check.

Comment 13 mike 2015-10-21 22:40:54 UTC
hi, got same issue. Seems like a year after but still unresolved?

Comment 14 mike 2015-10-21 22:46:54 UTC
can someone explain definition "which is not the same as what the quota tool looks at"
To where it looks at if not to the physical file usage?


see my results:
[diy-exch.rhcloud.com 55e3779b89f5cf236f000081]\> quota -w|egrep -v '(quotas|Filesystem)'|awk -F ' ' '{ print $2}'
538652
[diy-exch.rhcloud.com 55e3779b89f5cf236f000081]\> du -sh
du: cannot read directory `./.tmp': Permission denied
du: cannot read directory `./.sandbox': Permission denied
du: cannot read directory `./.ssh': Permission denied
527M    .

M:>rhc show-app diy --gears quota
Gear                     Cartridges                                           Used Limit
------------------------ ---------------------------------------------------- ------ -----
55e3779b89f5cf236f000081 diy-0.1 cron-1.4 mongodb-2.4 mmahut-quotamonitor-1.0 0.6 GB  1 GB

When My app works about 10 hours quota show that I am out of space and in the same time physically I am using around half of quota size

Comment 16 Sally 2016-01-20 20:41:51 UTC
Indeed, it is confusing that we use 'du' instead of 'quota' here:
https://github.com/openshift/rhc/blob/master/lib/rhc/commands/app.rb#L428

One source of confusion:
'quota' cmd includes usage from files that have been deleted but their data blocks are still being held by some process in the gear...
so in fact, quota gives a more accurate view of usage.

I am formulating a PR to replace 'du' with 'quota' to give more accurate quota info.  

In the meantime, this command will give you the 'quota' info you need:

rhc ssh app --gears quota

If the usage is more than you expect (if it varies from du), try re-starting your app and running it again to see if that clears some ghost data blocks.

Comment 17 Timothy Williams 2016-01-20 20:56:59 UTC
*** Bug 1273140 has been marked as a duplicate of this bug. ***

Comment 18 openshift-github-bot 2016-01-28 15:24:02 UTC
Commit pushed to master at https://github.com/openshift/rhc

https://github.com/openshift/rhc/commit/3499f13889650461874451e4128f8ceac4e06d5a
'rhc app show <app> --gears quota' use 'quota' not 'du'

Bug 1109935
Bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=1109935

Users expect 'rhc app show <app> --gears quota' to display output of the system 'quota' cmd.
Currently, the rhc cmd uses 'du -s'.  This PR replaces 'du' with 'quota'

Comment 19 Wei Sun 2016-02-01 06:37:33 UTC
Verified this bug with 
> rhc --version
rhc 1.38.4


Result:
# rhc app-show phptest --gears quota
Gear                     Cartridges Used Limit
------------------------ ---------- ---- -----
56aefbc2db11e4c989000009 php-5.3    1 MB  1 GB

# rhc ssh phptest
Connecting to 56aefbc2db11e4c989000009.rhcloud.com ...

    *********************************************************************

    You are accessing a service that is for use only by authorized users.
    If you do not have authorization, discontinue use at once.
    Any use of the services is subject to the applicable terms of the
    agreement which can be found at:
    https://www.openshift.com/legal

    *********************************************************************

    Welcome to OpenShift shell

    This shell will assist you in managing OpenShift applications.

    !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!
    Shell access is quite powerful and it is possible for you to
    accidentally damage your application.  Proceed with care!
    If worse comes to worst, destroy your application with "rhc app delete"
    and recreate it
    !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!

    Type "help" for more info.


[phptest-wsundev.dev.rhcloud.com 56aefbc2db11e4c989000009]\> quota -s
Disk quotas for user 56aefbc2db11e4c989000009 (uid 1000): 
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
     /dev/xvda1    1016       0   1024M             224       0   80000

Comment 20 Anping Li 2016-02-26 07:20:59 UTC
The rhc is using size from quota. so move bug to verified.

[sphp-anlidom.ose22-auto.com.cn /]\> du -sh
<---snip---->
<---snip---->
3.6G	.
[sphp-anlidom.ose22-auto.com.cn /]\> quota -s
Disk quotas for user anlidom-sphp-1 (uid 1068): 
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
     /dev/loop0    1504       0   1024M             324       0   80000        
[sphp-anlidom.ose22-auto.com.cn /]\> exit
exit
Connection to sphp-anlidom.ose22-auto.com.cn closed.
[anli@broker ~]$ rhc app show sphp --gear quota
Gear           Cartridges            Used Limit
-------------- ------------------- ------ -----
anlidom-sphp-1 haproxy-1.4 php-5.3 1.5 MB  1 GB

Comment 21 Eric Paris 2017-05-31 18:22:11 UTC
We apologize, however, we do not plan to address this report at this time. The majority of our active development is for the v3 version of OpenShift. If you would like for Red Hat to reconsider this decision, please reach out to your support representative. We are very sorry for any inconvenience this may cause.


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