Bug 902472

Summary: Broker issues error on key upload attempt
Product: OKD Reporter: N. Harrison Ripps <hripps>
Component: PodAssignee: Dan McPherson <dmcphers>
Status: CLOSED NOTABUG QA Contact: libra bugs <libra-bugs>
Severity: high Docs Contact:
Priority: unspecified    
Version: 2.xCC: bmeng
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-01-22 17:58:08 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:
Attachments:
Description Flags
Screen shot of error from UI none

Description N. Harrison Ripps 2013-01-21 18:28:13 UTC
Description of problem:
When I run "rhc setup" for an account, the utility attempts to upload my public SSH key on my behalf. However, an error seems to occur and the upload fails.

Version-Release number of selected component (if applicable):
rhc client version 1.3.4
rhc-broker version 

How reproducible:
Always

Steps to Reproduce:
1. run `rhc setup`
2. Answer 'yes' to "Your public SSH key must be uploaded to the OpenShift server to access code.  Upload now? (yes|no)"
  
Actual results:
Command exits with: "Uploading key 'default' from /home/harrison/.ssh/id_rsa.pub ... can't convert String into Integer"


Expected results:
Setup completes succesfully, key is uploaded

Additional info:
Here is debug output from my latest attempt:


Since you do not have any keys associated with your OpenShift account, your new key will be uploaded as the 'default' key.

  Type:        ssh-rsa
  Fingerprint: 01:81:96:c2:02:9c:93:dc:83:58:74:f4:e4:1b:be:2e

Uploading key 'default' from /home/harrison/.ssh/id_rsa.pub ... = Request

POST /broker/rest/user/keys HTTP/1.1
accept: application/json
content-type: application/json
Authorization: Basic aGFycmlzb25AZW1pY2hyb24uY29tOmQwbTFuOHJ4
User-Agent: rhc/1.3.4 (ruby 1.9.3; x86_64-linux) (2.3.2, ruby 1.9.3 (2012-12-25) [x86_64-linux])
Date: Mon, 21 Jan 2013 18:22:21 GMT
Content-Length: 252
Host: 54.242.109.37

{"name":"default","type":"ssh-rsa","content":"AAAAB3NzaC1yc2EAAAADAQABAAAAgQDARYm8VNejYBDYFs0G/h1pZfvz15ep7lGq9k7UHi/OuEthbCqHWUTq5u5tFTmGfLch1bobp+G5zAxc5KFhn7EWdb+0AoohgkQ7Pylwi5jnhhWQ7rfTkXKSlv83elxKCdDCh6bBeN+kTwDYyt8Cnu3EV8JJG9MsVPvBYrHCk/sXZQ=="}

= Response

HTTP/1.1 500 Internal Server Error
Date: Mon, 21 Jan 2013 18:22:21 GMT
Server: Apache/2.2.15 (Red Hat)
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.17
X-UA-Compatible: IE=Edge
Cache-Control: no-cache
X-Request-Id: 487673f36cb30e5b613be27664293849
X-Runtime: 0.034965
X-Rack-Cache: invalidate, pass
Location: /broker/rest/api
Status: 500
Content-Length: 221
Content-Type: application/json; charset=utf-8
Vary: Accept-Encoding,User-Agent
Strict-Transport-Security: max-age=15768000
ProxyTime: D=36850
Connection: close

