Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 890572

Summary: If RHEV-H host registered from RHEV-M and later re-registered from RHEV-H, the 'Management Server Port' value cannot be changed.
Product: Red Hat Enterprise Virtualization Manager Reporter: Gordon Watson <gwatson>
Component: vdsmAssignee: Douglas Schilling Landgraf <dougsland>
Status: CLOSED ERRATA QA Contact: Artyom <alukiano>
Severity: low Docs Contact:
Priority: unspecified    
Version: 3.1.0CC: acathrow, bazulay, bsarathy, chchen, cpelland, cshao, dyasny, gouyang, hadong, hateya, huiwa, iheim, jboggs, knesenko, leiwang, lpeer, mburns, ovirt-maint, ycui, ykaul, zdover
Target Milestone: ---   
Target Release: 3.2.0   
Hardware: x86_64   
OS: Linux   
Whiteboard: infra
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Previously, it was not possible to change the Management Server Port in the Red Hat Enterprise Virtualization Hypervisor Textual User Interface (TUI) if the host was registered twice. The TUI has been updated so that it is now possible to change the Management Server Port at any time.
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-06-10 20:38:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Gordon Watson 2012-12-27 21:08:15 UTC
Description of problem:
On a RHEV-H host in a RHEV 3.1 environment the '/etc/vdsm-reg/vdsm-reg.conf' file initially contains "vdc_host_port=443". 

If registration of a RHEV-H host is initiated from the RHEV Manager, the host port that it uses in RHEV 3.1 is 80, and the 'vdc_host_port' value in the '/etc/vdsm-reg/vdsm-reg.conf' file is changed accordingly. However, the line becomes "vdc_host_port = 80". It now has a space before and after the '=' sign. 

If the RHEV-H host is then re-registered from RHEV-H (not from RHEV Manager), then the 'Management Server Port' value on the 'RHEV-M Configuration' menu can no longer be modified.

What happens then is that as long as communication between the host and RHEV-M via port 80 is successful, then there appears to be no issue with this change in format, other than the value can no longer be modified via the'RHEV-M Configuration' menu.


Version-Release number of selected component (if applicable):
RHEV 3.1
RHEV-H 6.3
VDSM, VDSM-REG 4.9.6-x.x.x

However, this also occurs in RHEV 3.0 with VDSM/VDSM-REG 4.9-x.x.


How reproducible:
Every time.


Steps to Reproduce:
1. Register a RHEV-H host from the RHEV Manager.

2. Re-register the RHEV-H host from RHEV-H (via the 'admin' login/'ovirt-config-setup' menus)

3. The 'Management Server Port' value on the 'RHEV-M Configuration' menu can no longer be modified.
  

Actual results:
When a RHEV-H hypervisor is registered the '/etc/vdsm-reg/vdsm-reg.conf' file is initially configured with the host port set as "vdc_host_port=443";

[vars]
# time to wait (in seconds) for the next registration request when registration fails
reg_req_interval = 5
#The location of the vdsm conf file
vdsm_conf_file=/etc/vdsm/vdsm.conf
#The location of the pid file
pidfile=/var/run/vdsm-reg.pid
#The logger conf file
logger_conf=/etc/vdsm-reg/logger.conf
#The hostname of the vdc, should be verified each boot (look for DNS SRV record)
vdc_host_name=None
#The port of the RHEV-M. Allows http or https connections.
vdc_host_port=443	
#The registrtion uri
vdc_reg_uri=/RHEVManagerWeb/VdsAutoRegistration.aspx
#Upgrade settings
upgrade_iso_file=/data/updates/ovirt-node-image.iso
upgrade_mount_point=/live
# registration ticket
ticket=


The 'vdc_host_port' value then gets written by the 'setup' script during the host registration process;

        if engine_port is not None:
            deployUtil._updateFileLine(vdsm_reg_conf_file, "vdc_host_port", str(engine_port), True)


'deployUtil._updateFileLine()' is called, which writes it specifically with no space characters;

        for line in old_file:
            #Note: the line below must not have spaces before or after the '=', since it'll fail bash scripts !
            newLine = re.sub('^[#\s]*%s\s*=.*' % key , '%s=%s' % (key, value), line)
            if re.match('^%s=%s$' % (re.escape(key), re.escape(value)), newLine):
                logging.debug("_updateFileLine: replacing " + str(line) + " with: " + newLine)
                fReplaced = True
                line = newLine

 
However, when 'vdsm-reg-setup' is then executed, it executes the following;

         if ticket:
             if registered or ticketRetries is 0:
                 config.set('vars', 'ticket', '')
                 config.write(file(confFile, 'w+'))
                 deployUtil.ovirtfunctions.ovirt_store_config(confFile)
                 ticket = ""


