Bug 1417583 - hosted-engine --get-shared-config should report a nice error not traceback when nonexistent key is used
Summary: hosted-engine --get-shared-config should report a nice error not traceback wh...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: ovirt-hosted-engine-setup
Classification: oVirt
Component: General
Version: 2.1.0
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: ovirt-4.1.1
: 2.1.0.4
Assignee: Jenny Tokar
QA Contact: Nikolai Sednev
URL:
Whiteboard:
Depends On:
Blocks: 1301681 1379405
TreeView+ depends on / blocked
 
Reported: 2017-01-30 11:03 UTC by Nikolai Sednev
Modified: 2017-05-11 09:31 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: calling hosted-engine --get-shared-config with non existing key Consequence: traceback with an error message instead of a nice message Fix: format the error message Result: clear error with the available keys for the user examples can be found here: http://www.ovirt.org/develop/release-management/features/sla/hosted-engine-edit-configuration-on-shared-storage/
Clone Of:
Environment:
Last Closed: 2017-04-21 09:52:12 UTC
oVirt Team: SLA
rule-engine: ovirt-4.1+
nsednev: testing_plan_complete+
msivak: devel_ack+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1417591 0 unspecified CLOSED [RFE][Doc] it's now possible to change HE settings after deploy on the HE shared storage. 2021-02-22 00:41:40 UTC
oVirt gerrit 72327 0 master MERGED Add a method to get all editable keys on shared storage 2017-02-15 11:58:13 UTC
oVirt gerrit 72328 0 master MERGED Provide more info in error message 2017-02-15 11:58:16 UTC
oVirt gerrit 72331 0 master MERGED Format errors when getting and setting configuration 2017-02-15 15:01:25 UTC
oVirt gerrit 72346 0 v2.1.z MERGED Add a method to get all editable keys on shared storage 2017-02-15 12:35:26 UTC
oVirt gerrit 72347 0 v2.1.z MERGED Provide more info in error message 2017-02-15 12:35:29 UTC
oVirt gerrit 72408 0 ovirt-hosted-engine-setup-2.1 MERGED Format errors when getting and setting configuration 2017-02-23 12:39:05 UTC

Internal Links: 1417591

Description Nikolai Sednev 2017-01-30 11:03:29 UTC
Description of problem:
hosted-engine --get-shared-config state-transition --type=broker is not working.

Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.7/site-packages/ovirt_hosted_engine_setup/get_shared_config.py", line 51, in <module>
    value_and_type = get_shared_config.get_shared_config(*sys.argv)
  File "/usr/lib/python2.7/site-packages/ovirt_hosted_engine_setup/get_shared_config.py", line 40, in get_shared_config
    result = ha_cli.get_shared_config(key, config_type)
  File "/usr/lib/python2.7/site-packages/ovirt_hosted_engine_ha/client/client.py", line 279, in get_shared_config
    return self._config.get_config_from_shared_storage(key, config_type)
  File "/usr/lib/python2.7/site-packages/ovirt_hosted_engine_ha/env/config.py", line 216, in get_config_from_shared_storage
    value = self.get(final_type, key)
  File "/usr/lib/python2.7/site-packages/ovirt_hosted_engine_ha/env/config.py", line 210, in get
    key
KeyError: 'Configuration value not found: file=/var/lib/ovirt-hosted-engine-ha/broker.conf, key=state-transition'

Version-Release number of selected component (if applicable):
ovirt-hosted-engine-ha-2.1.0-1.el7ev.noarch
ovirt-host-deploy-1.6.0-1.el7ev.noarch
ovirt-imageio-common-0.5.0-0.el7ev.noarch
ovirt-vmconsole-host-1.0.4-1.el7ev.noarch
qemu-kvm-rhev-2.6.0-28.el7_3.3.x86_64
libvirt-client-2.0.0-10.el7_3.4.x86_64
mom-0.5.8-1.el7ev.noarch
vdsm-4.19.2-2.el7ev.x86_64
ovirt-hosted-engine-setup-2.1.0-2.el7ev.noarch
ovirt-setup-lib-1.1.0-1.el7ev.noarch
ovirt-engine-sdk-python-3.6.9.1-1.el7ev.noarch
ovirt-imageio-daemon-0.5.0-0.el7ev.noarch
ovirt-vmconsole-1.0.4-1.el7ev.noarch
sanlock-3.4.0-1.el7.x86_64
Linux version 3.10.0-514.6.1.el7.x86_64 (mockbuild@x86-030.build.eng.bos.redhat.com) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Sat Dec 10 11:15:38 EST 2016
Linux 3.10.0-514.6.1.el7.x86_64 #1 SMP Sat Dec 10 11:15:38 EST 2016 x86_64 x86_64 x86_64 GNU/Linux
Red Hat Enterprise Linux Server release 7.3 (Maipo)

How reproducible:
100%

Steps to Reproduce:
1.On deployed HE environment with some data storage domain run "hosted-engine --get-shared-config state-transition --type=broker" on host.
2.
3.

