mirror of
https://github.com/kemko/nomad.git
synced 2026-01-02 00:15:43 +03:00
* drivers: plumb hardware topology via grpc into drivers This PR swaps out the temporary use of detecting system hardware manually in each driver for using the Client's detected topology by plumbing the data over gRPC. This ensures that Client configuration is taken to account consistently in all references to system topology. * cr: use enum instead of bool for core grade * cr: fix test slit tables to be possible
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package executor
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hashicorp/go-hclog"
|
|
"github.com/hashicorp/go-plugin"
|
|
"github.com/hashicorp/nomad/client/lib/cpustats"
|
|
"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
|
|
compute cpustats.Compute
|
|
}
|
|
|
|
func (p *ExecutorPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error {
|
|
if p.fsIsolation {
|
|
proto.RegisterExecutorServer(s, &grpcExecutorServer{impl: NewExecutorWithIsolation(p.logger, p.compute)})
|
|
} else {
|
|
proto.RegisterExecutorServer(s, &grpcExecutorServer{impl: NewExecutor(p.logger, p.compute)})
|
|
}
|
|
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
|
|
}
|