* Alon Bar-Lev <alo...@redhat.com> [2012-09-05 16:11]:
> Alon Bar-Lev has uploaded a new change for review.
> 
> Change subject: bootstrap: perform reboot asynchronously
> ......................................................................
> 
> bootstrap: perform reboot asynchronously
> 
> The use of /sbin/reboot may cause reboot to be performed at the middle
> of script execution.
> 
> Reboot should be delayed in background so that script will have a fair
> chance to terminate properly.

So, we fork and sleep 10 seconds?  Is that really want we want to do?
Why is 10 seconds enough?  

Shouldn't the deployUtil be tracking the script execution and waiting
for the scripts to complete before rebooting?


> 
> Change-Id: I0abb02ae4d5033a8b9f2d468da86fcdc53e2e1c2
> Signed-off-by: Alon Bar-Lev <alo...@redhat.com>
> ---
> M vdsm_reg/deployUtil.py.in
> 1 file changed, 39 insertions(+), 5 deletions(-)
> 
> 
>   git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/83/7783/1
> 
> diff --git a/vdsm_reg/deployUtil.py.in b/vdsm_reg/deployUtil.py.in
> index ebc7d36..b72cb44 100644
> --- a/vdsm_reg/deployUtil.py.in
> +++ b/vdsm_reg/deployUtil.py.in
> @@ -166,13 +166,47 @@
>  
>  def reboot():
>      """
> -        This function reboots the machine.
> +        This function reboots the machine async
>      """
> -    fReturn = True
> +    fReturn = False
>  
> -    out, err, ret = _logExec([EX_REBOOT])
> -    if ret:
> -        fReturn = False
> +    # Default maximum for the number of available file descriptors.
> +    MAXFD = 1024
> +
> +    import resource  # Resource usage information.
> +    maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
> +    if (maxfd == resource.RLIM_INFINITY):
> +        maxfd = MAXFD
> +
> +    try:
> +        pid = os.fork()
> +        if pid == 0:
> +            try:
> +                os.setsid()
> +                for fd in range(0, maxfd):
> +                    try:
> +                        os.close(fd)
> +                    except OSError:  # ERROR, fd wasn't open to begin with 
> (ignored)
> +                        pass
> +
> +                os.open(os.devnull, os.O_RDWR)  # standard input (0)
> +                os.dup2(0, 1)  # standard output (1)
> +                os.dup2(0, 2)  # standard error (2)
> +
> +                if os.fork() != 0:
> +                    os._exit(0)
> +
> +                time.sleep(10)
> +                os.execl(EX_REBOOT, EX_REBOOT)
> +            finally:
> +                os._exit(1)
> +
> +        pid, status = os.waitpid(pid, 0)
> +
> +        if os.WIFEXITED(status) and os.WEXITSTATUS(status) == 0:
> +            fReturn = True
> +    except OSError:
> +        pass
>  
>      return fReturn
>  
> 
> 
> --
> To view, visit http://gerrit.ovirt.org/7783
> To unsubscribe, visit http://gerrit.ovirt.org/settings
> 
> Gerrit-MessageType: newchange
> Gerrit-Change-Id: I0abb02ae4d5033a8b9f2d468da86fcdc53e2e1c2
> Gerrit-PatchSet: 1
> Gerrit-Project: vdsm
> Gerrit-Branch: master
> Gerrit-Owner: Alon Bar-Lev <alo...@redhat.com>
> _______________________________________________
> vdsm-patches mailing list
> vdsm-patc...@lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
ry...@us.ibm.com

_______________________________________________
vdsm-devel mailing list
vdsm-devel@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-devel

Reply via email to