mirror of https://github.com/k3s-io/k3s
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
parent
85b8a23f19
commit
9e29ab985b
|
@ -288,23 +288,42 @@ func (c *glusterfsUnmounter) TearDownAt(dir string) error {
|
||||||
|
|
||||||
func (b *glusterfsMounter) setUpAtInternal(dir string) error {
|
func (b *glusterfsMounter) setUpAtInternal(dir string) error {
|
||||||
var errs error
|
var errs error
|
||||||
|
|
||||||
options := []string{}
|
options := []string{}
|
||||||
|
hasLogFile := false
|
||||||
|
log := ""
|
||||||
|
|
||||||
if b.readOnly {
|
if b.readOnly {
|
||||||
options = append(options, "ro")
|
options = append(options, "ro")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p := path.Join(b.glusterfs.plugin.host.GetPluginDir(glusterfsPluginName), b.glusterfs.volName)
|
// Check logfile has been provided by user, if provided, use that as the log file.
|
||||||
if err := os.MkdirAll(p, 0750); err != nil {
|
for _, userOpt := range b.mountOptions {
|
||||||
return fmt.Errorf("failed to create directory %v: %v", p, err)
|
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
|
// If logfile has not been provided, create driver specific log file.
|
||||||
// and more specific log path so each pod has
|
if !hasLogFile {
|
||||||
// its own log based on PV + Pod
|
log = ""
|
||||||
log := path.Join(p, b.pod.Name+"-glusterfs.log")
|
p := path.Join(b.glusterfs.plugin.host.GetPluginDir(glusterfsPluginName), b.glusterfs.volName)
|
||||||
options = append(options, "log-level=ERROR")
|
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-file="+log)
|
||||||
|
options = append(options, "log-level=ERROR")
|
||||||
|
|
||||||
var addrlist []string
|
var addrlist []string
|
||||||
if b.hosts == nil {
|
if b.hosts == nil {
|
||||||
|
|
Loading…
Reference in New Issue