Bug 1088589

Summary: Failure in gf_log_init reopening stderr
Product: [Community] GlusterFS Reporter: John Eckersberg <jeckersb>
Component: libglusterfsclientAssignee: Anand Avati <aavati>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: mainlineCC: bugs, chrisw, eharney, gluster-bugs, greg.markey
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: glusterfs-3.6.0beta1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1103413 1150188 (view as bug list) Environment:
Last Closed: 2014-11-11 08:30:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1103413, 1150188    

Description John Eckersberg 2014-04-16 20:24:39 UTC
The qemu gluster block driver attempts to set gluster logging to stderr as such:

    ret = glfs_set_logging(glfs, "-", 4)

And then inside gf_log_init, "-" is matched, file is set to "/dev/stderr", and the file is attempted to be reopened:

    fd = open (file, O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR);

However this fails:

    ERROR: failed to create logfile "/dev/stderr" (Permission denied)

The reason is that libvirt has already redirected stderr into the logfile for the VM and that file has restricted permissions:

[root@compute tmp]# ls -l /proc/29981/fd/2
l-wx------. 1 qemu qemu 64 Apr 16 15:11 /proc/29981/fd/2 -> /var/log/libvirt/qemu/instance-0000000b.log
[root@compute tmp]# ls -l /var/log/libvirt/qemu/instance-0000000b.log
-rw-------. 1 root root 16768 Apr 16 15:11 /var/log/libvirt/qemu/instance-0000000b.log

So the process is unable to reopen the file, but there is already an open descriptor that can be used.  In this case perhaps fall back to the old behavior that was changed by this commit?:

https://forge.gluster.org/glusterfs-core/glusterfs/commit/00b159840added72099f61f45b38133e856d23bf

Comment 1 Anand Avati 2014-04-29 20:59:19 UTC
REVIEW: http://review.gluster.org/7607 (logging: use duplicate stderr, instead of re-opening) posted (#1) for review on master by Anand Avati (avati)

Comment 2 Anand Avati 2014-05-01 06:58:22 UTC
COMMIT: http://review.gluster.org/7607 committed in master by Vijay Bellur (vbellur) 
------
commit 15ea78fffd63756fecf2f15887d3cad6a13d2a34
Author: Anand Avati <avati>
Date:   Tue Apr 29 13:54:53 2014 -0700

    logging: use duplicate stderr, instead of re-opening
    
    The special filename "-" is supposed to log to stderr. Instead of
    trying to explictly open "/dev/stderr" again (which may not be possible
    as permissions might have changed by then), dup the stderr and use
    the copy.
    
    It is not a good idea to use @stderr global variable directly, as
    ctx->log.logfile is fclose()d in glfs_fini() (was fixed in
    http://review.gluster.org/6452)
    
    Change-Id: Ia6c538fe363905588dcf4fc4783804073956a586
    BUG: 1088589
    Signed-off-by: Anand Avati <avati>
    Reviewed-on: http://review.gluster.org/7607
    Tested-by: Gluster Build System <jenkins.com>
    Reviewed-by: Vijay Bellur <vbellur>

Comment 3 Niels de Vos 2014-09-22 12:38:11 UTC
A beta release for GlusterFS 3.6.0 has been released. Please verify if the release solves this bug report for you. In case the glusterfs-3.6.0beta1 release does not have a resolution for this issue, leave a comment in this bug and move the status to ASSIGNED. If this release fixes the problem for you, leave a note and change the status to VERIFIED.

Packages for several distributions should become available in the near future. Keep an eye on the Gluster Users mailinglist [2] and the update (possibly an "updates-testing" repository) infrastructure for your distribution.

[1] http://supercolony.gluster.org/pipermail/gluster-users/2014-September/018836.html
[2] http://supercolony.gluster.org/pipermail/gluster-users/

Comment 4 Niels de Vos 2014-11-11 08:30:05 UTC
This bug is getting closed because a release has been made available that should address the reported issue. In case the problem is still not fixed with glusterfs-3.6.1, please reopen this bug report.

glusterfs-3.6.1 has been announced [1], packages for several distributions should become available in the near future. Keep an eye on the Gluster Users mailinglist [2] and the update infrastructure for your distribution.

[1] http://supercolony.gluster.org/pipermail/gluster-users/2014-November/019410.html
[2] http://supercolony.gluster.org/mailman/listinfo/gluster-users