mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
executor: fail early on reattach if listener is not executor (#24538)
This commit is contained in:
committed by
GitHub
parent
b293e6a82a
commit
4e2d9675e7
3
.changelog/24538.txt
Normal file
3
.changelog/24538.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
executor: validate executor on reattach to avoid possibility of killing non-Nomad processes
|
||||
```
|
||||
@@ -75,7 +75,11 @@ func CreateExecutor(
|
||||
return newExecutorClient(config, logger)
|
||||
}
|
||||
|
||||
// ReattachToExecutor launches a plugin with a given plugin config
|
||||
// ReattachToExecutor launches a plugin with a given plugin config and validates it can call the executor.
|
||||
// Note: On Windows, go-plugin listens on a localhost port. It is possible on a reboot that another process
|
||||
// is listening on that port, and a process is running with the previous executors PID, leading the Nomad
|
||||
// TaskRunner to kill the PID after it errors calling the Wait RPC. So, fail early via the Version RPC if
|
||||
// we detect the listener isn't actually an Executor.
|
||||
func ReattachToExecutor(reattachConfig *plugin.ReattachConfig, logger hclog.Logger, compute cpustats.Compute) (Executor, *plugin.Client, error) {
|
||||
config := &plugin.ClientConfig{
|
||||
HandshakeConfig: base.Handshake,
|
||||
@@ -84,7 +88,14 @@ func ReattachToExecutor(reattachConfig *plugin.ReattachConfig, logger hclog.Logg
|
||||
AllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC},
|
||||
Logger: logger.Named("executor"),
|
||||
}
|
||||
return newExecutorClient(config, logger)
|
||||
exec, pluginClient, err := newExecutorClient(config, logger)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if _, err := exec.Version(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return exec, pluginClient, nil
|
||||
}
|
||||
|
||||
func newExecutorClient(config *plugin.ClientConfig, logger hclog.Logger) (Executor, *plugin.Client, error) {
|
||||
|
||||
Reference in New Issue
Block a user