Actual results:
hosted-engine --get-shared-config state-transition --type=broker
Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.7/site-packages/ovirt_hosted_engine_setup/get_shared_config.py", line 51, in <module>
    value_and_type = get_shared_config.get_shared_config(*sys.argv)
  File "/usr/lib/python2.7/site-packages/ovirt_hosted_engine_setup/get_shared_config.py", line 40, in get_shared_config
    result = ha_cli.get_shared_config(key, config_type)
  File "/usr/lib/python2.7/site-packages/ovirt_hosted_engine_ha/client/client.py", line 279, in get_shared_config
    return self._config.get_config_from_shared_storage(key, config_type)
  File "/usr/lib/python2.7/site-packages/ovirt_hosted_engine_ha/env/config.py", line 216, in get_config_from_shared_storage
    value = self.get(final_type, key)
  File "/usr/lib/python2.7/site-packages/ovirt_hosted_engine_ha/env/config.py", line 210, in get
    key
KeyError: 'Configuration value not found: file=/var/lib/ovirt-hosted-engine-ha/broker.conf, key=state-transition'

Expected results:
No errors should be printed.

Additional info:

Comment 1 Nikolai Sednev 2017-01-30 11:11:10 UTC
Sosreport from alma04 available from here https://drive.google.com/open?id=0B85BEaDBcF88VDhuVFRTSnF4Zms

Comment 2 Jenny Tokar 2017-01-30 13:10:49 UTC
This is mistake in documentation, the key should be state_transition and not state-transition. 

I fixed the document, can you verify that the correct key now works?

Comment 3 Nikolai Sednev 2017-01-31 10:47:43 UTC
# hosted-engine --get-shared-config state_transition --type=broker

broker : maintenance|start|stop|migrate|up|down, type : broker

I'm not sure how to properly use the set though. I've tried to use with single key value like:
hosted-engine --set-shared-config state_transition maintenance --type=broker
# hosted-engine --get-shared-config state_transition --type=broker
broker : maintenance, type : broker

But how to return to default of maintenance|start|stop|migrate|up|down ?

# hosted-engine --set-shared-config state_transition maintenance,start,stop,migrate,up,down --type=broker
[root@alma04 ~]# hosted-engine --get-shared-config state_transition --type=broker
broker : maintenance,start,stop,migrate,up,down, type : broker

hosted-engine --set-shared-config state_transition maintenance|start|stop|migrate|up|down --type=broker
-bash: start: command not found
-bash: stop: command not found
-bash: migrate: command not found
-bash: up: command not found
-bash: down: command not found


Anyway, the improperly used input of state-transition still causing an error, which have to be fixed, regardless of documentation.

Comment 4 Jenny Tokar 2017-01-31 14:00:12 UTC
Use double quotes, the pipeline makes the shell think the arguments are commands.

hosted-engine --set-shared-config state_transition "maintenance|start|stop|migrate|up|down" --type=broker

Comment 5 Nikolai Sednev 2017-02-05 15:00:08 UTC
Now that part from comment #3 is working properly.

[root@alma04 ~]# hosted-engine --set-shared-config state_transition maintenance --type=broker[root@alma04 ~]# hosted-engine --get-shared-config state_transition 

 : maintenance, type : broker

[root@alma04 ~]# hosted-engine --set-shared-config state_transition "maintenance|start|stop|migrate|up|down" --type=broker
[root@alma04 ~]# hosted-engine --get-shared-config state_transition 
 : maintenance|start|stop|migrate|up|down, type : broker

However that error should be fixed.

Comment 6 Jenny Tokar 2017-02-06 12:34:31 UTC
I see an error that the key name doesn't appear at the beginning of the output line, and I'll fix that.
Should be: "state_transition : maintenance|start|stop|migrate|up|down, type : broker" 
And not " : maintenance|start|stop|migrate|up|down, type : broker"

However, what's causing the command to fail in comment 3 is a part of bash functionality, a pipeline (|) sends the output of the command to the next command in the pipeline. 
In our case bash interprets the command "hosted-engine --set-shared-config state_transition maintenance|start|stop|migrate|up|down --type=broker" like this:
the output of "hosted-engine --set-shared-config state_transition maintenance" is sent to a command "start". This command does not exist so you get the bash error.  
This is not an error but the way bash works.

Comment 7 Nikolai Sednev 2017-02-06 17:14:33 UTC
That is not "Not a bug", rather incorrect documentation, which lead me to use "state-transition" instead of "state_transition".
You should fix the issue when customer printing "state-transition" instead of "state_transition".



puma18 ~]#  hosted-engine --get-shared-config state-transition --type=broker
Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.7/site-packages/ovirt_hosted_engine_setup/get_shared_config.py", line 51, in <module>
    value_and_type = get_shared_config.get_shared_config(*sys.argv)
  File "/usr/lib/python2.7/site-packages/ovirt_hosted_engine_setup/get_shared_config.py", line 40, in get_shared_config
    result = ha_cli.get_shared_config(key, config_type)
  File "/usr/lib/python2.7/site-packages/ovirt_hosted_engine_ha/client/client.py", line 279, in get_shared_config
    return self._config.get_config_from_shared_storage(key, config_type)
  File "/usr/lib/python2.7/site-packages/ovirt_hosted_engine_ha/env/config.py", line 224, in get_config_from_shared_storage
    value = self.get(final_type, key)
  File "/usr/lib/python2.7/site-packages/ovirt_hosted_engine_ha/env/config.py", line 218, in get
    key
