From 1135e42ac0e0affa5588206a825fe3980cd7c841 Mon Sep 17 00:00:00 2001 From: Jesse Hallam Date: Mon, 12 Aug 2019 18:38:25 -0300 Subject: [PATCH] MM-17488: simplify plugin health check (#11820) Simplify the plugin health check to only leverage the `Ping` API instead of sending signals, the latter of which is not supported on Windows. --- plugin/supervisor.go | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/plugin/supervisor.go b/plugin/supervisor.go index 25faa978f7..d07ece8b1c 100644 --- a/plugin/supervisor.go +++ b/plugin/supervisor.go @@ -4,14 +4,11 @@ package plugin import ( - "errors" "fmt" - "os" "os/exec" "path/filepath" "runtime" "strings" - "syscall" "time" plugin "github.com/hashicorp/go-plugin" @@ -111,13 +108,8 @@ func (sup *supervisor) Hooks() Hooks { return sup.hooks } -// PerformHealthCheck checks the plugin through a process check, an RPC ping, and a HealthCheck hook call. +// PerformHealthCheck checks the plugin through an an RPC ping. func (sup *supervisor) PerformHealthCheck() error { - if procErr := sup.CheckProcess(); procErr != nil { - mlog.Debug(fmt.Sprintf("Error checking plugin process, error: %s", procErr.Error())) - return errors.New("Plugin process not found, or not responding") - } - if pingErr := sup.Ping(); pingErr != nil { for pingFails := 1; pingFails < HEALTH_CHECK_PING_FAIL_LIMIT; pingFails++ { pingErr = sup.Ping() @@ -145,21 +137,6 @@ func (sup *supervisor) Ping() error { return client.Ping() } -// CheckProcess checks if the plugin process's PID exists and can respond to a signal. -func (sup *supervisor) CheckProcess() error { - process, err := os.FindProcess(sup.pid) - if err != nil { - return err - } - - err = process.Signal(syscall.Signal(0)) - if err != nil { - return err - } - - return nil -} - func (sup *supervisor) Implements(hookId int) bool { return sup.implemented[hookId] }