Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1514984 - [RFE] cannot get or change appliance settings via rails or api [NEEDINFO]
Summary: [RFE] cannot get or change appliance settings via rails or api
Keywords:
Status: CLOSED DUPLICATE of bug 1486634
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: cfme-openshift-app
Version: 5.9.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: GA
: 5.10.0
Assignee: Brandon Dunne
QA Contact: Dave Johnson
Red Hat CloudForms Documentation
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-11-19 21:17 UTC by Ievgen Zapolskyi
Modified: 2017-12-04 21:35 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-12-04 21:35:10 UTC
Category: Bug
Cloudforms Team: CFME Core
yrudman: needinfo? (dajohnso)


Attachments (Terms of Use)

Description Ievgen Zapolskyi 2017-11-19 21:17:37 UTC
Description of problem: 
automated tests get and set appliance settings using Settings.to_hash.deep_stringify_keys.to_yaml and cfmedb_set_config.rbt
Test framework is broken now because Settings produces an error due to absent config and other similar changes.
ManageIQ api doesn't provide interface to read and change appliance settings.

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

How reproducible:
100%

Steps to Reproduce:
1. deploy podified appliance 
2. connect to appliance by ssh
3. run cd /var/www/miq/vmdb; bin/rails runner Settings.to_hash.deep_stringify_keys.to_yaml

Actual results:
exception occurs

Expected results:
For the short run, we need these scripts and env to be fixed.
For the long run, we need to be able to read and change appliance settings via API. I can provide the list of options which need to implemented first.

