Skip to content

Commit

Permalink
fuse: bind connections into mount pod (#741)
Browse files Browse the repository at this point in the history
* fuse: bind connections into mount pod

Signed-off-by: xixi <[email protected]>
  • Loading branch information
Hexilee authored Sep 7, 2023
1 parent c168866 commit ee51baa
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 16 deletions.
2 changes: 2 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ var (
JFSMountPriorityName = "system-node-critical"
JFSMountPreemptionPolicy = ""

FuseConnectionPath = "/sys/fs/fuse/connections"

TmpPodMountBase = "/tmp"
PodMountBase = "/jfs"
MountBase = "/var/lib/jfs"
Expand Down
51 changes: 35 additions & 16 deletions pkg/juicefs/mount/builder/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ import (
)

const (
JfsDirName = "jfs-dir"
JfsRootDirName = "jfs-root-dir"
UpdateDBDirName = "updatedb"
UpdateDBCfgFile = "/etc/updatedb.conf"
JfsDirName = "jfs-dir"
FuseConnectinsName = "fuse-connections"
JfsRootDirName = "jfs-root-dir"
UpdateDBDirName = "updatedb"
UpdateDBCfgFile = "/etc/updatedb.conf"
)

type Builder struct {
Expand Down Expand Up @@ -86,15 +87,26 @@ func (r *Builder) getVolumes() []corev1.Volume {
dir := corev1.HostPathDirectoryOrCreate
file := corev1.HostPathFileOrCreate
secretName := r.jfsSetting.SecretName
volumes := []corev1.Volume{{
Name: JfsDirName,
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: config.MountPointPath,
Type: &dir,
volumes := []corev1.Volume{
{
Name: JfsDirName,
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: config.MountPointPath,
Type: &dir,
},
},
},
}}
{
Name: FuseConnectinsName,
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: config.FuseConnectionPath,
Type: &dir,
},
},
},
}

if !config.Immutable {
volumes = append(volumes, corev1.Volume{
Expand Down Expand Up @@ -159,11 +171,18 @@ func (r *Builder) getVolumes() []corev1.Volume {

func (r *Builder) getVolumeMounts() []corev1.VolumeMount {
mp := corev1.MountPropagationBidirectional
volumeMounts := []corev1.VolumeMount{{
Name: JfsDirName,
MountPath: config.PodMountBase,
MountPropagation: &mp,
}}
volumeMounts := []corev1.VolumeMount{
{
Name: JfsDirName,
MountPath: config.PodMountBase,
MountPropagation: &mp,
},
{
Name: FuseConnectinsName,
MountPath: config.FuseConnectionPath,
MountPropagation: &mp,
},
}

if !config.Immutable {
volumeMounts = append(volumeMounts, corev1.VolumeMount{
Expand Down
12 changes: 12 additions & 0 deletions pkg/juicefs/mount/builder/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ var (
Type: &dir,
},
},
}, {
Name: FuseConnectinsName,
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: config.FuseConnectionPath,
Type: &dir,
},
},
}, {
Name: UpdateDBDirName,
VolumeSource: corev1.VolumeSource{
Expand Down Expand Up @@ -106,6 +114,10 @@ var (
MountPath: config.PodMountBase,
MountPropagation: &mp,
}, {
Name: FuseConnectinsName,
MountPath: config.FuseConnectionPath,
MountPropagation: &mp,
}, {

Name: UpdateDBDirName,
MountPath: UpdateDBCfgFile,
Expand Down

0 comments on commit ee51baa

Please sign in to comment.