From ffadab1b203d11a7e14cf4fc91e1d3ead0e2ea99 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Wed, 19 Dec 2018 15:26:37 -0800 Subject: [PATCH] remove nil logger --- drivers/docker/cmd/main.go | 17 +++++++++++++++++ plugins/drivers/client.go | 4 ---- plugins/drivers/plugin.go | 6 ++---- plugins/drivers/testutils/testing.go | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 drivers/docker/cmd/main.go diff --git a/drivers/docker/cmd/main.go b/drivers/docker/cmd/main.go new file mode 100644 index 000000000..5c26333dd --- /dev/null +++ b/drivers/docker/cmd/main.go @@ -0,0 +1,17 @@ +package main + +import ( + log "github.com/hashicorp/go-hclog" + "github.com/hashicorp/nomad/drivers/docker" + "github.com/hashicorp/nomad/plugins" +) + +func main() { + // Serve the plugin + plugins.Serve(factory) +} + +// factory returns a new instance of the Nvidia GPU plugin +func factory(log log.Logger) interface{} { + return docker.NewDockerDriver(log) +} diff --git a/plugins/drivers/client.go b/plugins/drivers/client.go index edefec092..2b01ffa93 100644 --- a/plugins/drivers/client.go +++ b/plugins/drivers/client.go @@ -8,7 +8,6 @@ import ( "github.com/LK4D4/joincontext" "github.com/golang/protobuf/ptypes" - hclog "github.com/hashicorp/go-hclog" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/nomad/structs" "github.com/hashicorp/nomad/plugins/base" @@ -26,7 +25,6 @@ type driverPluginClient struct { *base.BasePluginClient client proto.DriverClient - logger hclog.Logger // doneCtx is closed when the plugin exits doneCtx context.Context @@ -95,7 +93,6 @@ func (d *driverPluginClient) handleFingerprint(ctx context.Context, ch chan *Fin pb, err := stream.Recv() if err != nil { if err != io.EOF { - d.logger.Error("error receiving stream from Fingerprint driver RPC", "error", err) ch <- &Fingerprint{ Err: shared.HandleStreamErr(err, ctx, d.doneCtx), } @@ -297,7 +294,6 @@ func (d *driverPluginClient) handleTaskEvents(ctx context.Context, ch chan *Task ev, err := stream.Recv() if err != nil { if err != io.EOF { - d.logger.Error("error receiving stream from TaskEvents driver RPC", "error", err) ch <- &TaskEvent{ Err: shared.HandleStreamErr(err, ctx, d.doneCtx), } diff --git a/plugins/drivers/plugin.go b/plugins/drivers/plugin.go index 524123cba..b3fcfcfc4 100644 --- a/plugins/drivers/plugin.go +++ b/plugins/drivers/plugin.go @@ -19,10 +19,9 @@ type PluginDriver struct { logger hclog.Logger } -func NewDriverPlugin(d DriverPlugin, logger hclog.Logger) plugin.GRPCPlugin { +func NewDriverPlugin(d DriverPlugin) plugin.GRPCPlugin { return &PluginDriver{ - impl: d, - logger: logger.Named("driver_plugin"), + impl: d, } } @@ -42,7 +41,6 @@ func (p *PluginDriver) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker Client: baseproto.NewBasePluginClient(c), }, client: proto.NewDriverClient(c), - logger: p.logger, doneCtx: ctx, }, nil } diff --git a/plugins/drivers/testutils/testing.go b/plugins/drivers/testutils/testing.go index 2394b4f1b..f4c54702f 100644 --- a/plugins/drivers/testutils/testing.go +++ b/plugins/drivers/testutils/testing.go @@ -43,7 +43,7 @@ func (d *DriverHarness) Impl() drivers.DriverPlugin { func NewDriverHarness(t testing.T, d drivers.DriverPlugin) *DriverHarness { logger := testlog.HCLogger(t).Named("driver_harness") - pd := drivers.NewDriverPlugin(d, logger).(*drivers.PluginDriver) + pd := drivers.NewDriverPlugin(d).(*drivers.PluginDriver) client, server := plugin.TestPluginGRPCConn(t, map[string]plugin.Plugin{