Bug 1263119

Summary: virt-who show error info in the log if "OWNER" or "ENV" is null in /etc/sysconfig/virt-who
Product: Red Hat Enterprise Linux 7 Reporter: Liushihui <shihliu>
Component: virt-whoAssignee: Radek Novacek <rnovacek>
Status: CLOSED DUPLICATE QA Contact: Li Bin Liu <liliu>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.2CC: gxing, hsun, ovasik, sgao, shihliu
Target Milestone: rcKeywords: Reopened
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-09-22 13:35:06 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 Liushihui 2015-09-15 07:28:35 UTC
Description of problem:
Configure virt-who as the following two error conditions in /etc/sysconfig/virt-who, Although failed to start virt-who service, virt-who show nothing in the log and terminal side.
1. no VIRTWHO_XXX_OWNER  or VIRTWHO_XXX_ENV in /etc/sysconfig/virt-who
2. configure "VIRTWHO_XXX_OWNER" or "VIRTWHO_XXX_ENV" to null in /etc/sysconfig/virt-who

Version-Release number of selected component (if applicable):
python-rhsm-1.15.4-4.el7.x86_64
subscription-manager-1.15.9-7.el7.x86_64
virt-who-0.14-7.el7.noarch
SAM-1.4.1-RHEL-6-20141113.0

How reproducible:
Always

Steps to Reproduce:
1. Register system to SAM.
2. Configure virt-who run at esx mode and configure "VIRTWHO_ESX_OWNER" or "VIRTWHO_ESX_ENV" to null.
# grep -v  "^#" /etc/sysconfig/virt-who
VIRTWHO_BACKGROUND=1
VIRTWHO_DEBUG=1
VIRTWHO_INTERVAL=5
VIRTWHO_ESX=1
VIRTWHO_ESX_OWNER=
VIRTWHO_ESX_ENV=Library
VIRTWHO_ESX_SERVER=10.66.78.2
VIRTWHO_ESX_USERNAME=administrator
VIRTWHO_ESX_PASSWORD=qwer1234P!
3. Restart virt-who service and check virt-who's log
[root@hp-z220-05 ~]# systemctl restart virt-who

[root@hp-z220-05 ~]# tail -f /var/log/rhsm/rhsm.log

Actual results:
There are two problems:
1. Although failed to start virt-who service, it hasn't show any error info in the terminal side, it should be the same bug as "bug 1243341"
2. It hasn't show any error info in the virt-who's log. customers will confuse to see virt-who's status unless run "systemctl status virt-who"

[root@hp-z220-05 ~]# systemctl status virt-who
● virt-who.service - Daemon for reporting virtual guest IDs to subscription-manager
   Loaded: loaded (/usr/lib/systemd/system/virt-who.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2015-09-15 14:57:42 CST; 11s ago
  Process: 27231 ExecStart=/usr/bin/virt-who (code=exited, status=1/FAILURE)
 Main PID: 27231 (code=exited, status=1/FAILURE)

Sep 15 14:57:41 hp-z220-05.qe.lab.eng.nay.redhat.com systemd[1]: Started Daemon for reporting virtual guest IDs to subscription-manager.
Sep 15 14:57:41 hp-z220-05.qe.lab.eng.nay.redhat.com systemd[1]: Starting Daemon for reporting virtual guest IDs to subscription-manager...
***********************It is show the reason*****************************
Sep 15 14:57:42 hp-z220-05.qe.lab.eng.nay.redhat.com virt-who[27231]: Option --esx-owner (or VIRTWHO_ESX_OWNER environment variable) ... set
**************************************************************************

Expected results:
When failed to start virt-who service, it should show error info in the log and terminal side

Additional info:
When "encrypted_password" isn't exist on system, restart virt-who service will show error info in the log as the following:
2015-09-15 14:55:49,609 [ERROR]  @virtwho.py:672 - [Errno 2] No such file or directory: '/var/lib/virt-who/key'

Comment 1 Radek Novacek 2015-09-15 08:21:32 UTC
This is caused by bug 1243341, marking it as duplicate.

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

Comment 2 Liushihui 2015-09-18 06:06:28 UTC
In the latest virt-who-0.14-8.el7.noarch, if "owner" or "env" have not been configured in /etc/virt-who.d/XXX, it will show error info in the log. please see it as the following. However, it won't generate any log if "owner" or "env" have not been configured in /etc/sysconfig/virt-who. I think it should show the same result on these two configure files in the same condition.

2015-09-18 02:02:02,352 [ERROR]  @virtwho.py:747 - Fatal error: Option `env` needs to be set in config `test-rhevm1`
Traceback (most recent call last):
  File "/usr/share/virt-who/virtwho.py", line 741, in <module>
    main()
  File "/usr/share/virt-who/virtwho.py", line 670, in main
    virtWho = VirtWho(logger, options)
  File "/usr/share/virt-who/virtwho.py", line 130, in __init__
    self.configManager = ConfigManager(self.logger, config_dir, smType=options.smType)
  File "/usr/share/virt-who/config.py", line 357, in __init__
    self._readConfig(parser)
  File "/usr/share/virt-who/config.py", line 364, in _readConfig
    config.checkOptions(self.smType, self.logger)
  File "/usr/share/virt-who/config.py", line 96, in checkOptions
    raise InvalidOption("Option `env` needs to be set in config `%s`" % (self.name))
InvalidOption: Option `env` needs to be set in config `test-rhevm1`

Comment 3 Radek Novacek 2015-09-22 13:35:06 UTC
Thanks for noticing, will fix together with bug 1254843.

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