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"
This issue is blocking www.pivotaltracker.com/projects/1608513 The source of the failure is the arguements to File.open are out of order in gems/pending/util/postgres_admin.rb 10.8.99.217 sb> diff gems/pending/util/postgres_admin.rb.FIX gems/pending/util/postgres_admin.rb.ORIG 270c270 < File.open(PGPASS_FILE, "w", 0600) { |f| f.write pass } if opts[:password] --- > File.open(PGPASS_FILE, 0600, "w") { |f| f.write pass } if opts[:password]
This is fixed by Keenan Brock's commit: https://github.com/ManageIQ/manageiq/commit/0dcef4f71016b704afee8b5642a95f4946fe5041
*** Bug 1356212 has been marked as a duplicate of this bug. ***
5.7.0.3
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-2017-0012.html