Skip to content

Commit

Permalink
client/logmon: acquire executable in init block
Browse files Browse the repository at this point in the history
This PR causes the logmon task runner to acquire the binary of the
Nomad executable in an 'init' block, so as to almost certainly get
the name while the nomad file still exists.

This is an attempt at fixing the case where a deleted Nomad file
(e.g. during upgrade) may be getting renamed with a mysterious
suffix first.

If this doesn't work, as a last resort we can literally just trim
the mystery string.

Fixes: #14079
  • Loading branch information
shoenig committed Aug 24, 2022
1 parent 34e4b08 commit a35ae59
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions client/logmon/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,27 @@ import (
"os"
"os/exec"

hclog "github.com/hashicorp/go-hclog"
plugin "github.com/hashicorp/go-plugin"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/client/logmon/proto"
"github.com/hashicorp/nomad/plugins/base"
"google.golang.org/grpc"
)

var bin = getBin()

func getBin() string {
b, err := os.Executable()
if err != nil {
panic(err)
}
return b
}

// LaunchLogMon launches a new logmon or reattaches to an existing one.
// TODO: Integrate with base plugin loader
func LaunchLogMon(logger hclog.Logger, reattachConfig *plugin.ReattachConfig) (LogMon, *plugin.Client, error) {
logger = logger.Named("logmon")
bin, err := os.Executable()
if err != nil {
return nil, nil, err
}

conf := &plugin.ClientConfig{
HandshakeConfig: base.Handshake,
Plugins: map[string]plugin.Plugin{
Expand Down

0 comments on commit a35ae59

Please sign in to comment.