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

danken at redhat.com danken at redhat.com
Wed Mar 16 05:03:57 UTC 2016


Dan Kenigsberg has posted comments on this change.

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


Patch Set 3:

(8 comments)

partial review

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

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)
things would be simpler if the touched file was simply named as the network, right?
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 <=
you should care about creation time, not access time. right?
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):
try to avoid funtions that modify their args
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
File vdsm_hooks/checkips/checkips:

Line 38:         return False
Line 39:     return True
Line 40: 
Line 41: 
Line 42: def _is_address_connective(address, interface, net):
this function does not return a bool, it should not start with "is"
Line 43:     ping = 'ping' if _is_ipv4_address(address) else 'ping6'
Line 44:     command = [
Line 45:         ping, '-c', '1', '-w', str(PING_TIMEOUT), '-I', interface, address
Line 46:     ]


Line 51: 
Line 52: def _ping_addresses():
Line 53:     threads = []
Line 54:     networks = persist_net.PersistentConfig().networks
Line 55:     for net, params in networks.iteritems():
new code ahould be python3-aware. use six.iteritems
Line 56:         addresses = checkips_utils.parse_addresses(params)
Line 57:         for address in addresses:
Line 58:             ping_thread = threading.Thread(
Line 59:                 target=_is_address_connective,


Line 65:     for ping_thread in threads:
Line 66:         ping_thread.join()
Line 67: 
Line 68: 
Line 69: class TimerThread(threading.Thread):
this seems excessively complex. could you have a simple main function that runs ping threads, waits for them to finish, waits until PING_SAMPLE time expires (time.sleep should be enough) and repeats?
Line 70:     def __init__(self, event, target=None, args=(), kwargs=None):
Line 71:         super(TimerThread, self).__init__()
Line 72:         self.event = event
Line 73:         self.__target = target


https://gerrit.ovirt.org/#/c/54102/3/vdsm_hooks/checkips/checkips.service.in
File vdsm_hooks/checkips/checkips.service.in:

Line 1: [Unit]
Line 2: Description=Service that ping given ips each 60 seconds
Line 3: Requires=vdsmd.service
Line 4: After=vdsmd.service
does this really need a running vdsm?
Line 5: 
Line 6: [Service]
Line 7: Type=simple
Line 8: LimitCORE=infinity


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'):
letting a file to endlessly grow is not a good idea
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: 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