Bug 1044417

Summary: oo-admin-chk will be broken when checking gears with tracked additional storage in applications collection but not in usage_records
Product: OpenShift Online Reporter: zhaozhanqi <zzhao>
Component: PodAssignee: Ravi Sankar <rpenta>
Status: CLOSED CURRENTRELEASE QA Contact: libra bugs <libra-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 2.xCC: rpenta, wsun, xtian
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-02-26 19:08:58 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description zhaozhanqi 2013-12-18 09:41:24 UTC
Description of problem:
Given one jbosseap created.Add more storage to the cartridge to make the storage more than tracked storage. After that there will be created user_record with user_type 'ADDTL_FS_GB'. if deleting this record. run 'oo-admin-chk -l 1' will be broken with errors "/usr/sbin/oo-admin-chk:798:in `block in <main>': undefined method `gears' for nil:NilClass (NoMethodError)'

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

How reproducible:
always

Steps to Reproduce:
1.create one jbosseap app
2.setup the user tracked stoage to 10G via oo-admin-ctl-user
oo-admin-ctl-user -l $user --setmaxtrackedstorage 10

3.Add more than tracked number storage to the cartridge
 rhc cartridge-storage jbosseap-6 eap --add  11GB
4. Delete the record in collection 'user_record' with user_type 'ADDTL_FS_GB'
   db.user_record.remove({"usage_type": "ADDTL_FS_GB"})
5. run 'oo-admin-chk -l 1'


Actual results:
oot@ip-10-183-145-38 openshift]# oo-admin-chk -l1
Started at: 2013-12-18 03:30:47 -0500
Time to fetch mongo data: 0.043s
Total gears found in mongo: 4
Time to get all gears from nodes: 20.763s
Total gears found on the nodes: 4
Total nodes that responded : 1
Time to get all sshkeys for all gears from nodes: 20.066s
Total gears found on the nodes: 4
Total nodes that responded : 1
/usr/sbin/oo-admin-chk:798:in `block in <main>': undefined method `gears' for nil:NilClass (NoMethodError)
	from /usr/sbin/oo-admin-chk:782:in `each'
	from /usr/sbin/oo-admin-chk:782:in `<main>'


Expected results:
no this error and should detect like 'Found addtl storage for gear Id '51b938f3c9c6fe945b000021' but could not find corresponding usage record'

Additional info:

Comment 1 Ravi Sankar 2013-12-18 19:52:41 UTC
Fixed in master https://github.com/openshift/origin-server/pull/4374

Comment 3 zhaozhanqi 2013-12-19 02:40:29 UTC
Tested this issue on devenv_4154, it did not be fixed.

if adding more storage to the cartridge to make the storage more than tracked storage and then it will be block.

1.create one jbosseap app
2.setup the user tracked stoage to 10G via oo-admin-ctl-user
oo-admin-ctl-user -l $user --setmaxtrackedstorage 10

3.Add more than tracked number storage to the cartridge
 rhc cartridge-storage jbosseap-6 eap --add  11GB
4. oo-admin-chk -l 1

oo-admin-chk -l 1
Started at: 2013-12-19 02:31:20 UTC

Total gears found in mongo: 1
Total gears found on the nodes: 1
Total nodes that responded: 1
/opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-controller-1.19.2/app/helpers/admin_helper.rb:618:in `block in find_app_storage_usage_record_inconsistencies': undefined local variable or method `usage_storage_hash' for main:Object (NameError)
	from /opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-controller-1.19.2/app/helpers/admin_helper.rb:617:in `each'
	from /opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-controller-1.19.2/app/helpers/admin_helper.rb:617:in `find_app_storage_usage_record_inconsistencies'
	from /usr/sbin/oo-admin-chk:172:in `<main>'

Comment 4 Ravi Sankar 2013-12-19 23:40:38 UTC
Fixed in https://github.com/openshift/origin-server/pull/4385

Comment 5 openshift-github-bot 2013-12-20 06:00:28 UTC
Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/5054bd1b21fe1b81596d6dbf412fe4885cfd69a5
Bug 1044417 - Fix storage inconsistencies in oo-admin-chk

Comment 6 zhaozhanqi 2013-12-20 11:31:27 UTC
Check this bug on devenv_4162, it has been fixed.


1.create one jbosseap app
2.setup the user tracked stoage to 10G via oo-admin-ctl-user
oo-admin-ctl-user -l $user --setmaxtrackedstorage 10
oo-admin-ctl-user -l $user --setmaxuntrackedstorage 10


3.Add more than tracked number storage to the cartridge
 rhc cartridge-storage jbosseap-6 eap --add  7GB
 rhc cartridge-storage jbosseap-6 eap --add  5GB

4. delete the user_record with user_type 'ADDTL_FS_GB'


5. oo-admin-chk -l 1

oo-admin-chk -l 1
Started at: 2013-12-20 11:29:07 UTC

Total gears found in mongo: 3
Total gears found on the nodes: 3
Total nodes that responded: 1

Finished at: 2013-12-20 11:29:49 UTC
Total time: 41.457s
Found addtl storage mismatch for gear Id '52b4287f2a2b96e76c00004e', 8 in usage record vs 11 for corresponding gear in the application.
Found 1 un-ended records in usage collection for gear Id '52b4287f2a2b96e76c00004e' but could not find corresponding records in usage_records.
FAILED
Please refer to the oo-admin-repair tool to resolve some of these inconsistencies