Prior to the call to 'config.write(), the '/etc/vdsm-reg/vdsm-reg.conf' file remains unchanged. However, inside this routine, which is 
in 'Configparser.py', the file contents are erased and new contents are written;

    380     def write(self, fp):
    381         """Write an .ini-format representation of the configuration state."""
    382         if self._defaults:
    383             fp.write("[%s]\n" % DEFAULTSECT)
    384             for (key, value) in self._defaults.items():
    385                 fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t')))
    386             fp.write("\n")
    387         for section in self._sections:
    388             fp.write("[%s]\n" % section)
    389             for (key, value) in self._sections[section].items():
    390                 if key != "__name__":
    391                     fp.write("%s = %s\n" %
    392                              (key, str(value).replace('\n', '\n\t')))
    393             fp.write("\n")


The 'self._sections' array looks like;

{'vars': {'vdc_host_port': '80', 'test_socket_timeout': '10', 'reg_req_interval': '5', 'vdsm_conf_file': '/etc/vdsm/vdsm.conf', 'vdc_reg_uri': '/SolidICE/VdsAutoRegistration.aspx', 'vdc_authkeys_path': '/rhevm.ssh.key.txt', 'vdsm_dir': '/usr/share/vdsm', 'vdc_host_ip': 'None', 'vdc_reg_port': '54321', 'logger_conf': '/etc/vdsm-reg/logger.conf', 'upgrade_iso_file': '/data/updates/ovirt-node-image.iso', 'ticket': '', 'vdc_host_name': 'None', 'pidfile': '/var/run/vdsm-reg.pid'}}


On exit, the file contents have been re-written and all entries contain a space before and after the '=' sign, e.g.

[vars]
vdc_host_port = 80
test_socket_timeout = 10
reg_req_interval = 5
vdsm_conf_file = /etc/vdsm/vdsm.conf
vdc_reg_uri = /SolidICE/VdsAutoRegistration.aspx
vdc_authkeys_path = /rhevm.ssh.key.txt
vdsm_dir = /usr/share/vdsm
vdc_host_ip = None
vdc_reg_port = 54321
logger_conf = /etc/vdsm-reg/logger.conf
upgrade_iso_file = /data/updates/ovirt-node-image.iso
ticket = 
vdc_host_name = None
pidfile = /var/run/vdsm-reg.pid



If the RHEV-H host is then re-registered from RHEV-H (not from RHEV Manager), the 'Management Server Port' value on the 'RHEV-M Configuration' menu cannot be changed.┘


If you enter a new value, e.g. 443, it will revert to 80.

The reason is that the spaces before and after the '=' sign cause 'engine.py' (and 'rhevm.py' in 3.0) not to be able to modify this value in '/etc/vdsm-reg/vdsm-reg.conf';

    if system("ping -c 1 " + engineHost):
        sed_cmd = "sed -i --copy \"s/\(^vdc_host_name=\)\(..*$\)/vdc_host_name=" + engineHost + "/\" " + VDSM_REG_CONFIG
        if system(sed_cmd):
            log("The @ENGINENAME@'s address is set: %s\n" % engineHost)
        if enginePort != "":
            sed_cmd = "sed -i --copy \"s/\(^vdc_host_port=\)\(..*$\)/vdc_host_port=" + str(enginePort) + "/\" " + VDSM_REG_CONFIG
            if system(sed_cmd):
                log("The @ENGINENAME@'s port set: %s\n" % enginePort)
            fWriteConfig=1



Expected results:
The 'Management Server Port' value on the 'RHEV-M Configuration' menu should be able to be modified.


Additional info:
This is a fairly trivial bug, but I have seen customer cases where an initial attempt to register a RHEV-H host failed and follow-up attempts have been required, and in so doing I have seen the the 'vdsm-reg.log' contain something like this, where the HTTPS connection fails, but then the HTTP connection succeeds;

MainThread::DEBUG::2012-11-02 15:02:39,773::vdsm-reg-setup::199::root::execute: after getRhevmCert: True
MainThread::DEBUG::2012-11-02 15:02:39,776::deployUtil::1265::root::getRemoteFile start. IP = 10.16.190.122 port = 8080 fileName = "/rhevm.ssh.key.txt"
MainThread::DEBUG::2012-11-02 15:02:59,790::deployUtil::1285::root::/rhevm.ssh.key.txt failed in HTTPS. Retrying using HTTP.
Traceback (most recent call last):
  File "/usr/share/vdsm-reg/deployUtil.py", line 1280, in getRemoteFile
  File "/usr/share/vdsm-reg/deployUtil.py", line 1124, in getSSLSocket
  File "/usr/lib64/python2.6/ssl.py", line 338, in wrap_socket
  File "/usr/lib64/python2.6/ssl.py", line 120, in __init__
  File "/usr/lib64/python2.6/ssl.py", line 279, in do_handshake
