mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 00:07:50 +00:00
refactor(kubelet): use errors.Is(err, os.ErrProcessDone)
use errors.Is(err, os.ErrProcessDone) here and remove "process already finished" string comparison. Signed-off-by: cndoit18 <cndoit18@outlook.com>
This commit is contained in:
parent
f5be5052e3
commit
601d02b90f
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package cm
|
package cm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@ -127,10 +128,7 @@ func (m *podContainerManagerImpl) killOnePid(pid int) error {
|
|||||||
p, _ := os.FindProcess(pid)
|
p, _ := os.FindProcess(pid)
|
||||||
if err := p.Kill(); err != nil {
|
if err := p.Kill(); err != nil {
|
||||||
// If the process already exited, that's fine.
|
// If the process already exited, that's fine.
|
||||||
if strings.Contains(err.Error(), "process already finished") {
|
if errors.Is(err, os.ErrProcessDone) {
|
||||||
// Hate parsing strings, but
|
|
||||||
// vendor/github.com/opencontainers/runc/libcontainer/
|
|
||||||
// also does this.
|
|
||||||
klog.V(3).InfoS("Process no longer exists", "pid", pid)
|
klog.V(3).InfoS("Process no longer exists", "pid", pid)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user