Change in vdsm[master]: hooks:checkips: add checkips hook

danken at redhat.com danken at redhat.com
Wed Mar 16 12:56:22 UTC 2016


Dan Kenigsberg has posted comments on this change.

Change subject: hooks:checkips: add checkips hook
......................................................................


Patch Set 3:

(5 comments)

https://gerrit.ovirt.org/#/c/54102/3/vdsm_hooks/checkips/after_get_stats.py
File vdsm_hooks/checkips/after_get_stats.py:

Line 46: TEST_DIR = '/tmp'
Line 47: CONNECTIVITY_TIMEOUT = 60
Line 48: 
Line 49: 
Line 50: def _is_connectivity(address, net, file_dir):
_is_network_accessible() is a better name
Line 51:     file_name = '{net}_{address}'.format(net=net, address=address)
Line 52:     file_path = os.path.join(file_dir, file_name)
Line 53:     if os.path.exists(file_path):
Line 54:         return (


Line 47: CONNECTIVITY_TIMEOUT = 60
Line 48: 
Line 49: 
Line 50: def _is_connectivity(address, net, file_dir):
Line 51:     file_name = '{net}_{address}'.format(net=net, address=address)
> I added it because thought we want support list of ips
that's a nice extension; but I'm not sure if we should require ALL hosts or ANY of the hosts.

I prefer to keep things simple for now, and have up to a single ip per network.
Line 52:     file_path = os.path.join(file_dir, file_name)
Line 53:     if os.path.exists(file_path):
Line 54:         return (
Line 55:             time.time() - os.stat(file_path).st_atime <=


Line 51:     file_name = '{net}_{address}'.format(net=net, address=address)
Line 52:     file_path = os.path.join(file_dir, file_name)
Line 53:     if os.path.exists(file_path):
Line 54:         return (
Line 55:             time.time() - os.stat(file_path).st_atime <=
> I check if file was touched less than one minute ago,
atime can change if someone reads the file by mistake. it makes less sense for a read to cause a change of the reported state of the network.
Line 56:             CONNECTIVITY_TIMEOUT
Line 57:         )
Line 58:     return False
Line 59: 


Line 57:         )
Line 58:     return False
Line 59: 
Line 60: 
Line 61: def allocate_given_address(stats_json, networks, file_dir):
> I can see such approach used many times under hooks, but if you want I can 
I'm afraid that the code quality of some of the hooks can be improved.


but on a second review, you can modify the stats in this function, but make sure the function name makes it clear

update_networks_sate()
Line 62:     for net, params in networks.iteritems():
Line 63:         addresses = checkips_utils.parse_addresses(params)
Line 64:         for address in addresses:
Line 65:             if not _is_connectivity(address, net, file_dir):


https://gerrit.ovirt.org/#/c/54102/3/vdsm_hooks/checkips/checkips_utils.py
File vdsm_hooks/checkips/checkips_utils.py:

Line 25: 
Line 26: def touch(address, net, file_dir):
Line 27:     file_name = '{net}_{address}'.format(net=net, address=address)
Line 28:     file_path = os.path.join(file_dir, file_name)
Line 29:     with open(file_path, 'a'):
> in this case, it just updates file time and date, file size always stays 0
oops, I thought you were appending text to it. there is no need for both open and utime. any of them would set the modification time of the file.
Line 30:         os.utime(file_path, None)
Line 31: 
Line 32: 
Line 33: def parse_addresses(params):


-- 
To view, visit https://gerrit.ovirt.org/54102
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I53cec37310f0f1844d6fe244419fd8c10e9b7ebb
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Artyom Lukianov <alukiano at redhat.com>
Gerrit-Reviewer: Artyom Lukianov <alukiano at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Edward Haas <edwardh at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list