aboutsummaryrefslogtreecommitdiff
path: root/exec2
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-11-28 12:37:50 +0100
committerAlex Auvolat <alex@adnab.me>2022-11-28 12:37:50 +0100
commit77a2fb9190e1add91205d3bd26792fbbd8c0f459 (patch)
tree10b947f7f806247b4138878ae19e59f351ab9651 /exec2
parent06be7dcbf6ad5a0a068d6478c98b17306af44394 (diff)
downloadnomad-driver-nix2-77a2fb9190e1add91205d3bd26792fbbd8c0f459.tar.gz
nomad-driver-nix2-77a2fb9190e1add91205d3bd26792fbbd8c0f459.zip
First build as external plugin
Diffstat (limited to 'exec2')
-rw-r--r--exec2/driver.go21
-rw-r--r--exec2/handle.go2
-rw-r--r--exec2/state.go2
3 files changed, 12 insertions, 13 deletions
diff --git a/exec2/driver.go b/exec2/driver.go
index f035d15..4e52062 100644
--- a/exec2/driver.go
+++ b/exec2/driver.go
@@ -1,4 +1,4 @@
-package exec
+package exec2
import (
"context"
@@ -27,7 +27,7 @@ import (
const (
// pluginName is the name of the plugin
- pluginName = "exec"
+ pluginName = "exec2"
// fingerprintPeriod is the interval at which the driver will send fingerprint responses
fingerprintPeriod = 30 * time.Second
@@ -45,13 +45,6 @@ var (
PluginType: base.PluginTypeDriver,
}
- // PluginConfig is the exec driver factory function registered in the
- // plugin catalog.
- PluginConfig = &loader.InternalPluginConfig{
- Config: map[string]interface{}{},
- Factory: func(ctx context.Context, l hclog.Logger) interface{} { return NewExecDriver(ctx, l) },
- }
-
// pluginInfo is the response returned for the PluginInfo RPC
pluginInfo = &base.PluginInfoResponse{
Type: base.PluginTypeDriver,
@@ -125,6 +118,10 @@ type Driver struct {
// coordinate shutdown
ctx context.Context
+ // signalShutdown is called when the driver is shutting down and cancels
+ // the ctx passed to any subsystems
+ signalShutdown context.CancelFunc
+
// logger will log to the Nomad agent
logger hclog.Logger
@@ -233,13 +230,15 @@ type TaskState struct {
StartedAt time.Time
}
-// NewExecDriver returns a new DrivePlugin implementation
-func NewExecDriver(ctx context.Context, logger hclog.Logger) drivers.DriverPlugin {
+// NewPlugin returns a new DrivePlugin implementation
+func NewPlugin(logger hclog.Logger) drivers.DriverPlugin {
+ ctx, cancel := context.WithCancel(context.Background())
logger = logger.Named(pluginName)
return &Driver{
eventer: eventer.NewEventer(ctx, logger),
tasks: newTaskStore(),
ctx: ctx,
+ signalShutdown: cancel,
logger: logger,
}
}
diff --git a/exec2/handle.go b/exec2/handle.go
index 606406b..1316922 100644
--- a/exec2/handle.go
+++ b/exec2/handle.go
@@ -1,4 +1,4 @@
-package exec
+package exec2
import (
"context"
diff --git a/exec2/state.go b/exec2/state.go
index 08cdee8..277e336 100644
--- a/exec2/state.go
+++ b/exec2/state.go
@@ -1,4 +1,4 @@
-package exec
+package exec2
import (
"sync"