SSLError: [Errno 8] _ssl.c:490: EOF occurred in violation of protocol


I can't tie instances of the message sequence above specifically to this bug, and therefore haven't attached any customer cases to this bug, but it is certainly a possibility that this bug is the cause of the message sequence above. However, as long as the subsequent HTTP connection succeeds then the host registration will continue, so this bug does not necessarily cause a blocking problem. It can however potentially result in a misdiagnosis of a host registration failure, if something else in the registration sequence actually were to fail. I digress.

Comment 2 cshao 2012-12-31 03:34:43 UTC
RHEV-H QE test env as follows:
rhev-hypervisor6-6.3-20121212.0.el6_3
rhevm si25.2

1. Register a RHEV-H host from the RHEV Manager can successful.
2. Re-register the RHEV-H host from RHEV-H (via the 'admin' login/'ovirt-config-setup' menus), the 'Management Server Port' value on the 'RHEV-M Configuration' menu can be modified.

Can you re-test with the latest rhevh6.3 version?
Thanks!

Comment 3 cshao 2012-12-31 06:50:40 UTC
Maybe I misunderstand, in actually, the value of 'Management Server Port' can be changed in TUI, but if user choose apply the new value setting, it always show the original rhevm server and rhevm server port in rhev-m page.

Which means that user cannot register RHEVH to other RHEVM once it's been added to RHEVM.
So please ignore comment 2.

There is a existing bug for trace this issue.
https://bugzilla.redhat.com/show_bug.cgi?id=869867

Comment 4 Gordon Watson 2012-12-31 19:26:05 UTC
The situation is that you can enter a new value into the 'Management Server Port' field, but when you hit 'Apply' it reverts to "80" (in 3.1). If you then continue, the host registration will succeed (unless there is some other problem of course) using HTTP connection via port 80 in 'vdsm-reg-setup'.

The problem described in BZ 869867 is a different one, in which the host registration apparently fails when registering the host to a different RHEV Manager.

When I originally discovered this problem/condition, the latest version of RHEV-H was 'rhevh-6.3-20121107.0'. By the time I opened the bug, I guess a newer version had become available. I can try this newer version some time later this week. However, has there been a bug fix in this area in this newer version ?  

Basically, it appears that the issue here is a discrepancy between 'engine.py', which expects no spaces before and after the '=' sign, and 'vdsm-reg-setup', which generates a space before and after the '=' sign when it executes 'Configparser.py'.

Comment 5 Mike Burns 2013-01-02 13:41:02 UTC
Moving this to vdsm, they own the rhevm registration page in rhev-h

Comment 6 Gordon Watson 2013-01-02 17:20:05 UTC
Per the request in comment 2, I just tried the latest version of RHEV-H (6.3-20121212.0), with the same result.

Comment 8 Cheryn Tan 2013-04-03 07:02:05 UTC
This bug is currently attached to errata RHBA-2012:14332. If this change is not to be documented in the text for this errata please either remove it from the errata, set the requires_doc_text flag to minus (-), or leave a "Doc Text" value of "--no tech note required" if you do not have permission to alter the flag.

Otherwise to aid in the development of relevant and accurate release documentation, please fill out the "Doc Text" field above with these four (4) pieces of information:

* Cause: What actions or circumstances cause this bug to present.

* Consequence: What happens when the bug presents.

* Fix: What was done to fix the bug.

* Result: What now happens when the actions or circumstances above occur. (NB: this is not the same as 'the bug doesn't present anymore')

Once filled out, please set the "Doc Type" field to the appropriate value for the type of change made and submit your edits to the bug.

For further details on the Cause, Consequence, Fix, Result format please refer to:

https://bugzilla.redhat.com/page.cgi?id=fields.html#cf_release_notes

Thanks in advance.

Comment 10 Artyom 2013-05-19 09:13:45 UTC
Verified on sf16
vdsm-4.10.2-19.0.el6ev
After reproducing steps, still can modify port field in RHEV-M Configuration menu

Comment 12 errata-xmlrpc 2013-06-10 20:38:42 UTC
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.

http://rhn.redhat.com/errata/RHSA-2013-0886.html