Skip to content

Commit

Permalink
Merge branch 'master' into f-grpc-executor
Browse files Browse the repository at this point in the history
* master: (71 commits)
  Fix output of 'nomad deployment fail' with no arg
  Always create a running allocation when testing task state
  tests: ensure exec tests pass valid task resources (#4992)
  some changes for more idiomatic code
  fix iops related tests
  fixed bug in loop delay
  gofmt
  improved code for readability
  client: updateAlloc release lock after read
  fixup! device attributes in `nomad node status -verbose`
  drivers/exec: support device binds and mounts
  fix iops bug and increase test matrix coverage
  tests: tag image explicitly
  changelog
  ci: install lxc-templates explicitly
  tests: skip checking rdma cgroup
  ci: use Ubuntu 16.04 (Xenial) in TravisCI
  client: update driver info on new fingerprint
  drivers/docker: enforce volumes.enabled (#4983)
  client: Style: use fluent style for building loggers
  ...
  • Loading branch information
nickethier committed Dec 13, 2018
2 parents 4243b7d + 0826042 commit 8a34441
Show file tree
Hide file tree
Showing 129 changed files with 3,934 additions and 1,086 deletions.
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@ git:
matrix:
include:
- os: linux
dist: trusty
dist: xenial
sudo: required
- os: linux
dist: trusty
dist: xenial
sudo: required
env: ENABLE_RACE=1
- os: linux
dist: trusty
dist: xenial
sudo: false
env: RUN_WEBSITE_TESTS=1 SKIP_NOMAD_TESTS=1
- os: linux
dist: trusty
dist: xenial
sudo: false
env: RUN_UI_TESTS=1 SKIP_NOMAD_TESTS=1
- os: linux
dist: trusty
dist: xenial
sudo: false
env: RUN_STATIC_CHECKS=1 SKIP_NOMAD_TESTS=1
- os: osx
osx_image: xcode9.1
- os: linux
dist: trusty
dist: xenial
sudo: required
env: RUN_E2E_TESTS=1 SKIP_NOMAD_TESTS=1
allow_failures:
Expand Down
30 changes: 24 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

__BACKWARDS INCOMPATIBILITIES:__
* core: Switch to structured logging using [go-hclog](https://github.com/hashicorp/go-hclog)
* core: IOPS as a resource is now deprecated [[GH-4970](https://github.com/hashicorp/nomad/issues/4970)]
* core: Allow the != constraint to match against keys that do not exist [[GH-4875](https://github.com/hashicorp/nomad/pull/4875)]
* client: Task config interpolation requires names to be valid identifiers
(`node.region` or `NOMAD_DC`). Interpolating other variables requires a new
Expand Down Expand Up @@ -29,17 +30,34 @@ IMPROVEMENTS:
* vendor: Removed library obsoleted by go 1.8 [[GH-4469](https://github.com/hashicorp/nomad/issues/4469)]

BUG FIXES:
* core: Fixed bug in reconciler where allocs already stopped were being unnecessarily updated [[GH-4764](https://github.com/hashicorp/nomad/issues/4764)]
* core: Fixed bug where some successfully completed jobs get re-run after job garbage collection [[GH-4861](https://github.com/hashicorp/nomad/pull/4861)]
* core: Fix an issue where artifact checksums containing interpolated variables failed validation [[GH-4810](https://github.com/hashicorp/nomad/pull/4819)]
* core: Fixed bug that affects garbage collection of batch jobs that are purged and resubmitted with the same id [[GH-4839](https://github.com/hashicorp/nomad/pull/4839)]
* client: Fix an issue reloading the client config [[GH-4730](https://github.com/hashicorp/nomad/issues/4730)]
* deployments: Fix an issue where a deployment with multiple task groups could
be marked as failed when the first progress deadline was hit regardless of if
that group was done deploying [[GH-4842](https://github.com/hashicorp/nomad/issues/4842)]
* driver/raw_exec: Fix issue where tasks that used an interpolated command in driver configuration would not start [[GH-4813](https://github.com/hashicorp/nomad/pull/4813)]
* server/vault: Fixed bug in Vault token renewal that could panic on a malformed Vault response [[GH-4904](https://github.com/hashicorp/nomad/issues/4904)], [[GH-4937](https://github.com/hashicorp/nomad/pull/4937)]

## 0.8.7 (Unreleased)

IMPROVEMENTS:
* core: Added `filter_default`, `prefix_filter` and `disable_dispatched_job_summary_metrics`
client options to improve metric filtering [[GH-4878](https://github.com/hashicorp/nomad/issues/4878)]
* driver/docker: Support `bind` mount type in order to allow Windows users to mount absolute paths [[GH-4958](https://github.com/hashicorp/nomad/issues/4958)]

BUG FIXES:
* core: Fixed panic when Vault secret response is nil [[GH-4904](https://github.com/hashicorp/nomad/pull/4904)] [[GH-4937](https://github.com/hashicorp/nomad/pull/4937)]
* core: Fixed issue with negative counts in job summary [[GH-4949](https://github.com/hashicorp/nomad/issues/4949)]
* core: Fixed issue with handling duplicated blocked evaluations [[GH-4867](https://github.com/hashicorp/nomad/pull/4867)]
* core: Fixed bug where some successfully completed jobs get re-run after job
garbage collection [[GH-4861](https://github.com/hashicorp/nomad/pull/4861)]
* core: Fixed bug in reconciler where allocs already stopped were being
unnecessarily updated [[GH-4764](https://github.com/hashicorp/nomad/issues/4764)]
* core: Fixed bug that affects garbage collection of batch jobs that are purged
and resubmitted with the same id [[GH-4839](https://github.com/hashicorp/nomad/pull/4839)]
* core: Fixed an issue with garbage collection where terminal but still running
allocations could be garbage collected server side [[GH-4965](https://github.com/hashicorp/nomad/issues/4965)]
* deployments: Fix an issue where a deployment with multiple task groups could
be marked as failed when the first progress deadline was hit regardless of if
that group was done deploying [[GH-4842](https://github.com/hashicorp/nomad/issues/4842)]

## 0.8.6 (September 26, 2018)

IMPROVEMENTS:
Expand Down
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ test-nomad: dev ## Run Nomad test suites
$(if $(ENABLE_RACE),GORACE="strip_path_prefix=$(GOPATH)/src") go test \
$(if $(ENABLE_RACE),-race) $(if $(VERBOSE),-v) \
-cover \
-timeout=30m \
-timeout=15m \
-tags="$(if $(HAS_LXC),lxc)" ./... $(if $(VERBOSE), >test.log ; echo $$? > exit-code)
@if [ $(VERBOSE) ] ; then \
bash -C "$(PROJECT_ROOT)/scripts/test_check.sh" ; \
Expand Down
2 changes: 0 additions & 2 deletions api/compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func TestCompose(t *testing.T) {
CPU: helper.IntToPtr(1250),
MemoryMB: helper.IntToPtr(1024),
DiskMB: helper.IntToPtr(2048),
IOPS: helper.IntToPtr(500),
Networks: []*NetworkResource{
{
CIDR: "0.0.0.0/0",
Expand Down Expand Up @@ -109,7 +108,6 @@ func TestCompose(t *testing.T) {
CPU: helper.IntToPtr(1250),
MemoryMB: helper.IntToPtr(1024),
DiskMB: helper.IntToPtr(2048),
IOPS: helper.IntToPtr(500),
Networks: []*NetworkResource{
{
CIDR: "0.0.0.0/0",
Expand Down
1 change: 0 additions & 1 deletion api/jobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ func TestJobs_Canonicalize(t *testing.T) {
Resources: &Resources{
CPU: helper.IntToPtr(500),
MemoryMB: helper.IntToPtr(256),
IOPS: helper.IntToPtr(0),
Networks: []*NetworkResource{
{
MBits: helper.IntToPtr(10),
Expand Down
6 changes: 3 additions & 3 deletions api/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strconv"
"time"

"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/nomad/structs"
)

Expand Down Expand Up @@ -673,17 +674,16 @@ func (v *StatValue) String() string {
case v.StringVal != nil:
return *v.StringVal
case v.FloatNumeratorVal != nil:
str := strconv.FormatFloat(*v.FloatNumeratorVal, 'f', -1, 64)
str := helper.FormatFloat(*v.FloatNumeratorVal, 3)
if v.FloatDenominatorVal != nil {
str += " / " + strconv.FormatFloat(*v.FloatDenominatorVal, 'f', -1, 64)
str += " / " + helper.FormatFloat(*v.FloatDenominatorVal, 3)
}

if v.Unit != "" {
str += " " + v.Unit
}
return str
case v.IntNumeratorVal != nil:

str := strconv.FormatInt(*v.IntNumeratorVal, 10)
if v.IntDenominatorVal != nil {
str += " / " + strconv.FormatInt(*v.IntDenominatorVal, 10)
Expand Down
56 changes: 42 additions & 14 deletions api/resources.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
package api

import "github.com/hashicorp/nomad/helper"
import (
"strconv"

"github.com/hashicorp/nomad/helper"
)

// Resources encapsulates the required resources of
// a given task or task group.
type Resources struct {
CPU *int
MemoryMB *int `mapstructure:"memory"`
DiskMB *int `mapstructure:"disk"`
IOPS *int
Networks []*NetworkResource
Devices []*RequestedDevice

// COMPAT(0.10)
// XXX Deprecated. Please do not use. The field will be removed in Nomad
// 0.10 and is only being kept to allow any references to be removed before
// then.
IOPS *int
}

// Canonicalize will supply missing values in the cases
Expand All @@ -23,9 +32,6 @@ func (r *Resources) Canonicalize() {
if r.MemoryMB == nil {
r.MemoryMB = defaultResources.MemoryMB
}
if r.IOPS == nil {
r.IOPS = defaultResources.IOPS
}
for _, n := range r.Networks {
n.Canonicalize()
}
Expand All @@ -42,7 +48,6 @@ func DefaultResources() *Resources {
return &Resources{
CPU: helper.IntToPtr(100),
MemoryMB: helper.IntToPtr(300),
IOPS: helper.IntToPtr(0),
}
}

Expand All @@ -55,7 +60,6 @@ func MinResources() *Resources {
return &Resources{
CPU: helper.IntToPtr(20),
MemoryMB: helper.IntToPtr(10),
IOPS: helper.IntToPtr(0),
}
}

Expand All @@ -73,9 +77,6 @@ func (r *Resources) Merge(other *Resources) {
if other.DiskMB != nil {
r.DiskMB = other.DiskMB
}
if other.IOPS != nil {
r.IOPS = other.IOPS
}
if len(other.Networks) != 0 {
r.Networks = other.Networks
}
Expand Down Expand Up @@ -125,6 +126,10 @@ type NodeDeviceResource struct {
Attributes map[string]*Attribute
}

func (r NodeDeviceResource) ID() string {
return r.Vendor + "/" + r.Type + "/" + r.Name
}

// NodeDevice is an instance of a particular device.
type NodeDevice struct {
// ID is the ID of the device.
Expand All @@ -146,21 +151,44 @@ type NodeDevice struct {
// specifying units
type Attribute struct {
// Float is the float value for the attribute
Float *float64
FloatVal *float64 `json:"Float,omitempty"`

// Int is the int value for the attribute
Int *int64
IntVal *int64 `json:"Int,omitempty"`

// String is the string value for the attribute
String *string
StringVal *string `json:"String,omitempty"`

// Bool is the bool value for the attribute
Bool *bool
BoolVal *bool `json:"Bool,omitempty"`

// Unit is the optional unit for the set int or float value
Unit string
}

func (a Attribute) String() string {
switch {
case a.FloatVal != nil:
str := helper.FormatFloat(*a.FloatVal, 3)
if a.Unit != "" {
str += " " + a.Unit
}
return str
case a.IntVal != nil:
str := strconv.FormatInt(*a.IntVal, 10)
if a.Unit != "" {
str += " " + a.Unit
}
return str
case a.StringVal != nil:
return *a.StringVal
case a.BoolVal != nil:
return strconv.FormatBool(*a.BoolVal)
default:
return "<unknown>"
}
}

// NodeDeviceLocality stores information about the devices hardware locality on
// the node.
type NodeDeviceLocality struct {
Expand Down
1 change: 0 additions & 1 deletion api/tasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ func TestTask_Require(t *testing.T) {
CPU: helper.IntToPtr(1250),
MemoryMB: helper.IntToPtr(128),
DiskMB: helper.IntToPtr(2048),
IOPS: helper.IntToPtr(500),
Networks: []*NetworkResource{
{
CIDR: "0.0.0.0/0",
Expand Down
1 change: 0 additions & 1 deletion api/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func testJob() *Job {
Require(&Resources{
CPU: helper.IntToPtr(100),
MemoryMB: helper.IntToPtr(256),
IOPS: helper.IntToPtr(10),
}).
SetLogConfig(&LogConfig{
MaxFiles: helper.IntToPtr(1),
Expand Down
10 changes: 7 additions & 3 deletions client/allocrunner/alloc_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,13 @@ type allocRunner struct {
// allocBroadcaster sends client allocation updates to all listeners
allocBroadcaster *cstructs.AllocBroadcaster

// prevAllocWatcher allows waiting for a previous allocation to exit
// and if necessary migrate its alloc dir.
// prevAllocWatcher allows waiting for any previous or preempted allocations
// to exit
prevAllocWatcher allocwatcher.PrevAllocWatcher

// prevAllocMigrator allows the migration of a previous allocations alloc dir.
prevAllocMigrator allocwatcher.PrevAllocMigrator

// pluginSingletonLoader is a plugin loader that will returns singleton
// instances of the plugins.
pluginSingletonLoader loader.PluginCatalog
Expand Down Expand Up @@ -134,6 +137,7 @@ func NewAllocRunner(config *Config) (*allocRunner, error) {
taskStateUpdateHandlerCh: make(chan struct{}),
deviceStatsReporter: config.DeviceStatsReporter,
prevAllocWatcher: config.PrevAllocWatcher,
prevAllocMigrator: config.PrevAllocMigrator,
pluginSingletonLoader: config.PluginSingletonLoader,
devicemanager: config.DeviceManager,
}
Expand Down Expand Up @@ -713,7 +717,7 @@ func (ar *allocRunner) Shutdown() {
//
// This method is safe for calling concurrently with Run().
func (ar *allocRunner) IsMigrating() bool {
return ar.prevAllocWatcher.IsMigrating()
return ar.prevAllocMigrator.IsMigrating()
}

func (ar *allocRunner) StatsReporter() interfaces.AllocStatsReporter {
Expand Down
3 changes: 2 additions & 1 deletion client/allocrunner/alloc_runner_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ func (ar *allocRunner) initRunnerHooks() {
// directory path exists for other hooks.
ar.runnerHooks = []interfaces.RunnerHook{
newAllocDirHook(hookLogger, ar.allocDir),
newDiskMigrationHook(hookLogger, ar.prevAllocWatcher, ar.allocDir),
newUpstreamAllocsHook(hookLogger, ar.prevAllocWatcher),
newDiskMigrationHook(hookLogger, ar.prevAllocMigrator, ar.allocDir),
newAllocHealthWatcherHook(hookLogger, ar.Alloc(), hs, ar.Listener(), ar.consulClient),
}
}
Expand Down
8 changes: 5 additions & 3 deletions client/allocrunner/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ type Config struct {
// StateUpdater is used to emit updated task state
StateUpdater interfaces.AllocStateHandler

// deviceStatsReporter is used to lookup resource usage for alloc devices
// DeviceStatsReporter is used to lookup resource usage for alloc devices
DeviceStatsReporter interfaces.DeviceStatsReporter

// PrevAllocWatcher handles waiting on previous allocations and
// migrating their ephemeral disk when necessary.
// PrevAllocWatcher handles waiting on previous or preempted allocations
PrevAllocWatcher allocwatcher.PrevAllocWatcher

// PrevAllocMigrator allows the migration of a previous allocations alloc dir
PrevAllocMigrator allocwatcher.PrevAllocMigrator

// PluginLoader is used to load plugins.
PluginLoader loader.PluginCatalog

Expand Down
6 changes: 3 additions & 3 deletions client/allocrunner/health_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (h *allocHealthWatcherHook) Update(req *interfaces.RunnerUpdateRequest) err
return h.init()
}

func (h *allocHealthWatcherHook) Destroy() error {
func (h *allocHealthWatcherHook) Postrun() error {
h.hookLock.Lock()
defer h.hookLock.Unlock()

Expand All @@ -189,8 +189,8 @@ func (h *allocHealthWatcherHook) Destroy() error {
}

func (h *allocHealthWatcherHook) Shutdown() {
// Same as Destroy
h.Destroy()
// Same as Postrun
h.Postrun()
}

// watchHealth watches alloc health until it is set, the alloc is stopped, or
Expand Down
Loading

0 comments on commit 8a34441

Please sign in to comment.