Alon Bar-Lev has posted comments on this change.

Change subject: Avoiding automatically restart of sanlock service when starting 
vdsmd
......................................................................


Patch Set 9:

(8 comments)

....................................................
File init/sysvinit/vdsmd.init.in
Line 61:                initctl stop "${srv}" || : # stop fails when already 
down
Line 62:                initctl status "${srv}" | grep -q stop/waiting
Line 63:            elif [ -x "/etc/init.d/${srv}" ]; then
Line 64:                 ! service "${srv}" status >/dev/null 2>&1 ||
Line 65:                 service "${srv}" stop
something in the indent is wrong

use:

 service status && service stop

but we do want to have error of stop, so it should be:

 if service status; then
     service stop
 fi

this way you will get rc=0 even if service status is failing
Line 66:            else
Line 67:                true
Line 68:            fi
Line 69:         fi


....................................................
File lib/vdsm/tool/configurator.py
Line 90:     """
Line 91:     Check if sanlock service requires a restart to reload the relevant
Line 92:     supplementary groups.
Line 93:     """
Line 94:     retval = 0
always assume failure.
Line 95:     sanlock_pid_file = "/var/run/sanlock/sanlock.pid"
Line 96:     proc_status_path = "/proc/%s/status"
Line 97:     proc_status_group_prefix = "Groups:\t"
Line 98: 


Line 98: 
Line 99:     try:
Line 100:         with open(sanlock_pid_file, "r") as f:
Line 101:             sanlock_pid = f.readline().strip()
Line 102:         sanlock_status = open(proc_status_path % sanlock_pid, "r")
leak?
Line 103:     except IOError as e:
Line 104:         if e.errno == os.errno.ENOENT:
Line 105:             sys.stdout.write("sanlock service is not running\n")
Line 106:             return retval  # service is not running, returning


Line 100:         with open(sanlock_pid_file, "r") as f:
Line 101:             sanlock_pid = f.readline().strip()
Line 102:         sanlock_status = open(proc_status_path % sanlock_pid, "r")
Line 103:     except IOError as e:
Line 104:         if e.errno == os.errno.ENOENT:
why not check if exist first then fail after?

 if os.path.exists(...):
    with open ... as
Line 105:             sys.stdout.write("sanlock service is not running\n")
Line 106:             return retval  # service is not running, returning
Line 107:         raise
Line 108: 


Line 102:         sanlock_status = open(proc_status_path % sanlock_pid, "r")
Line 103:     except IOError as e:
Line 104:         if e.errno == os.errno.ENOENT:
Line 105:             sys.stdout.write("sanlock service is not running\n")
Line 106:             return retval  # service is not running, returning
please avoid return at middle.
Line 107:         raise
Line 108: 
Line 109:     for status_line in sanlock_status:
Line 110:         if status_line.startswith(proc_status_group_prefix):


Line 111:             groups = [int(x) for x in
Line 112:                       status_line[len(proc_status_group_prefix):].
Line 113:                       strip().split(" ")]
Line 114:             break
Line 115:     else:
this is *UGLY*, close should be in finally anyway.
Line 116:         sanlock_status.close()
Line 117:         raise RuntimeError("Unable to find sanlock service groups")
Line 118: 
Line 119:     sanlock_status.close()


Line 117:         raise RuntimeError("Unable to find sanlock service groups")
Line 118: 
Line 119:     sanlock_status.close()
Line 120:     diskimage_gid = grp.getgrnam(DISKIMAGE_GROUP)[2]
Line 121:     if diskimage_gid in groups:
not in... and in the success flow set retval = 0.

Now... question... why not throw RuntimeException with the error message each 
time you have an error, and have proper positive flow?
Line 122:         sys.stdout.write("sanlock service requires restart\n")
Line 123:     else:
Line 124:         sys.stdout.write("sanlock service is already configured\n")
Line 125:         retval = 1


Line 137:         service.service_stop("supervdsmd")
Line 138:         service.service_stop("libvirtd")
Line 139: 
Line 140:     if not configure_libvirt(*args):
Line 141:         sys.stderr.write("failed to run configure-libvirt\n")
and exit/throw with error? you cannot continue as usual.
Line 142:     if sanlock_check_service(*args):


-- 
To view, visit http://gerrit.ovirt.org/19890
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I48658066f707632719df8d65799d26c7b239dcd5
Gerrit-PatchSet: 9
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <ybron...@redhat.com>
Gerrit-Reviewer: Alon Bar-Lev <alo...@redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <dan...@redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybron...@redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to