Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
75d333fe
Commit
75d333fe
authored
6 years ago
by
Danielle Tomlinson
Browse files
Options
Download
Email Patches
Plain Diff
client: Move executor plugins into own package
parent
d4ef3b68
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
client/driver/exec.go
+3
-2
client/driver/exec.go
client/driver/executor_plugin/executor_plugin.go
+1
-1
client/driver/executor_plugin/executor_plugin.go
client/driver/executor_plugin/executor_plugin_pre_0_9_0.go
+1
-1
client/driver/executor_plugin/executor_plugin_pre_0_9_0.go
client/driver/executor_plugin/plugins.go
+1
-1
client/driver/executor_plugin/plugins.go
client/driver/java.go
+3
-2
client/driver/java.go
client/driver/qemu.go
+3
-2
client/driver/qemu.go
client/driver/raw_exec.go
+3
-2
client/driver/raw_exec.go
client/driver/utils.go
+6
-5
client/driver/utils.go
command/executor_plugin.go
+3
-3
command/executor_plugin.go
plugins/drivers/utils/utils.go
+6
-6
plugins/drivers/utils/utils.go
with
30 additions
and
25 deletions
+30
-25
client/driver/exec.go
+
3
-
2
View file @
75d333fe
...
...
@@ -12,6 +12,7 @@ import (
"github.com/hashicorp/go-multierror"
"github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/client/allocdir"
"github.com/hashicorp/nomad/client/driver/executor_plugin"
dstructs
"github.com/hashicorp/nomad/client/driver/structs"
cstructs
"github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/drivers/shared/executor"
...
...
@@ -175,7 +176,7 @@ type execId struct {
KillTimeout
time
.
Duration
MaxKillTimeout
time
.
Duration
UserPid
int
PluginConfig
*
PluginReattachConfig
PluginConfig
*
executorplugin
.
PluginReattachConfig
}
func
(
d
*
ExecDriver
)
Open
(
ctx
*
ExecContext
,
handleID
string
)
(
DriverHandle
,
error
)
{
...
...
@@ -222,7 +223,7 @@ func (h *execHandle) ID() string {
Version
:
h
.
version
,
KillTimeout
:
h
.
killTimeout
,
MaxKillTimeout
:
h
.
maxKillTimeout
,
PluginConfig
:
NewPluginReattachConfig
(
h
.
pluginClient
.
ReattachConfig
()),
PluginConfig
:
executorplugin
.
NewPluginReattachConfig
(
h
.
pluginClient
.
ReattachConfig
()),
UserPid
:
h
.
userPid
,
}
...
...
This diff is collapsed.
Click to expand it.
client/driver/executor_plugin.go
→
client/driver/executor_plugin
/executor_plugin
.go
+
1
-
1
View file @
75d333fe
package
driver
package
executorplugin
import
(
"encoding/gob"
...
...
This diff is collapsed.
Click to expand it.
client/driver/executor_plugin_pre_0_9_0.go
→
client/driver/executor_plugin
/executor_plugin
_pre_0_9_0.go
+
1
-
1
View file @
75d333fe
package
driver
package
executorplugin
/*
import (
...
...
This diff is collapsed.
Click to expand it.
client/driver/plugins.go
→
client/driver/
executor_plugin/
plugins.go
+
1
-
1
View file @
75d333fe
package
driver
package
executorplugin
import
(
"io"
...
...
This diff is collapsed.
Click to expand it.
client/driver/java.go
+
3
-
2
View file @
75d333fe
...
...
@@ -18,6 +18,7 @@ import (
"github.com/hashicorp/go-plugin"
"github.com/mitchellh/mapstructure"
"github.com/hashicorp/nomad/client/driver/executor_plugin"
dstructs
"github.com/hashicorp/nomad/client/driver/structs"
"github.com/hashicorp/nomad/client/fingerprint"
cstructs
"github.com/hashicorp/nomad/client/structs"
...
...
@@ -307,7 +308,7 @@ type javaId struct {
Version
string
KillTimeout
time
.
Duration
MaxKillTimeout
time
.
Duration
PluginConfig
*
PluginReattachConfig
PluginConfig
*
executorplugin
.
PluginReattachConfig
TaskDir
string
UserPid
int
ShutdownSignal
string
...
...
@@ -359,7 +360,7 @@ func (h *javaHandle) ID() string {
Version
:
h
.
version
,
KillTimeout
:
h
.
killTimeout
,
MaxKillTimeout
:
h
.
maxKillTimeout
,
PluginConfig
:
NewPluginReattachConfig
(
h
.
pluginClient
.
ReattachConfig
()),
PluginConfig
:
executorplugin
.
NewPluginReattachConfig
(
h
.
pluginClient
.
ReattachConfig
()),
UserPid
:
h
.
userPid
,
TaskDir
:
h
.
taskDir
,
ShutdownSignal
:
h
.
shutdownSignal
,
...
...
This diff is collapsed.
Click to expand it.
client/driver/qemu.go
+
3
-
2
View file @
75d333fe
...
...
@@ -17,6 +17,7 @@ import (
"github.com/coreos/go-semver/semver"
plugin
"github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/client/driver/executor_plugin"
dstructs
"github.com/hashicorp/nomad/client/driver/structs"
"github.com/hashicorp/nomad/client/fingerprint"
cstructs
"github.com/hashicorp/nomad/client/structs"
...
...
@@ -372,7 +373,7 @@ type qemuId struct {
KillTimeout
time
.
Duration
MaxKillTimeout
time
.
Duration
UserPid
int
PluginConfig
*
PluginReattachConfig
PluginConfig
*
executorplugin
.
PluginReattachConfig
ShutdownSignal
string
}
...
...
@@ -421,7 +422,7 @@ func (h *qemuHandle) ID() string {
Version
:
h
.
version
,
KillTimeout
:
h
.
killTimeout
,
MaxKillTimeout
:
h
.
maxKillTimeout
,
PluginConfig
:
NewPluginReattachConfig
(
h
.
pluginClient
.
ReattachConfig
()),
PluginConfig
:
executorplugin
.
NewPluginReattachConfig
(
h
.
pluginClient
.
ReattachConfig
()),
UserPid
:
h
.
userPid
,
ShutdownSignal
:
h
.
shutdownSignal
,
}
...
...
This diff is collapsed.
Click to expand it.
client/driver/raw_exec.go
+
3
-
2
View file @
75d333fe
...
...
@@ -14,6 +14,7 @@ import (
multierror
"github.com/hashicorp/go-multierror"
"github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/client/allocdir"
"github.com/hashicorp/nomad/client/driver/executor_plugin"
dstructs
"github.com/hashicorp/nomad/client/driver/structs"
"github.com/hashicorp/nomad/client/fingerprint"
cstructs
"github.com/hashicorp/nomad/client/structs"
...
...
@@ -201,7 +202,7 @@ type rawExecId struct {
KillTimeout
time
.
Duration
MaxKillTimeout
time
.
Duration
UserPid
int
PluginConfig
*
PluginReattachConfig
PluginConfig
*
executorplugin
.
PluginReattachConfig
ShutdownSignal
string
}
...
...
@@ -252,7 +253,7 @@ func (h *rawExecHandle) ID() string {
Version
:
h
.
version
,
KillTimeout
:
h
.
killTimeout
,
MaxKillTimeout
:
h
.
maxKillTimeout
,
PluginConfig
:
NewPluginReattachConfig
(
h
.
pluginClient
.
ReattachConfig
()),
PluginConfig
:
executorplugin
.
NewPluginReattachConfig
(
h
.
pluginClient
.
ReattachConfig
()),
UserPid
:
h
.
userPid
,
ShutdownSignal
:
h
.
shutdownSignal
,
}
...
...
This diff is collapsed.
Click to expand it.
client/driver/utils.go
+
6
-
5
View file @
75d333fe
...
...
@@ -15,6 +15,7 @@ import (
"github.com/hashicorp/go-multierror"
"github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/client/driver/executor_plugin"
dstructs
"github.com/hashicorp/nomad/client/driver/structs"
"github.com/hashicorp/nomad/drivers/shared/executor"
"github.com/hashicorp/nomad/helper/discover"
...
...
@@ -45,8 +46,8 @@ func createExecutor(w io.Writer, clientConfig *config.Config,
config
:=
&
plugin
.
ClientConfig
{
Cmd
:
exec
.
Command
(
bin
,
"executor"
,
string
(
c
)),
}
config
.
HandshakeConfig
=
HandshakeConfig
config
.
Plugins
=
GetPluginMap
(
w
,
hclog
.
LevelFromString
(
clientConfig
.
LogLevel
),
executorConfig
.
FSIsolation
)
config
.
HandshakeConfig
=
executorplugin
.
HandshakeConfig
config
.
Plugins
=
executorplugin
.
GetPluginMap
(
w
,
hclog
.
LevelFromString
(
clientConfig
.
LogLevel
),
executorConfig
.
FSIsolation
)
config
.
MaxPort
=
clientConfig
.
ClientMaxPort
config
.
MinPort
=
clientConfig
.
ClientMinPort
...
...
@@ -71,11 +72,11 @@ func createExecutor(w io.Writer, clientConfig *config.Config,
}
func
createExecutorWithConfig
(
config
*
plugin
.
ClientConfig
,
w
io
.
Writer
)
(
executor
.
Executor
,
*
plugin
.
Client
,
error
)
{
config
.
HandshakeConfig
=
HandshakeConfig
config
.
HandshakeConfig
=
executorplugin
.
HandshakeConfig
// Setting this to DEBUG since the log level at the executor server process
// is already set, and this effects only the executor client.
config
.
Plugins
=
GetPluginMap
(
w
,
hclog
.
Debug
,
false
)
config
.
Plugins
=
executorplugin
.
GetPluginMap
(
w
,
hclog
.
Debug
,
false
)
executorClient
:=
plugin
.
NewClient
(
config
)
rpcClient
,
err
:=
executorClient
.
Client
()
...
...
@@ -87,7 +88,7 @@ func createExecutorWithConfig(config *plugin.ClientConfig, w io.Writer) (executo
if
err
!=
nil
{
return
nil
,
nil
,
fmt
.
Errorf
(
"unable to dispense the executor plugin: %v"
,
err
)
}
executorPlugin
,
ok
:=
raw
.
(
*
ExecutorRPC
)
executorPlugin
,
ok
:=
raw
.
(
*
executorplugin
.
ExecutorRPC
)
if
!
ok
{
return
nil
,
nil
,
fmt
.
Errorf
(
"unexpected executor rpc type: %T"
,
raw
)
}
...
...
This diff is collapsed.
Click to expand it.
command/executor_plugin.go
+
3
-
3
View file @
75d333fe
...
...
@@ -8,7 +8,7 @@ import (
hclog
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/client/driver"
"github.com/hashicorp/nomad/client/driver
/executor_plugin
"
dstructs
"github.com/hashicorp/nomad/client/driver/structs"
)
...
...
@@ -43,8 +43,8 @@ func (e *ExecutorPluginCommand) Run(args []string) int {
return
1
}
plugin
.
Serve
(
&
plugin
.
ServeConfig
{
HandshakeConfig
:
driver
.
HandshakeConfig
,
Plugins
:
driver
.
GetPluginMap
(
HandshakeConfig
:
executorplugin
.
HandshakeConfig
,
Plugins
:
executorplugin
.
GetPluginMap
(
stdo
,
hclog
.
LevelFromString
(
executorConfig
.
LogLevel
),
executorConfig
.
FSIsolation
,
...
...
This diff is collapsed.
Click to expand it.
plugins/drivers/utils/utils.go
+
6
-
6
View file @
75d333fe
...
...
@@ -12,7 +12,7 @@ import (
plugin
"github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/client/allocdir"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/client/driver"
"github.com/hashicorp/nomad/client/driver
/executor_plugin
"
dstructs
"github.com/hashicorp/nomad/client/driver/structs"
cstructs
"github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/drivers/shared/env"
...
...
@@ -79,8 +79,8 @@ func CreateExecutor(w io.Writer, level hclog.Level, driverConfig *base.ClientDri
config
:=
&
plugin
.
ClientConfig
{
Cmd
:
exec
.
Command
(
bin
,
"executor"
,
string
(
c
)),
}
config
.
HandshakeConfig
=
driver
.
HandshakeConfig
config
.
Plugins
=
driver
.
GetPluginMap
(
w
,
level
,
executorConfig
.
FSIsolation
)
config
.
HandshakeConfig
=
executorplugin
.
HandshakeConfig
config
.
Plugins
=
executorplugin
.
GetPluginMap
(
w
,
level
,
executorConfig
.
FSIsolation
)
if
driverConfig
!=
nil
{
config
.
MaxPort
=
driverConfig
.
ClientMaxPort
...
...
@@ -112,11 +112,11 @@ func CreateExecutor(w io.Writer, level hclog.Level, driverConfig *base.ClientDri
// CreateExecutorWithConfig launches a plugin with a given plugin config
func
CreateExecutorWithConfig
(
config
*
plugin
.
ClientConfig
,
w
io
.
Writer
)
(
executor
.
Executor
,
*
plugin
.
Client
,
error
)
{
config
.
HandshakeConfig
=
driver
.
HandshakeConfig
config
.
HandshakeConfig
=
executorplugin
.
HandshakeConfig
// Setting this to DEBUG since the log level at the executor server process
// is already set, and this effects only the executor client.
config
.
Plugins
=
driver
.
GetPluginMap
(
w
,
hclog
.
Debug
,
false
)
config
.
Plugins
=
executorplugin
.
GetPluginMap
(
w
,
hclog
.
Debug
,
false
)
executorClient
:=
plugin
.
NewClient
(
config
)
rpcClient
,
err
:=
executorClient
.
Client
()
...
...
@@ -128,7 +128,7 @@ func CreateExecutorWithConfig(config *plugin.ClientConfig, w io.Writer) (executo
if
err
!=
nil
{
return
nil
,
nil
,
fmt
.
Errorf
(
"unable to dispense the executor plugin: %v"
,
err
)
}
executorPlugin
,
ok
:=
raw
.
(
*
driver
.
ExecutorRPC
)
executorPlugin
,
ok
:=
raw
.
(
*
executorplugin
.
ExecutorRPC
)
if
!
ok
{
return
nil
,
nil
,
fmt
.
Errorf
(
"unexpected executor rpc type: %T"
,
raw
)
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help