ctrox / csi-s3

A Container Storage Interface for S3
Apache License 2.0
758 stars 167 forks source link

defunct processes, the possible explanation #74

Open sterchelen opened 2 years ago

sterchelen commented 2 years ago

introduction

The following explanation is focused on using csi-s3 with goofys as a backend. All the components are in their latest version. The issue I stumbled upon is the number of goofys Zombie processes. The number doesn't have any importance in the understanding.

explanation

I looked in the csi-s3 code and more importantly at the FuseUnmount function and then at waitForProcess https://github.com/ctrox/csi-s3/blob/ddbd6fdaa1bd76754df3ea76fba0afe149ebe87d/pkg/mounter/mounter.go#L133-L156

Due to the name of the function I was expected to see a wait4 syscall to consume the child process, in our case goofys. If we look at the below outputs:

$ ps aux | grep goofys
root     32767  0.0  0.0      0     0 ?        Zs   Jun14   0:00 [goofys] <defunct>

In other words, there is a leak on child termination. The fix should be trivial; in the waitForProcess when the cmdLine is empty, we have to syscall.wait4 on the given pid. https://github.com/ctrox/csi-s3/blob/ddbd6fdaa1bd76754df3ea76fba0afe149ebe87d/pkg/mounter/mounter.go#L142-L148

wdyt @ctrox?