Bug 1216220

Summary: oo-snapshot is not working
Product: OpenShift Container Platform Reporter: Ricardo Martinelli de Oliveira <rmartine>
Component: ContainersAssignee: Timothy Williams <tiwillia>
Status: CLOSED ERRATA QA Contact: libra bugs <libra-bugs>
Severity: unspecified Docs Contact:
Priority: high    
Version: 2.2.0CC: adellape, anli, bleanhar, jialiu, jokerman, libra-onpremise-devel, mmccomas, pruan, tiwillia
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rubygem-openshift-origin-node-1.36.1.1-1 Doc Type: Bug Fix
Doc Text:
The oo-snapshot command, which is a wrapper for '/usr/bin/gear snapshot', reports an unhelpful error when used outside of a gear environment. This bug fix updates /usr/bin/gear to report an error stating it should only be run inside of a gear when necessary environment variables are not defined. As a result, oo-snapshot reports the same error when run outside of a gear.
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-07-21 19:12:24 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:
Embargoed:

Description Ricardo Martinelli de Oliveira 2015-04-28 19:34:16 UTC
Description of problem:
After run oo-snapshot I get this error:

# oo-snapshot
invalid command. Use --help for more information
/opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-node-1.34.1.1/lib/openshift-origin-node/model/application_container.rb:112:in `getpwnam': can't convert nil into String (TypeError)
	from /opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-node-1.34.1.1/lib/openshift-origin-node/model/application_container.rb:112:in `block in initialize'
	from /opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-node-1.34.1.1/lib/openshift-origin-node/model/application_container.rb:110:in `each'
	from /opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-node-1.34.1.1/lib/openshift-origin-node/model/application_container.rb:110:in `initialize'
	from /usr/bin/gear:61:in `new'
	from /usr/bin/gear:61:in `<main>'


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

How reproducible:
Always you run oo-snapshot

Steps to Reproduce:
1. ssh to a Node host
2. run oo-snapshot

Actual results:
The command returns an error

Expected results:
The command should print the possible options to use with it.


Additional info:

Comment 2 Brenton Leanhardt 2015-04-28 20:27:55 UTC
Looks like it's a problem with /usr/bin/gear.

Comment 3 Timothy Williams 2015-04-30 13:52:11 UTC
oo-snapshot works when run inside a gear. The reason it fails outside of a gear is that the environment variables that '/usr/bin/gear' uses are not set:

@container = OpenShift::Runtime::ApplicationContainer.new(ENV['OPENSHIFT_APP_UUID'], ENV['OPENSHIFT_GEAR_UUID'], Etc.getpwuid.uid, ENV['OPENSHIFT_APP_NAME'], ENV['OPENSHIFT_GEAR_NAME'], ENV['OPENSHIFT_NAMESPACE'])

The error seen occurs any time /usr/bin/gear is run outside of a gear:

# gear
invalid command. Use --help for more information
/opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-node-1.35.4.2/lib/openshift-origin-node/model/application_container.rb:113:in `getpwnam': can't convert nil into String (TypeError)

I think the bigger problem here is that we don't document the use of oo-snapshot, which is just a wrapper for '/usr/bin/gear snapshot'.

I could see adding some logic in /usr/bin/gear to give a better error when it is run outside of a gear though. If we want to take this path:

https://github.com/openshift/origin-server/pull/6133

Comment 4 openshift-github-bot 2015-04-30 21:20:18 UTC
Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/5054607c088762892498cbce7f7dd1f73dc950df
BZ1216220 - oo-snapshot fails when run outside of a gear

Bug 1216220
Bugzilla link https://bugzilla.redhat.com/show_bug.cgi?id=1216220
oo-snapshot and gear fail when run outside of a gear. Instead, these will fail gracefully with an error stating that they should not be run outside of a gear.

Comment 7 Anping Li 2015-05-05 03:00:08 UTC
There isn't package rubygem-openshift-origin-node-1.36.1.1-1 in puddle-2-2-2015-05-04 . We need to rebuild a puddle. thanks

Comment 11 Anping Li 2015-05-06 06:21:45 UTC
oo-snapshot provide clear message on node now.  I will run extend testing (app snapshot save/restore ) once 1218872 is fixed.

[root@node1 ~]# oo-snapshot 
This command should only be run inside of a gear.
The environment variables 'OPENSHIFT_APP_UUID' and 'OPENSHIFT_GEAR_UUID' are not set.
invalid command. Use --help for more information

Comment 12 Anping Li 2015-05-07 02:36:36 UTC
On puddle-2-2-2015-05-06. snapshot save/restore works. so move bug to verified.

[anli@broker ~]$ rhc snapshot save sphp
Pulling down a snapshot of application 'sphp' to sphp.tar.gz ... done
[anli@broker ~]$ rhc snapshot restore sphp
Restoring from snapshot sphp.tar.gz to application 'sphp' ... done

Comment 14 errata-xmlrpc 2015-07-21 19:12:24 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://rhn.redhat.com/errata/RHBA-2015-1463.html