Additional info:
[root@cloudforms-0 vmdb]# bin/rails runner Settings.to_hash.deep_stringify_keys.to_yaml
/opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/application/configuration.rb:143:in `database_configuration': Cannot load `Rails.application.database_configuration`: (RuntimeError)
Could not load database configuration. No such file - ["config/database.yml"]
        from /var/www/miq/vmdb/lib/patches/database_configuration_patch.rb:32:in `database_configuration'
        from /opt/rh/cfme-gemset/gems/activerecord-5.0.6/lib/active_record/railtie.rb:122:in `block (2 levels) in <class:Railtie>'
        from /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:69:in `instance_eval'
        from /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
        from /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control'
        from /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:65:in `execute_hook'
        from /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:41:in `block in on_load'
        from /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:40:in `each'
        from /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/lazy_load_hooks.rb:40:in `on_load'
        from /opt/rh/cfme-gemset/gems/activerecord-5.0.6/lib/active_record/railtie.rb:121:in `block in <class:Railtie>'
        from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/initializable.rb:30:in `instance_exec'
        from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/initializable.rb:30:in `run'
        from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /opt/rh/rh-ruby23/root/usr/share/ruby/tsort.rb:228:in `block in tsort_each'
        from /opt/rh/rh-ruby23/root/usr/share/ruby/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        from /opt/rh/rh-ruby23/root/usr/share/ruby/tsort.rb:431:in `each_strongly_connected_component_from'
        from /opt/rh/rh-ruby23/root/usr/share/ruby/tsort.rb:349:in `block in each_strongly_connected_component'
        from /opt/rh/rh-ruby23/root/usr/share/ruby/tsort.rb:347:in `each'
        from /opt/rh/rh-ruby23/root/usr/share/ruby/tsort.rb:347:in `call'
        from /opt/rh/rh-ruby23/root/usr/share/ruby/tsort.rb:347:in `each_strongly_connected_component'
        from /opt/rh/rh-ruby23/root/usr/share/ruby/tsort.rb:226:in `tsort_each'
        from /opt/rh/rh-ruby23/root/usr/share/ruby/tsort.rb:205:in `tsort_each'
        from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/initializable.rb:54:in `run_initializers'
        from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/application.rb:352:in `initialize!'
        from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/railtie.rb:193:in `public_send'
        from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/railtie.rb:193:in `method_missing'
        from /var/www/miq/vmdb/config/environment.rb:5:in `<top (required)>'
        from /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:293:in `require'
        from /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:293:in `block in require'
        from /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:259:in `load_dependency'
        from /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:293:in `require'
        from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/application.rb:328:in `require_environment!'
        from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands/runner.rb:52:in `<top (required)>'
        from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:138:in `require'
        from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:138:in `require_command!'
        from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:104:in `runner'
        from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
        from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands.rb:18:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'
[

Comment 2 Dave Johnson 2017-11-20 16:44:08 UTC
Ultimately this functionality needs to be in the REST API becuase we cannot reliably SSH into the pods like we can the vm appliances.  We have been asking for this for some time.

Comment 3 Brandon Dunne 2017-11-20 20:07:37 UTC
Everything appears to be working fine for me on the latest image.

$ oc rsh cloudforms-0
sh-4.2# bash
[root@cloudforms-0 vmdb]# rails r "Settings.to_hash.deep_stringify_keys.to_yaml"
{"@timestamp":"2017-11-20T20:03:03.798040 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"MIQ(Vmdb::Loggers.apply_config) Log level for evm.log has been changed to [INFO]"}
{"@timestamp":"2017-11-20T20:03:03.799124 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"MIQ(Vmdb::Loggers.apply_config) Log level for vim.log has been changed to [WARN]"}
{"@timestamp":"2017-11-20T20:03:03.799678 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"MIQ(Vmdb::Loggers.apply_config) Log level for rhevm.log has been changed to [INFO]"}
{"@timestamp":"2017-11-20T20:03:03.800400 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"MIQ(Vmdb::Loggers.apply_config) Log level for aws.log has been changed to [INFO]"}
{"@timestamp":"2017-11-20T20:03:03.801517 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"MIQ(Vmdb::Loggers.apply_config) Log level for kubernetes.log has been changed to [INFO]"}
{"@timestamp":"2017-11-20T20:03:03.801817 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"MIQ(Vmdb::Loggers.apply_config) Log level for middleware.log has been changed to [INFO]"}
{"@timestamp":"2017-11-20T20:03:03.802149 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"MIQ(Vmdb::Loggers.apply_config) Log level for datawarehouse.log has been changed to [INFO]"}
{"@timestamp":"2017-11-20T20:03:03.802528 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"MIQ(Vmdb::Loggers.apply_config) Log level for container_monitoring.log has been changed to [INFO]"}
{"@timestamp":"2017-11-20T20:03:03.802909 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"MIQ(Vmdb::Loggers.apply_config) Log level for scvmm.log has been changed to [INFO]"}
{"@timestamp":"2017-11-20T20:03:03.803159 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"MIQ(Vmdb::Loggers.apply_config) Log level for api.log has been changed to [INFO]"}
{"@timestamp":"2017-11-20T20:03:03.803376 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"MIQ(Vmdb::Loggers.apply_config) Log level for fog.log has been changed to [INFO]"}
{"@timestamp":"2017-11-20T20:03:03.803623 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"MIQ(Vmdb::Loggers.apply_config) Log level for azure.log has been changed to [WARN]"}
{"@timestamp":"2017-11-20T20:03:03.803856 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"MIQ(Vmdb::Loggers.apply_config) Log level for lenovo.log has been changed to [INFO]"}
{"@timestamp":"2017-11-20T20:03:03.804124 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"MIQ(Vmdb::Loggers.apply_config) Log level for websocket.log has been changed to [INFO]"}
{"@timestamp":"2017-11-20T20:03:04.378699 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"MIQ(SessionStore) Using session_store: ActionDispatch::Session::MemCacheStore"}
{"@timestamp":"2017-11-20T20:03:04.728249 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"Initializing Environment for API"}
{"@timestamp":"2017-11-20T20:03:04.728518 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":""}
{"@timestamp":"2017-11-20T20:03:04.728672 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"Static Configuration"}
{"@timestamp":"2017-11-20T20:03:04.729760 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"  module                  : api"}
{"@timestamp":"2017-11-20T20:03:04.730169 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"  name                    : API"}
{"@timestamp":"2017-11-20T20:03:04.730757 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"  description             : REST API"}
{"@timestamp":"2017-11-20T20:03:04.731154 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"  version                 : 3.0.0"}
{"@timestamp":"2017-11-20T20:03:04.731791 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":""}
{"@timestamp":"2017-11-20T20:03:04.732161 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"Dynamic Configuration"}
{"@timestamp":"2017-11-20T20:03:04.736978 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"  token_ttl               : 10.minutes"}
{"@timestamp":"2017-11-20T20:03:04.737209 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"  authentication_timeout  : 30.seconds"}
{"@timestamp":"2017-11-20T20:03:04.737672 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"  max_results_per_page    : 1000"}
{"@timestamp":"2017-11-20T20:03:04.737935 ","hostname":"cloudforms-0","pid":411,"tid":"1023130","level":"info","message":"MIQ(Vmdb::Initializer.init) - Program Name: bin/rails, PID: 411, ENV['EVMSERVER']: "}

Comment 4 Brandon Dunne 2017-11-20 20:12:26 UTC
Ievgen, do you have a reproducer environment for this issue?

Comment 5 Ievgen Zapolskyi 2017-11-20 21:44:59 UTC
environment is provided. I hope it is really fixed in 5.9.0.9. checking it there.

Comment 6 Ievgen Zapolskyi 2017-11-20 23:18:42 UTC
it turned out that default bash started by ssh/oc rsh doesn't read .bash_profile, .bashrc and /etc/bashrc accordingly and doesn't prepare environment. So, workaround is quite easy to make bash read configs.
However, podified cfme currently doesn't include sshd, ssh tools like scp. systemd cannot be used in cloudforms-0 pod as well.

We anyway need something better than this hack when we run ssh+rails to read or change appliance settings in tests. 
So, I'd keep this BZ open until we get some api to deal with appliance settings.

Comment 7 Yuri Rudman 2017-11-21 12:26:16 UTC
(In reply to Dave Johnson from comment #2)
> Ultimately this functionality needs to be in the REST API becuase we cannot
> reliably SSH into the pods like we can the vm appliances.  We have been
> asking for this for some time.

Dave, I would suggest to close this BZ and create another RFE BZ if it does not exist already, what do you think?

Comment 8 Ievgen Zapolskyi 2017-11-21 16:13:35 UTC
the issue is still present. I checked workaround via oc rsh and oci web ui. 
However, when I try to change settings thru ssh, I run into next problem. appliance variables are set now but openshift's environment variables are still unavailable.

Comment 9 Brandon Dunne 2017-11-21 19:02:01 UTC
Ievgen,

I don't think we have any plans to install or run a SSH server in each pod.  My understanding is that Openshift users will oc rsh into pods for debugging.  We've been using this method during development and everything appears to work.

Comment 10 Ievgen Zapolskyi 2017-11-22 22:21:22 UTC
I've played with openshift's rest api and oc rsh. Thanks Jason and Brandon. Both ways work and can be used as a replacement for ssh. So, this issue doesn't block testing any longer.

Comment 11 Brandon Dunne 2017-12-04 21:35:10 UTC

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


Note You need to log in before you can comment on or make changes to this bug.