aboutsummaryrefslogtreecommitdiff
path: root/executor/executor_plugin.go
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-11-28 17:15:12 +0100
committerAlex Auvolat <alex@adnab.me>2022-11-28 17:15:12 +0100
commitbf3165a7069fc6dcf9ae3a28be3af07fe8b4e1c2 (patch)
tree32f52eeb5d60ae33e8a40c2d8b26d70cac19a473 /executor/executor_plugin.go
parent63e31b9ed97f34f4ea709f505c37f5e8968a0f36 (diff)
downloadnomad-driver-nix2-bf3165a7069fc6dcf9ae3a28be3af07fe8b4e1c2.tar.gz
nomad-driver-nix2-bf3165a7069fc6dcf9ae3a28be3af07fe8b4e1c2.zip
Vendor executor module so that we can patch it
Diffstat (limited to 'executor/executor_plugin.go')
-rw-r--r--executor/executor_plugin.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/executor/executor_plugin.go b/executor/executor_plugin.go
new file mode 100644
index 0000000..6eb7b35
--- /dev/null
+++ b/executor/executor_plugin.go
@@ -0,0 +1,34 @@
+package executor
+
+import (
+ "context"
+
+ hclog "github.com/hashicorp/go-hclog"
+ plugin "github.com/hashicorp/go-plugin"
+ "github.com/hashicorp/nomad/drivers/shared/executor/proto"
+ "google.golang.org/grpc"
+)
+
+type ExecutorPlugin struct {
+ // TODO: support backwards compatibility with pre 0.9 NetRPC plugin
+ plugin.NetRPCUnsupportedPlugin
+ logger hclog.Logger
+ fsIsolation bool
+}
+
+func (p *ExecutorPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error {
+ if p.fsIsolation {
+ proto.RegisterExecutorServer(s, &grpcExecutorServer{impl: NewExecutorWithIsolation(p.logger)})
+ } else {
+ proto.RegisterExecutorServer(s, &grpcExecutorServer{impl: NewExecutor(p.logger)})
+ }
+ return nil
+}
+
+func (p *ExecutorPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) {
+ return &grpcExecutorClient{
+ client: proto.NewExecutorClient(c),
+ doneCtx: ctx,
+ logger: p.logger,
+ }, nil
+}