Merge pull request #66675 from humblec/log-file

Automatic merge from submit-queue (batch tested with PRs 61389, 66817, 66903, 66675, 66965). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

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>



**What this PR does / why we need it**:

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note

```
pull/8/head
Kubernetes Submit Queue 2018-08-03 07:33:16 -07:00 committed by GitHub
commit 55d6a013e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 9 deletions

View File

@ -288,23 +288,42 @@ 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")
}
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)
// 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
}
}
// 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")
// 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)
}
// 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")
}
// 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 {