mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 02:15:43 +03:00
client: begin driver plugin integration
client: fingerprint driver plugins
This commit is contained in:
committed by
Michael Schurter
parent
627e20801d
commit
d335a82859
@@ -572,9 +572,7 @@ func DevConfig() *Config {
|
||||
}
|
||||
conf.Client.Options = map[string]string{
|
||||
"driver.raw_exec.enable": "true",
|
||||
}
|
||||
conf.Client.Options = map[string]string{
|
||||
"driver.docker.volumes": "true",
|
||||
"driver.docker.volumes": "true",
|
||||
}
|
||||
conf.Client.GCInterval = 10 * time.Minute
|
||||
conf.Client.GCDiskUsageThreshold = 99
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
"github.com/hashicorp/consul/api"
|
||||
"github.com/hashicorp/nomad/client/driver"
|
||||
"github.com/hashicorp/nomad/client/allocrunnerv2/taskrunner/interfaces"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
|
||||
@@ -39,7 +39,7 @@ type scriptCheck struct {
|
||||
|
||||
id string
|
||||
check *structs.ServiceCheck
|
||||
exec driver.ScriptExecutor
|
||||
exec interfaces.ScriptExecutor
|
||||
agent heartbeater
|
||||
|
||||
// lastCheckOk is true if the last check was ok; otherwise false
|
||||
@@ -52,7 +52,7 @@ type scriptCheck struct {
|
||||
// newScriptCheck creates a new scriptCheck. run() should be called once the
|
||||
// initial check is registered with Consul.
|
||||
func newScriptCheck(allocID, taskName, checkID string, check *structs.ServiceCheck,
|
||||
exec driver.ScriptExecutor, agent heartbeater, logger log.Logger,
|
||||
exec interfaces.ScriptExecutor, agent heartbeater, logger log.Logger,
|
||||
shutdownCh <-chan struct{}) *scriptCheck {
|
||||
|
||||
logger = logger.ResetNamed("consul.checks").With("task", taskName, "alloc_id", allocID, "check", check.Name)
|
||||
@@ -93,9 +93,8 @@ func (s *scriptCheck) run() *scriptHandle {
|
||||
metrics.IncrCounter([]string{"client", "consul", "script_runs"}, 1)
|
||||
|
||||
// Execute check script with timeout
|
||||
execctx, cancel := context.WithTimeout(ctx, s.check.Timeout)
|
||||
output, code, err := s.exec.Exec(execctx, s.check.Command, s.check.Args)
|
||||
switch execctx.Err() {
|
||||
output, code, err := s.exec.Exec(s.check.Timeout, s.check.Command, s.check.Args)
|
||||
switch err {
|
||||
case context.Canceled:
|
||||
// check removed during execution; exit
|
||||
cancel()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package consul
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/nomad/client/driver"
|
||||
"github.com/hashicorp/nomad/client/allocrunnerv2/taskrunner/interfaces"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
@@ -26,13 +26,13 @@ type TaskServices struct {
|
||||
Networks structs.Networks
|
||||
|
||||
// DriverExec is the script executor for the task's driver.
|
||||
DriverExec driver.ScriptExecutor
|
||||
DriverExec interfaces.ScriptExecutor
|
||||
|
||||
// DriverNetwork is the network specified by the driver and may be nil.
|
||||
DriverNetwork *cstructs.DriverNetwork
|
||||
}
|
||||
|
||||
func NewTaskServices(alloc *structs.Allocation, task *structs.Task, restarter TaskRestarter, exec driver.ScriptExecutor, net *cstructs.DriverNetwork) *TaskServices {
|
||||
func NewTaskServices(alloc *structs.Allocation, task *structs.Task, restarter TaskRestarter, exec interfaces.ScriptExecutor, net *cstructs.DriverNetwork) *TaskServices {
|
||||
ts := TaskServices{
|
||||
AllocID: alloc.ID,
|
||||
Name: task.Name,
|
||||
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
"github.com/hashicorp/nomad/plugins/shared/catalog"
|
||||
"github.com/hashicorp/nomad/plugins/shared/loader"
|
||||
"github.com/hashicorp/nomad/plugins/shared/singleton"
|
||||
|
||||
_ "github.com/hashicorp/nomad/drivers/rawexec"
|
||||
)
|
||||
|
||||
// setupPlugins is used to setup the plugin loaders.
|
||||
|
||||
Reference in New Issue
Block a user