mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Merge pull request #107250 from cndoit18/use-errors
cleanup(kubelet): use errors.Is(err, os.ErrProcessDone)
This commit is contained in:
commit
cadbe8dfb5
@ -17,6 +17,7 @@ limitations under the License.
|
||||
package cm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@ -127,10 +128,7 @@ func (m *podContainerManagerImpl) killOnePid(pid int) error {
|
||||
p, _ := os.FindProcess(pid)
|
||||
if err := p.Kill(); err != nil {
|
||||
// If the process already exited, that's fine.
|
||||
if strings.Contains(err.Error(), "process already finished") {
|
||||
// Hate parsing strings, but
|
||||
// vendor/github.com/opencontainers/runc/libcontainer/
|
||||
// also does this.
|
||||
if errors.Is(err, os.ErrProcessDone) {
|
||||
klog.V(3).InfoS("Process no longer exists", "pid", pid)
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user