Skip to content

Commit d05b447

Browse files
committed
support dumplable-setting in global configmap
1 parent bfe2531 commit d05b447

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

pkg/mounter/oss/ossfs.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ func (f *fuseOssfs) buildPodSpec(c *mounterutils.FusePodContext, target string)
221221

222222
container.Args = []string{"--socket=" + socketPath, "-v=4"}
223223

224+
if strings.ToLower(f.config.Extra["set-dumpable"]) == "true" {
225+
container.Env = append(container.Env, corev1.EnvVar{Name: "SET_DUMPABLE", Value: "true"})
226+
}
227+
224228
spec.Containers = []corev1.Container{container}
225229
spec.NodeName = c.NodeName
226230
spec.HostNetwork = true

pkg/mounter/oss/ossfs2.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ func (f *fuseOssfs2) buildPodSpec(c *mounterutils.FusePodContext, target string)
246246

247247
container.Args = []string{"--socket=" + socketPath, "-v=4"}
248248

249+
if strings.ToLower(f.config.Extra["set-dumpable"]) == "true" {
250+
container.Env = append(container.Env, corev1.EnvVar{Name: "SET_DUMPABLE", Value: "true"})
251+
}
252+
249253
spec.Containers = []corev1.Container{container}
250254
spec.NodeName = c.NodeName
251255
spec.HostNetwork = true

pkg/mounter/proxy/server/ossfs/driver.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ func (h *Driver) Mount(ctx context.Context, req *proxy.MountRequest) error {
8181
pid := cmd.Process.Pid
8282
klog.InfoS("Started ossfs", "pid", pid, "args", args)
8383

84-
err = unix.Prctl(unix.PR_SET_DUMPABLE, 1, 0, 0, 0)
85-
if err != nil {
86-
klog.ErrorS(err, "Failed to set process as dumpable")
84+
if dumpable := os.Getenv("SET_DUMPABLE"); dumpable == "true" {
85+
err = unix.Prctl(unix.PR_SET_DUMPABLE, 1, 0, 0, 0)
86+
if err != nil {
87+
klog.ErrorS(err, "Failed to set process as dumpable")
88+
}
8789
}
8890

8991
ossfsExited := make(chan error, 1)

pkg/mounter/proxy/server/ossfs2/driver.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ func (h *Driver) Mount(ctx context.Context, req *proxy.MountRequest) error {
8787
pid := cmd.Process.Pid
8888
klog.InfoS("Started ossfs2", "pid", pid, "args", args)
8989

90-
err = unix.Prctl(unix.PR_SET_DUMPABLE, 1, 0, 0, 0)
91-
if err != nil {
92-
klog.ErrorS(err, "Failed to set process as dumpable")
90+
if dumpable := os.Getenv("SET_DUMPABLE"); dumpable == "true" {
91+
err = unix.Prctl(unix.PR_SET_DUMPABLE, 1, 0, 0, 0)
92+
if err != nil {
93+
klog.ErrorS(err, "Failed to set process as dumpable")
94+
}
9395
}
9496

9597
ossfsExited := make(chan error, 1)

pkg/mounter/utils/fuse_pod_manager.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ func ExtractFuseContainerConfig(configmap *corev1.ConfigMap, name string) (confi
174174
invalid = true
175175
}
176176
default:
177+
// Initialize Extra map if nil. Currently supported keys in Extra:
178+
// - "set-dumpable": enables dumpable flag for process of ossfs 1.0 / ossfs 2.0
179+
// - "mime-support": enables MIME type support for ossfs 1.0
177180
if config.Extra == nil {
178181
config.Extra = make(map[string]string)
179182
}

0 commit comments

Comments
 (0)