{"data":null,"messages":[{"exit_code":1,"field":null,"severity":"error","text":"can't convert String into Integer"}],"status":"internal_server_error","supported_api_versions":[1.0,1.1,1.2,1.3],"type":null,"version":"1.3"}! CONNECTION CLOSED
/home/harrison/Code/rhc/lib/rhc/rest/client.rb:428:in `handle_error!': can't convert String into Integer (RHC::Rest::ServerErrorException)
	from /home/harrison/Code/rhc/lib/rhc/rest/client.rb:59:in `block in request'
	from /home/harrison/Code/rhc/lib/rhc/rest/client.rb:49:in `each'
	from /home/harrison/Code/rhc/lib/rhc/rest/client.rb:49:in `request'
	from /home/harrison/Code/rhc/lib/rhc/rest/base.rb:25:in `rest_method'
	from /home/harrison/Code/rhc/lib/rhc/rest/user.rb:10:in `add_key'
	from /home/harrison/Code/rhc/lib/rhc/rest/client.rb:231:in `add_key'
	from /home/harrison/Code/rhc/lib/rhc/wizard.rb:251:in `block in upload_ssh_key'
	from /home/harrison/Code/rhc/lib/rhc/helpers.rb:396:in `call'
	from /home/harrison/Code/rhc/lib/rhc/helpers.rb:396:in `section'
	from /home/harrison/Code/rhc/lib/rhc/helpers.rb:410:in `paragraph'
	from /home/harrison/Code/rhc/lib/rhc/wizard.rb:244:in `upload_ssh_key'
	from /home/harrison/Code/rhc/lib/rhc/wizard.rb:267:in `upload_ssh_key_stage'
	from /home/harrison/Code/rhc/lib/rhc/wizard.rb:50:in `block in run'
	from /home/harrison/Code/rhc/lib/rhc/wizard.rb:48:in `each'
	from /home/harrison/Code/rhc/lib/rhc/wizard.rb:48:in `run'
	from /home/harrison/Code/rhc/lib/rhc/commands/setup.rb:29:in `run'
	from /home/harrison/Code/rhc/lib/rhc/commands.rb:201:in `execute'
	from /home/harrison/Code/rhc/lib/rhc/commands.rb:192:in `block (3 levels) in to_commander'
	from /home/harrison/.gem/ruby/1.9.1/gems/commander-4.1.3/lib/commander/command.rb:180:in `call'
	from /home/harrison/.gem/ruby/1.9.1/gems/commander-4.1.3/lib/commander/command.rb:180:in `call'
	from /home/harrison/.gem/ruby/1.9.1/gems/commander-4.1.3/lib/commander/command.rb:155:in `run'
	from /home/harrison/.gem/ruby/1.9.1/gems/commander-4.1.3/lib/commander/runner.rb:402:in `run_active_command'
	from /home/harrison/Code/rhc/lib/rhc/command_runner.rb:95:in `run!'
	from /home/harrison/.gem/ruby/1.9.1/gems/commander-4.1.3/lib/commander/delegates.rb:11:in `run!'
	from /home/harrison/Code/rhc/lib/rhc/cli.rb:42:in `start'
	from bin/rhc:18:in `<main>'

Comment 1 Dan McPherson 2013-01-21 20:06:22 UTC
Creating key name:default type:ssh-rsa for us
er harrison (pid:12202)
ESC[0;37m2013-01-21 13:36:05.979ESC[0m [ESC[31mERRORESC[0m] can't convert String into Integer (pid:12202)
ESC[0;37m2013-01-21 13:36:05.980ESC[0m [ESC[31mERRORESC[0m] ["/opt/rh/ruby193/root/usr/share/gems/gems/open
shift-origin-controller-1.3.6/app/models/cloud_user.rb:257:in `[]='", "/opt/rh/ruby193/root/usr/share/gems/
gems/openshift-origin-controller-1.3.6/app/models/cloud_user.rb:257:in `add_ssh_key'", "/opt/rh/ruby193/roo
t/usr/share/gems/gems/openshift-origin-controller-1.3.6/app/controllers/keys_controller.rb:47:in `create'",
 "/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/implicit_render.rb:
4:in `send_action'", "/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/bas
e.rb:167:in `process_action'", "/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_contro
ller/metal/rendering.rb:10:in `process_action'"

Comment 2 Dan McPherson 2013-01-21 22:31:22 UTC
I haven't been able to recreate this.  Really need the steps to make it happen.

Comment 3 Dan McPherson 2013-01-21 23:25:27 UTC
I have tried every scenario I can think of to get ssh_keys to be an array and reviewed the code for any cases it is set to an array.  Marking ON_QA for now.  If it can be recreated please reopen.

Comment 4 Meng Bo 2013-01-22 11:21:05 UTC
Cannot recreate it from QE side too.

@hripps Can you give some more details?

Comment 5 N. Harrison Ripps 2013-01-22 16:20:14 UTC
Just hit this again today:

1. Create a devenv
2. Run sync

Don't bother to turn on integration; this morning I hit it without integration.

3. Log in to devenv with new fake account.
4. Click the "Create Application" tab
5. Select Wordpress 3.4
6. From the configuration page, interrupt the app creation process by clicking "My Account"
7. Enter a namespace for the account.
8. Click the "Create Application" tab
9. Select Wordpress 3.4
10. In a new window, open up rockmongo (https://[devenv]/rockmongo) and increase the fake user's max_gears to 20
11. Back in the app config window, give the wordpress app a name and set it to be scalable
12. Create the application
13. After the application is created, look at the application details page (https://[devenv]/app/console/applications/[application])
14. Click on the My Account tab
15. In a terminal window, run `less [path/to/id_rsa.pub]`
16. Back in the browser, copy the contents of the `less` output into the public key file area of the My Account page and press 'Save'.

Resulting screen is attached.

Comment 6 N. Harrison Ripps 2013-01-22 16:20:50 UTC
Created attachment 685280 [details]
Screen shot of error from UI

Comment 7 N. Harrison Ripps 2013-01-22 16:28:16 UTC
Another observation:

If I run rhc setup for this same fake user (after creating the user via the UI), I get the same errors from rhc.

_However_, if I use rhc setup to create a completely new user on the devenv, the key upload is successful.

Comment 8 Dan McPherson 2013-01-22 17:58:08 UTC
Okay I think your problem is in step 10.

I am guessing you are hitting update.  Changing the one value for 3 to 10 and hitting save.  The issue being you are changing the ssh_keys to an array when you do so.  As an alternative you can either set ssh_keys to {} or you can use the drop down next to the 3 (before going into update) and update the value in place.