Provide an option to supply log-file mount option for gluster plugin.

At present, `log-file` location of glusterfs client mount is decided
by the plugin, however at times, users/admin want to configure log-file
of gluster fuse client process on their own in some setups. Even though they can pass log-file
mount option through storage class, before this patch glusterfs plugin
always discard it. This patch enable/give preference
to admin supplied log-file mount option if specified in storage class.
If the log-file mount option is incomplete or wrong, plugin fallback to the
location which is carved out by the combination of pvc and pod name.

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
pull/8/head
Humble Chirammal 2018-07-23 20:31:35 +05:30 committed by hchiramm
parent 85b8a23f19
commit 9e29ab985b
1 changed files with 28 additions and 9 deletions

View File

@ -288,12 +288,27 @@ func (c *glusterfsUnmounter) TearDownAt(dir string) error {
func (b *glusterfsMounter) setUpAtInternal(dir string) error {
var errs error
options := []string{}
hasLogFile := false
log := ""
if b.readOnly {
options = append(options, "ro")
}
// Check logfile has been provided by user, if provided, use that as the log file.
for _, userOpt := range b.mountOptions {
if dstrings.HasPrefix(userOpt, "log-file") {
glog.V(4).Infof("log-file mount option has provided")
hasLogFile = true
break
}
}
// If logfile has not been provided, create driver specific log file.
if !hasLogFile {
log = ""
p := path.Join(b.glusterfs.plugin.host.GetPluginDir(glusterfsPluginName), b.glusterfs.volName)
if err := os.MkdirAll(p, 0750); err != nil {
return fmt.Errorf("failed to create directory %v: %v", p, err)
@ -302,9 +317,13 @@ func (b *glusterfsMounter) setUpAtInternal(dir string) error {
// adding log-level ERROR to remove noise
// and more specific log path so each pod has
// its own log based on PV + Pod
log := path.Join(p, b.pod.Name+"-glusterfs.log")
options = append(options, "log-level=ERROR")
log = path.Join(p, b.pod.Name+"-glusterfs.log")
}
// Use derived/provided log file in gluster fuse mount
options = append(options, "log-file="+log)
options = append(options, "log-level=ERROR")
var addrlist []string
if b.hosts == nil {