Change in vdsm[master]: gluster: Added gluster hooks support

abaron at redhat.com abaron at redhat.com
Mon Apr 22 21:34:52 UTC 2013


Ayal Baron has posted comments on this change.

Change subject: gluster: Added gluster hooks support
......................................................................


Patch Set 23: (2 inline comments)

....................................................
File vdsm/gluster/hooks.py
Line 133: @exportToSuperVdsm
Line 134: def hookEnable(glusterCmd, hookLevel, hookName):
Line 135:     enabledFile, disabledFile = _getHookFileNames(glusterCmd,
Line 136:                                                   hookLevel.lower(), hookName)
Line 137:     if os.path.exists(disabledFile):
this is racy by nature.  you could check if errno == ENOENT in the except clause instead
Line 138:         try:
Line 139:             os.rename(disabledFile, enabledFile)
Line 140:             st = os.stat(enabledFile)
Line 141:             os.chmod(enabledFile, st.st_mode | stat.S_IEXEC)


Line 137:     if os.path.exists(disabledFile):
Line 138:         try:
Line 139:             os.rename(disabledFile, enabledFile)
Line 140:             st = os.stat(enabledFile)
Line 141:             os.chmod(enabledFile, st.st_mode | stat.S_IEXEC)
why not toggle enable/disable by just changing the executable bit on the file.  That way you don't need to rename the file and check existence of both enabled and disabled and cannot reach a state where you have the same hook both enabled and disabled at the same time etc.
Line 142:         except OSError, e:
Line 143:             errMsg = "[Errno %s] %s: '%s'" % (e.errno, e.strerror, e.filename)
Line 144:             raise ge.GlusterHookEnableFailedException(err=[errMsg])
Line 145:     elif not os.path.exists(enabledFile):


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I3918aa035d90967f1297dc7fadcf14b6a9385c45
Gerrit-PatchSet: 23
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Timothy Asir <tjeyasin at redhat.com>
Gerrit-Reviewer: Aravinda VK <avishwan at redhat.com>
Gerrit-Reviewer: Ayal Baron <abaron at redhat.com>
Gerrit-Reviewer: Bala.FA <barumuga at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce at redhat.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi at redhat.com>
Gerrit-Reviewer: Timothy Asir <tjeyasin at redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server


More information about the vdsm-patches mailing list