Skip to content

Commit

Permalink
Merge branch 'master' into f-vault-sighup
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar authored Feb 2, 2017
2 parents 258ed55 + efc0602 commit 37121b4
Show file tree
Hide file tree
Showing 45 changed files with 6,415 additions and 814 deletions.
32 changes: 23 additions & 9 deletions client/gc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ import (
"log"
"os"
"testing"
"time"

"github.com/hashicorp/nomad/client/stats"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
)

var gcConfig = GCConfig{
DiskUsageThreshold: 80,
InodeUsageThreshold: 70,
Interval: 1 * time.Minute,
ReservedDiskMB: 0,
}

func TestIndexedGCAllocPQ(t *testing.T) {
pq := NewIndexedGCAllocPQ()

Expand Down Expand Up @@ -83,7 +91,7 @@ func (m *MockStatsCollector) Stats() *stats.HostStats {

func TestAllocGarbageCollector_MarkForCollection(t *testing.T) {
logger := log.New(os.Stdout, "", 0)
gc := NewAllocGarbageCollector(logger, &MockStatsCollector{}, 0)
gc := NewAllocGarbageCollector(logger, &MockStatsCollector{}, &gcConfig)

_, ar1 := testAllocRunnerFromAlloc(mock.Alloc(), false)
if err := gc.MarkForCollection(ar1); err != nil {
Expand All @@ -98,7 +106,7 @@ func TestAllocGarbageCollector_MarkForCollection(t *testing.T) {

func TestAllocGarbageCollector_Collect(t *testing.T) {
logger := log.New(os.Stdout, "", 0)
gc := NewAllocGarbageCollector(logger, &MockStatsCollector{}, 0)
gc := NewAllocGarbageCollector(logger, &MockStatsCollector{}, &gcConfig)

_, ar1 := testAllocRunnerFromAlloc(mock.Alloc(), false)
_, ar2 := testAllocRunnerFromAlloc(mock.Alloc(), false)
Expand All @@ -120,7 +128,7 @@ func TestAllocGarbageCollector_Collect(t *testing.T) {

func TestAllocGarbageCollector_CollectAll(t *testing.T) {
logger := log.New(os.Stdout, "", 0)
gc := NewAllocGarbageCollector(logger, &MockStatsCollector{}, 0)
gc := NewAllocGarbageCollector(logger, &MockStatsCollector{}, &gcConfig)

_, ar1 := testAllocRunnerFromAlloc(mock.Alloc(), false)
_, ar2 := testAllocRunnerFromAlloc(mock.Alloc(), false)
Expand All @@ -143,7 +151,8 @@ func TestAllocGarbageCollector_CollectAll(t *testing.T) {
func TestAllocGarbageCollector_MakeRoomForAllocations_EnoughSpace(t *testing.T) {
logger := log.New(os.Stdout, "", 0)
statsCollector := &MockStatsCollector{}
gc := NewAllocGarbageCollector(logger, statsCollector, 20)
gcConfig.ReservedDiskMB = 20
gc := NewAllocGarbageCollector(logger, statsCollector, &gcConfig)

_, ar1 := testAllocRunnerFromAlloc(mock.Alloc(), false)
close(ar1.waitCh)
Expand Down Expand Up @@ -179,7 +188,8 @@ func TestAllocGarbageCollector_MakeRoomForAllocations_EnoughSpace(t *testing.T)
func TestAllocGarbageCollector_MakeRoomForAllocations_GC_Partial(t *testing.T) {
logger := log.New(os.Stdout, "", 0)
statsCollector := &MockStatsCollector{}
gc := NewAllocGarbageCollector(logger, statsCollector, 20)
gcConfig.ReservedDiskMB = 20
gc := NewAllocGarbageCollector(logger, statsCollector, &gcConfig)

_, ar1 := testAllocRunnerFromAlloc(mock.Alloc(), false)
close(ar1.waitCh)
Expand Down Expand Up @@ -216,7 +226,8 @@ func TestAllocGarbageCollector_MakeRoomForAllocations_GC_Partial(t *testing.T) {
func TestAllocGarbageCollector_MakeRoomForAllocations_GC_All(t *testing.T) {
logger := log.New(os.Stdout, "", 0)
statsCollector := &MockStatsCollector{}
gc := NewAllocGarbageCollector(logger, statsCollector, 20)
gcConfig.ReservedDiskMB = 20
gc := NewAllocGarbageCollector(logger, statsCollector, &gcConfig)

_, ar1 := testAllocRunnerFromAlloc(mock.Alloc(), false)
close(ar1.waitCh)
Expand Down Expand Up @@ -249,7 +260,8 @@ func TestAllocGarbageCollector_MakeRoomForAllocations_GC_All(t *testing.T) {
func TestAllocGarbageCollector_MakeRoomForAllocations_GC_Fallback(t *testing.T) {
logger := log.New(os.Stdout, "", 0)
statsCollector := &MockStatsCollector{}
gc := NewAllocGarbageCollector(logger, statsCollector, 20)
gcConfig.ReservedDiskMB = 20
gc := NewAllocGarbageCollector(logger, statsCollector, &gcConfig)

_, ar1 := testAllocRunnerFromAlloc(mock.Alloc(), false)
close(ar1.waitCh)
Expand Down Expand Up @@ -281,7 +293,8 @@ func TestAllocGarbageCollector_MakeRoomForAllocations_GC_Fallback(t *testing.T)
func TestAllocGarbageCollector_UsageBelowThreshold(t *testing.T) {
logger := log.New(os.Stdout, "", 0)
statsCollector := &MockStatsCollector{}
gc := NewAllocGarbageCollector(logger, statsCollector, 20)
gcConfig.ReservedDiskMB = 20
gc := NewAllocGarbageCollector(logger, statsCollector, &gcConfig)

_, ar1 := testAllocRunnerFromAlloc(mock.Alloc(), false)
close(ar1.waitCh)
Expand Down Expand Up @@ -314,7 +327,8 @@ func TestAllocGarbageCollector_UsageBelowThreshold(t *testing.T) {
func TestAllocGarbageCollector_UsedPercentThreshold(t *testing.T) {
logger := log.New(os.Stdout, "", 0)
statsCollector := &MockStatsCollector{}
gc := NewAllocGarbageCollector(logger, statsCollector, 20)
gcConfig.ReservedDiskMB = 20
gc := NewAllocGarbageCollector(logger, statsCollector, &gcConfig)

_, ar1 := testAllocRunnerFromAlloc(mock.Alloc(), false)
close(ar1.waitCh)
Expand Down
2 changes: 1 addition & 1 deletion demo/vagrant/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get install -y unzip curl wget vim
# Download Nomad
echo Fetching Nomad...
cd /tmp/
curl -sSL https://releases.hashicorp.com/nomad/0.5.2/nomad_0.5.2_linux_amd64.zip -o nomad.zip
curl -sSL https://releases.hashicorp.com/nomad/0.5.4/nomad_0.5.4_linux_amd64.zip -o nomad.zip
echo Installing Nomad...
unzip nomad.zip
Expand Down
5 changes: 4 additions & 1 deletion nomad/node_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,9 @@ func (n *Node) DeriveVaultToken(args *structs.DeriveVaultTokenRequest,
// setErr is a helper for setting the recoverable error on the reply and
// logging it
setErr := func(e error, recoverable bool) {
if e == nil {
return
}
reply.Error = structs.NewRecoverableError(e, recoverable).(*structs.RecoverableError)
n.srv.logger.Printf("[ERR] nomad.client: DeriveVaultToken failed (recoverable %v): %v", recoverable, e)
}
Expand Down Expand Up @@ -1133,7 +1136,7 @@ func (n *Node) DeriveVaultToken(args *structs.DeriveVaultTokenRequest,

if rerr, ok := createErr.(*structs.RecoverableError); ok {
reply.Error = rerr
} else {
} else if err != nil {
reply.Error = structs.NewRecoverableError(createErr, false).(*structs.RecoverableError)
}

Expand Down
3 changes: 3 additions & 0 deletions nomad/structs/config/vault_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ func TestVaultConfig_Merge(t *testing.T) {
c1 := &VaultConfig{
Enabled: &falseValue,
Token: "1",
Role: "1",
AllowUnauthenticated: &trueValue,
TaskTokenTTL: "1",
Addr: "1",
Expand All @@ -24,6 +25,7 @@ func TestVaultConfig_Merge(t *testing.T) {
c2 := &VaultConfig{
Enabled: &trueValue,
Token: "2",
Role: "2",
AllowUnauthenticated: &falseValue,
TaskTokenTTL: "2",
Addr: "2",
Expand All @@ -38,6 +40,7 @@ func TestVaultConfig_Merge(t *testing.T) {
e := &VaultConfig{
Enabled: &trueValue,
Token: "2",
Role: "2",
AllowUnauthenticated: &falseValue,
TaskTokenTTL: "2",
Addr: "2",
Expand Down
107 changes: 107 additions & 0 deletions vendor/github.com/circonus-labs/circonus-gometrics/OPTIONS.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 37121b4

Please sign in to comment.