KeyError: 'Configuration value not found: file=/var/lib/ovirt-hosted-engine-ha/broker.conf, key=state-transition'
[root@puma18 ~]#  hosted-engine --get-shared-config state_transition --type=broker

broker : maintenance|start|stop|migrate|up|down, type : broker

Comment 8 Yaniv Lavi 2017-02-08 14:08:56 UTC
What docs did you use?

Comment 10 Martin Sivák 2017-02-13 10:41:15 UTC
Nikolai, please open a github issue for https://github.com/oVirt/ovirt-site/ to have this fixed. We do not use bugzilla for feature pages.

Comment 11 Jenny Tokar 2017-02-13 11:43:49 UTC
The ovirt site is already updated with the correct key name.

Comment 12 Nikolai Sednev 2017-02-13 12:52:29 UTC
(In reply to Martin Sivák from comment #10)
> Nikolai, please open a github issue for https://github.com/oVirt/ovirt-site/
> to have this fixed. We do not use bugzilla for feature pages.

Not sure I'm fully understand you Martin.
Feature should be documented in official downstream documentation. Upstream documentation is not sufficient.

Comment 13 Martin Sivák 2017-02-13 13:07:18 UTC
Nikolai, you used upstream documentation and there was a bug there that needs to be reported using github issue. Is the same bug in downstream documentation as well? If not then this bug needs to be closed.

Comment 14 Nikolai Sednev 2017-02-13 13:11:48 UTC
(In reply to Martin Sivák from comment #13)
> Nikolai, you used upstream documentation and there was a bug there that
> needs to be reported using github issue. Is the same bug in downstream
> documentation as well? If not then this bug needs to be closed.

Downstream documentation was missing at the point of a time I was trying to verify the RFE. As reported in comment #11, upstream documentation was already fixed.

This bug is not to be closed, until https://bugzilla.redhat.com/show_bug.cgi?id=1417583#c0 fixed.

Even with fixed upstream documentation, in case of improperly cast command e.g. "hosted-engine --get-shared-config state-transition --type=broker", customer will get errors as appears above.

Comment 15 Nikolai Sednev 2017-03-05 16:41:29 UTC
Works for me on these components on hosts:
qemu-kvm-rhev-2.6.0-28.el7_3.6.x86_64
mom-0.5.9-1.el7ev.noarch
ovirt-host-deploy-1.6.2-1.el7ev.noarch
vdsm-4.19.7-1.el7ev.x86_64
ovirt-engine-sdk-python-3.6.9.1-1.el7ev.noarch
sanlock-3.4.0-1.el7.x86_64
ovirt-vmconsole-host-1.0.4-1.el7ev.noarch
ovirt-hosted-engine-ha-2.1.0.4-1.el7ev.noarch
rhevm-appliance-20161214.0-1.el7ev.noarch
libvirt-client-2.0.0-10.el7_3.5.x86_64
ovirt-vmconsole-1.0.4-1.el7ev.noarch
ovirt-imageio-common-1.0.0-0.el7ev.noarch
ovirt-imageio-daemon-1.0.0-0.el7ev.noarch
ovirt-hosted-engine-setup-2.1.0.4-1.el7ev.noarch
ovirt-setup-lib-1.1.0-1.el7ev.noarch
Linux version 3.10.0-514.10.2.el7.x86_64 (mockbuild@x86-039.build.eng.bos.redhat.com) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Mon Feb 20 02:37:52 EST 2017
Linux 3.10.0-514.10.2.el7.x86_64 #1 SMP Mon Feb 20 02:37:52 EST 2017 x86_64 x86_64 x86_64 GNU/Linux
Red Hat Enterprise Linux Server release 7.3 (Maipo)

On engine:
rhevm-setup-plugins-4.1.1-1.el7ev.noarch
rhevm-dependencies-4.1.1-1.el7ev.noarch
rhev-guest-tools-iso-4.1-4.el7ev.noarch
rhevm-4.1.1.3-0.1.el7.noarch
rhevm-doc-4.1.0-2.el7ev.noarch
rhevm-branding-rhev-4.1.0-1.el7ev.noarch
Linux version 3.10.0-514.6.2.el7.x86_64 (mockbuild@x86-017.build.eng.bos.redhat.com) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Fri Feb 17 19:21:31 EST 2017
Linux 3.10.0-514.6.2.el7.x86_64 #1 SMP Fri Feb 17 19:21:31 EST 2017 x86_64 x86_64 x86_64 GNU/Linux
Red Hat Enterprise Linux Server release 7.3 (Maipo)


# hosted-engine --get-shared-config state-transition --type=broker
Invalid configuration key state-transition.
Available keys are:
broker : ['smtp-port', 'destination-emails', 'smtp-server', 'source-email', 'state_transition']
#


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