mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 06:01:50 +00:00
Override the GlusterFS log file location
GlusterFS by default uses a log file based on the mountpoint path munged into a file, i.e. `/mnt/foo/bar` becomes `/var/log/glusterfs/mnt-foo-bar.log`. On certain Kubernetes environments this can result in a log file that exceeds the 255 character length most filesystems impose on filenames causing the mount to fail. Instead, use the `log-file` mount option to place the log file under the kubelet plugin directory with a filename of our choosing keeping it fairly persistent in the case of troubleshooting.
This commit is contained in:
@@ -17,8 +17,8 @@ limitations under the License.
|
|||||||
package glusterfs
|
package glusterfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
@@ -221,12 +221,23 @@ func (b *glusterfsBuilder) setUpAtInternal(dir string) error {
|
|||||||
options = append(options, "ro")
|
options = append(options, "ro")
|
||||||
}
|
}
|
||||||
|
|
||||||
l := len(b.hosts.Subsets)
|
p := path.Join(b.glusterfs.plugin.host.GetPluginDir(glusterfsPluginName), b.glusterfs.volName)
|
||||||
|
if err := os.MkdirAll(p, 0750); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log := path.Join(p, "glusterfs.log")
|
||||||
|
options = append(options, "log-file="+log)
|
||||||
|
|
||||||
|
addr := make(map[string]struct{})
|
||||||
|
for _, s := range b.hosts.Subsets {
|
||||||
|
for _, a := range s.Addresses {
|
||||||
|
addr[a.IP] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Avoid mount storm, pick a host randomly.
|
// Avoid mount storm, pick a host randomly.
|
||||||
start := rand.Int() % l
|
|
||||||
// Iterate all hosts until mount succeeds.
|
// Iterate all hosts until mount succeeds.
|
||||||
for i := start; i < start+l; i++ {
|
for hostIP := range addr {
|
||||||
hostIP := b.hosts.Subsets[i%l].Addresses[0].IP
|
|
||||||
errs = b.mounter.Mount(hostIP+":"+b.path, dir, "glusterfs", options)
|
errs = b.mounter.Mount(hostIP+":"+b.path, dir, "glusterfs", options)
|
||||||
if errs == nil {
|
if errs == nil {
|
||||||
return nil
|
return nil
|
||||||
|
Reference in New Issue
Block a user