diff --git a/client/gc_test.go b/client/gc_test.go index 8ae97a3cc..cc3e7aa27 100644 --- a/client/gc_test.go +++ b/client/gc_test.go @@ -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() @@ -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 { @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/nomad/structs/config/vault_test.go b/nomad/structs/config/vault_test.go index 29f7ea590..f92f1dde7 100644 --- a/nomad/structs/config/vault_test.go +++ b/nomad/structs/config/vault_test.go @@ -10,6 +10,7 @@ func TestVaultConfig_Merge(t *testing.T) { c1 := &VaultConfig{ Enabled: &falseValue, Token: "1", + Role: "1", AllowUnauthenticated: &trueValue, TaskTokenTTL: "1", Addr: "1", @@ -24,6 +25,7 @@ func TestVaultConfig_Merge(t *testing.T) { c2 := &VaultConfig{ Enabled: &trueValue, Token: "2", + Role: "2", AllowUnauthenticated: &falseValue, TaskTokenTTL: "2", Addr: "2", @@ -38,6 +40,7 @@ func TestVaultConfig_Merge(t *testing.T) { e := &VaultConfig{ Enabled: &trueValue, Token: "2", + Role: "2", AllowUnauthenticated: &falseValue, TaskTokenTTL: "2", Addr: "2", diff --git a/website/source/docs/drivers/rkt.html.md b/website/source/docs/drivers/rkt.html.md index eb8995012..b3efe62a4 100644 --- a/website/source/docs/drivers/rkt.html.md +++ b/website/source/docs/drivers/rkt.html.md @@ -73,16 +73,18 @@ The `rkt` driver supports the following configuration in the job spec: * `net` - (Optional) A list of networks to be used by the containers -* `port_map` - (Optional) A key/value map of port to be used by the container. - port name in the image manifest file needs to be specified for the value. For example: +* `port_map` - (Optional) A key/value map of ports used by the container. The + value is the port name specified in the image manifest file. When running + Docker images with rkt the port names will be of the form `${PORT}-tcp`. See + [networking](#networking) below for more details. - ``` + ```hcl port_map { + # If running a Docker image that exposes port 8080 app = "8080-tcp" } ``` - - See below for more details. + * `debug` - (Optional) Enable rkt command debug option.