Bug 1356212

Summary: PostgresAdmin.runcmd fails when overrides to the default options are provided
Product: Red Hat CloudForms Management Engine Reporter: Joe Vlcek <jvlcek>
Component: ApplianceAssignee: Gregg Tanzillo <gtanzill>
Status: CLOSED DUPLICATE QA Contact: Dave Johnson <dajohnso>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 5.7.0CC: abellott, jhardy, obarenbo
Target Milestone: GA   
Target Release: 5.7.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-20 01:44:35 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 Joe Vlcek 2016-07-13 17:15:51 UTC
Description of problem:

When invoking PostgresAdmin.runcmd with overrides to the default options
a traceback is produced.


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


How reproducible:

This issue can be observed using rails console on an appliance configured
with a database.


Steps to Reproduce:
1. Log into an appliance with a database
2. cd /var/www/miq/vmdb
3. bundle exec rails console
4. Run for following code segment:

require 'util/postgres_admin'

opts={}
opts[:dbname] = "vmdb_production"
opts[:hostname] = "127.0.0.1"
opts[:username] = "root"
opts[:password] = "<specify the configured root password>"

result = PostgresAdmin.runcmd("psql", opts, :command => "SELECT name FROM users ;")


Actual results:

Errno::ENOENT: No such file or directory @ unlink_internal - /root/.pgpass
	from /var/www/miq/vmdb/gems/pending/util/postgres_admin.rb:273:in `delete'
	from /var/www/miq/vmdb/gems/pending/util/postgres_admin.rb:273:in `ensure in with_pgpass_file'
	from /var/www/miq/vmdb/gems/pending/util/postgres_admin.rb:273:in `with_pgpass_file'
	from /var/www/miq/vmdb/gems/pending/util/postgres_admin.rb:258:in `runcmd_with_logging'
	from /var/www/miq/vmdb/gems/pending/util/postgres_admin.rb:253:in `runcmd'
	from (irb):9
	from /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/gems/railties-5.0.0.rc2/lib/rails/commands/console.rb:65:in `start'
	from /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/gems/railties-5.0.0.rc2/lib/rails/commands/console_helper.rb:9:in `start'
	from /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/gems/railties-5.0.0.rc2/lib/rails/commands/commands_tasks.rb:78:in `console'
	from /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/gems/railties-5.0.0.rc2/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
	from /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/gems/railties-5.0.0.rc2/lib/rails/commands.rb:18:in `<top (required)>'
	from bin/rails:4:in `require'
	from bin/rails:4:in `<main>'



Expected results:

irb(main):009:0* result = PostgresAdmin.runcmd("psql", opts, :command => "SELECT name FROM users ;")
=> "           name            \n---------------------------\n Administrator\n Consumption Administrator\n(2 rows)\n\n"


Additional info:

Comment 2 Dave Johnson 2016-07-20 01:44:35 UTC

*** This bug has been marked as a duplicate of bug 1356213 ***