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

Bug 917485

Summary: Exception was shown when setting NTP Server/NFS kdump with valid value.
Product: [Retired] oVirt Reporter: haiyang,dong <hadong>
Component: ovirt-nodeAssignee: Fabian Deutsch <fdeutsch>
Status: CLOSED CURRENTRELEASE QA Contact: bugs <bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.2CC: acathrow, cshao, fdeutsch, gouyang, hadong, jboggs, leiwang, mgoldboi, ovirt-bugs, ovirt-maint, ycui
Target Milestone: ---   
Target Release: 3.4.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: node
Fixed In Version: ovirt-node-3.0.0 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-04-30 10:51:39 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:
Attachments:
Description Flags
attached Screenshot for exception none

Description haiyang,dong 2013-03-04 07:36:21 UTC
Created attachment 704783 [details]
attached Screenshot for exception

Description of problem:
Install ovirt-node-upstream, configure network with "static", enter network page, then setting NTP Server with valid ip address.
But Exception was shown after clicking "Save" button.(Seen exception.png)

Also Exception was shown when configure NFS kdump with valid value.

Version-Release number of selected component (if applicable):
ovirt-node-iso-2.6.1-20120228.fc18.iso        

Steps to Reproduce:
1. Install ovirt-node-upstream, configure network with "static".
2. enter network page, then setting NTP Server with valid ip address.


Actual results:
Exception was shown after clicking "Save" button.

Expected results:
setting NTP Server with valid value should be successful.

Additional info:
----------

Comment 1 Fabian Deutsch 2013-03-04 08:59:17 UTC
http://gerrit.ovirt.org/#/c/12616/

Comment 3 haiyang,dong 2013-03-05 02:01:14 UTC
Maybe the root cause happens here, but i'm not sure about it:

>>> FQDN().validate("example.com")
    True
 >>> FQDN().validate("0.rhel.pool.ntp.org")
    False

So for ntp server "0.rhel.pool.ntp.org", it return "False", but actually "0.rhel.pool.ntp.org" is valid ntp server.


Change the class FQDN(RegexValidator) into follow can fix the issue:

class FQDN(RegexValidator):
 
    description = "a valid FQDN"
#    pattern = ("^(([a-z]|[a-z][a-z0-9\-]*[a-z0-9])\.)" +
#              "*([a-z]|[a-z][a-z0-9\-]*[a-z0-9])$", re.I)
    pattern = ("^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)" +
               "*([a-z]|[a-z][a-z0-9\-]*[a-z0-9])$", re.I)


 >>> FQDN().validate("example.com")
    True
 >>> FQDN().validate("0.rhel.pool.ntp.org")
    True
 >>> FQDN().validate("0.Rhel0.pool.ntp.org"
    True
 >>> FQDN().validate("example.com.")
    False
 >>> FQDN().validate("")
    False

Comment 5 Fabian Deutsch 2013-03-05 09:41:12 UTC
(In reply to comment #3)
> Maybe the root cause happens here, but i'm not sure about it:
> 
> >>> FQDN().validate("example.com")
>     True
>  >>> FQDN().validate("0.rhel.pool.ntp.org")
>     False
> 
> So for ntp server "0.rhel.pool.ntp.org", it return "False", but actually
> "0.rhel.pool.ntp.org" is valid ntp server.
> 
> 
> Change the class FQDN(RegexValidator) into follow can fix the issue:
> 
> class FQDN(RegexValidator):
>  
>     description = "a valid FQDN"
> #    pattern = ("^(([a-z]|[a-z][a-z0-9\-]*[a-z0-9])\.)" +
> #              "*([a-z]|[a-z][a-z0-9\-]*[a-z0-9])$", re.I)
>     pattern = ("^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)" +
>                "*([a-z]|[a-z][a-z0-9\-]*[a-z0-9])$", re.I)
> 
> 
>  >>> FQDN().validate("example.com")
>     True
>  >>> FQDN().validate("0.rhel.pool.ntp.org")
>     True
>  >>> FQDN().validate("0.Rhel0.pool.ntp.org"
>     True
>  >>> FQDN().validate("example.com.")
>     False
>  >>> FQDN().validate("")
>     False

Nice catch, I'll look into it ..

Comment 6 Fabian Deutsch 2013-03-11 15:55:21 UTC
This patch should also attack this problem (in addition to the patch above):
http://gerrit.ovirt.org/#/c/12733/

Comment 7 haiyang,dong 2013-05-23 08:41:23 UTC
Hey fabian,

Using the iso "ovirt-node-iso-3.0.0-1.0.20130517.fc18" to setting NTP Server/NFS kdump with valid value, it work well for setting NTP Server with valid value.
But still failed for setting NFS kdump with valid value(10.66.11.23:/var/nfsserver).

I was confused that the line 796 of the follow code in defaults.py


    794     @NodeConfigFileSection.map_and_update_defaults_decorator
    795     def update(self, nfs, ssh, local):
    796         (valid.Empty(or_none=True) | valid.FQDNOrIPAddress())(nfs)
    797         (valid.Empty(or_none=True) | valid.URL())(ssh)
    798         (valid.Empty(or_none=True) | valid.Boolean())(local)
    799         return {"OVIRT_KDUMP_LOCAL": "true" if local else None
    800                 }

why using the function "FQDNOrIPAddress" to check the nfs value is valid or not:


>>> valid.FQDNOrIPAddress()("10.66.11.23:/var/nfsserver")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/ovirt/node/valid.py", line 63, in __call__
  File "/usr/lib/python2.7/site-packages/ovirt/node/valid.py", line 69, in raise_exception
ovirt.node.exceptions.InvalidData: 'The field must contain a valid FQDN or a valid IPv4 address or a valid IPv6 address.'
>>>

Comment 8 Fabian Deutsch 2013-05-23 11:31:15 UTC
Hey Haiyang,

I suppose my patch was incomplete. A validator for a NFS address needs to be added.

Comment 9 Fabian Deutsch 2013-05-23 15:21:41 UTC
 http://gerrit.ovirt.org/15034


I've added doctests to test all sorts of nfs urls, would be nice, if you, Haiyang, could tak a look at the patch and see if I missed an important corner case in the doctest (so addresses to be validated)

Comment 10 Sandro Bonazzola 2014-03-04 09:18:54 UTC
This is an automated message.
Re-targeting all non-blocker bugs still open on 3.4.0 to 3.4.1.