Skip to content

Commit f759bcd

Browse files
authored
Merge pull request #1395 from AlbeeSo/feat/auto-coredump
set ossfs process dumpable
2 parents a22b6b6 + d05b447 commit f759bcd

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-0
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"syscall"
1313
"time"
1414

15+
"golang.org/x/sys/unix"
16+
1517
"github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/mounter/proxy"
1618
"github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/mounter/proxy/server"
1719
serverutils "github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/mounter/proxy/server"
@@ -79,6 +81,13 @@ func (h *Driver) Mount(ctx context.Context, req *proxy.MountRequest) error {
7981
pid := cmd.Process.Pid
8082
klog.InfoS("Started ossfs", "pid", pid, "args", args)
8183

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+
}
89+
}
90+
8291
ossfsExited := make(chan error, 1)
8392
h.wg.Add(1)
8493
h.pids.Store(pid, cmd)

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"syscall"
1313
"time"
1414

15+
"golang.org/x/sys/unix"
16+
1517
"github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/mounter/proxy"
1618
"github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/mounter/proxy/server"
1719
serverutils "github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/mounter/proxy/server"
@@ -85,6 +87,13 @@ func (h *Driver) Mount(ctx context.Context, req *proxy.MountRequest) error {
8587
pid := cmd.Process.Pid
8688
klog.InfoS("Started ossfs2", "pid", pid, "args", args)
8789

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+
}
95+
}
96+
8897
ossfsExited := make(chan error, 1)
8998
h.wg.Add(1)
9099
h.pids.Store(pid, cmd)

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)