Skip to content

Commit

Permalink
Merge branch 'master' into f-ui/long-client-names
Browse files Browse the repository at this point in the history
  • Loading branch information
backspace committed Jun 19, 2019
2 parents 8570b84 + e93bbf8 commit 37c4c55
Show file tree
Hide file tree
Showing 78 changed files with 5,772 additions and 4,213 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

IMPROVEMENTS:
* api: use region from job hcl when not provided as query parameter in job registration and plan endpoints [[GH-5664](https://github.com/hashicorp/nomad/pull/5664)]
* metrics: add namespace label as appropriate to metrics [[GH-5847](https://github.com/hashicorp/nomad/issues/5847)]

BUG FIXES:

* drivers: Fixed an issue preventing external driver plugins from launching executor process [[GH-5726](https://github.com/hashicorp/nomad/issues/5726)]
* drivers/docker: Fixed a bug mounting relative paths on Windows [[GH-5811](https://github.com/hashicorp/nomad/issues/5811)]
* drivers/exec: Upgraded libcontainer dependency to avoid zombie `runc:[1:CHILD]]` processes [[GH-5851](https://github.com/hashicorp/nomad/issues/5851)]
* ui: Fixed ability to click sort arrow to change sort direction [[GH-5833](https://github.com/hashicorp/nomad/pull/5833)]

## 0.9.3 (June 12, 2019)
Expand Down
4 changes: 4 additions & 0 deletions client/allocrunner/taskrunner/task_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ func (tr *TaskRunner) initLabels() {
Name: "task",
Value: tr.taskName,
},
{
Name: "namespace",
Value: tr.alloc.Namespace,
},
}

if tr.alloc.Job.ParentID != "" {
Expand Down
31 changes: 31 additions & 0 deletions client/allocrunner/taskrunner/task_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2021,3 +2021,34 @@ func testWaitForTaskToStart(t *testing.T, tr *TaskRunner) {
require.NoError(t, err)
})
}

// TestTaskRunner_BaseLabels tests that the base labels for the task metrics
// are set appropriately.
func TestTaskRunner_BaseLabels(t *testing.T) {
t.Parallel()
require := require.New(t)

alloc := mock.BatchAlloc()
alloc.Namespace = "not-default"
task := alloc.Job.TaskGroups[0].Tasks[0]
task.Driver = "raw_exec"
task.Config = map[string]interface{}{
"command": "whoami",
}

config, cleanup := testTaskRunnerConfig(t, alloc, task.Name)
defer cleanup()

tr, err := NewTaskRunner(config)
require.NoError(err)

labels := map[string]string{}
for _, e := range tr.baseLabels {
labels[e.Name] = e.Value
}
require.Equal(alloc.Job.Name, labels["job"])
require.Equal(alloc.TaskGroup, labels["task_group"])
require.Equal(task.Name, labels["task"])
require.Equal(alloc.ID, labels["alloc_id"])
require.Equal(alloc.Namespace, labels["namespace"])
}
4 changes: 2 additions & 2 deletions client/logmon/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package logmon

import (
"context"
"os"
"os/exec"

hclog "github.com/hashicorp/go-hclog"
plugin "github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/client/logmon/proto"
"github.com/hashicorp/nomad/helper/discover"
"github.com/hashicorp/nomad/plugins/base"
"google.golang.org/grpc"
)
Expand All @@ -16,7 +16,7 @@ import (
// TODO: Integrate with base plugin loader
func LaunchLogMon(logger hclog.Logger, reattachConfig *plugin.ReattachConfig) (LogMon, *plugin.Client, error) {
logger = logger.Named("logmon")
bin, err := discover.NomadExecutable()
bin, err := os.Executable()
if err != nil {
return nil, nil, err
}
Expand Down
33 changes: 33 additions & 0 deletions client/logmon/z_logmon_cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package logmon

import (
"os"

hclog "github.com/hashicorp/go-hclog"
plugin "github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/plugins/base"
)

// Install a plugin cli handler to ease working with tests
// and external plugins.
// This init() must be initialized last in package required by the child plugin
// process. It's recommended to avoid any other `init()` or inline any necessary calls
// here. See eeaa95d commit message for more details.
func init() {
if len(os.Args) > 1 && os.Args[1] == "logmon" {
logger := hclog.New(&hclog.LoggerOptions{
Level: hclog.Trace,
JSONFormat: true,
Name: "logmon",
})
plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: base.Handshake,
Plugins: map[string]plugin.Plugin{
"logmon": NewPlugin(NewLogMon(logger)),
},
GRPCServer: plugin.DefaultGRPCServer,
Logger: logger,
})
os.Exit(0)
}
}
16 changes: 0 additions & 16 deletions command/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"

"github.com/hashicorp/nomad/command/agent"
"github.com/hashicorp/nomad/drivers/docker/docklog"
"github.com/hashicorp/nomad/version"
colorable "github.com/mattn/go-colorable"
"github.com/mitchellh/cli"
Expand Down Expand Up @@ -237,11 +236,6 @@ func Commands(metaPtr *Meta, agentUi cli.Ui) map[string]cli.CommandFactory {
Meta: meta,
}, nil
},
docklog.PluginName: func() (cli.Command, error) {
return &DockerLoggerPluginCommand{
Meta: meta,
}, nil
},
"eval": func() (cli.Command, error) {
return &EvalCommand{
Meta: meta,
Expand All @@ -262,11 +256,6 @@ func Commands(metaPtr *Meta, agentUi cli.Ui) map[string]cli.CommandFactory {
Meta: meta,
}, nil
},
"executor": func() (cli.Command, error) {
return &ExecutorPluginCommand{
Meta: meta,
}, nil
},
"fs": func() (cli.Command, error) {
return &AllocFSCommand{
Meta: meta,
Expand Down Expand Up @@ -372,11 +361,6 @@ func Commands(metaPtr *Meta, agentUi cli.Ui) map[string]cli.CommandFactory {
Meta: meta,
}, nil
},
"logmon": func() (cli.Command, error) {
return &LogMonPluginCommand{
Meta: meta,
}, nil
},
"logs": func() (cli.Command, error) {
return &AllocLogsCommand{
Meta: meta,
Expand Down
43 changes: 0 additions & 43 deletions command/docker_logger_plugin.go

This file was deleted.

66 changes: 0 additions & 66 deletions command/executor_plugin.go

This file was deleted.

42 changes: 0 additions & 42 deletions command/logmon_plugin.go

This file was deleted.

4 changes: 2 additions & 2 deletions drivers/docker/docklog/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package docklog

import (
"context"
"os"
"os/exec"

hclog "github.com/hashicorp/go-hclog"
plugin "github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/drivers/docker/docklog/proto"
"github.com/hashicorp/nomad/helper/discover"
"github.com/hashicorp/nomad/plugins/base"
"google.golang.org/grpc"
)
Expand All @@ -17,7 +17,7 @@ const PluginName = "docker_logger"
// LaunchDockerLogger launches an instance of DockerLogger
func LaunchDockerLogger(logger hclog.Logger) (DockerLogger, *plugin.Client, error) {
logger = logger.Named(PluginName)
bin, err := discover.NomadExecutable()
bin, err := os.Executable()
if err != nil {
return nil, nil, err
}
Expand Down
34 changes: 34 additions & 0 deletions drivers/docker/docklog/z_docker_logger_cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package docklog

import (
"os"

log "github.com/hashicorp/go-hclog"
plugin "github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/plugins/base"
)

// Install a plugin cli handler to ease working with tests
// and external plugins.
// This init() must be initialized last in package required by the child plugin
// process. It's recommended to avoid any other `init()` or inline any necessary calls
// here. See eeaa95d commit message for more details.
func init() {
if len(os.Args) > 1 && os.Args[1] == PluginName {
logger := log.New(&log.LoggerOptions{
Level: log.Trace,
JSONFormat: true,
Name: PluginName,
})

plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: base.Handshake,
Plugins: map[string]plugin.Plugin{
PluginName: NewPlugin(NewDockerLogger(logger)),
},
GRPCServer: plugin.DefaultGRPCServer,
Logger: logger,
})
os.Exit(0)
}
}
Loading

0 comments on commit 37c4c55

Please sign in to comment.