diff --git a/client/allocrunner/alloc_runner.go b/client/allocrunnerdeprecated/alloc_runner.go similarity index 99% rename from client/allocrunner/alloc_runner.go rename to client/allocrunnerdeprecated/alloc_runner.go index f436340f0..97351ccdc 100644 --- a/client/allocrunner/alloc_runner.go +++ b/client/allocrunnerdeprecated/alloc_runner.go @@ -12,7 +12,7 @@ import ( "github.com/boltdb/bolt" "github.com/hashicorp/go-multierror" "github.com/hashicorp/nomad/client/allocdir" - "github.com/hashicorp/nomad/client/allocrunner/taskrunner" + "github.com/hashicorp/nomad/client/allocrunnerdeprecated/taskrunner" "github.com/hashicorp/nomad/client/allocwatcher" "github.com/hashicorp/nomad/client/config" consulApi "github.com/hashicorp/nomad/client/consul" diff --git a/client/allocrunner/alloc_runner_health_watcher.go b/client/allocrunnerdeprecated/alloc_runner_health_watcher.go similarity index 100% rename from client/allocrunner/alloc_runner_health_watcher.go rename to client/allocrunnerdeprecated/alloc_runner_health_watcher.go diff --git a/client/allocrunner/alloc_runner_test.go b/client/allocrunnerdeprecated/alloc_runner_test.go similarity index 99% rename from client/allocrunner/alloc_runner_test.go rename to client/allocrunnerdeprecated/alloc_runner_test.go index f6dc39c49..38fc9927c 100644 --- a/client/allocrunner/alloc_runner_test.go +++ b/client/allocrunnerdeprecated/alloc_runner_test.go @@ -19,7 +19,7 @@ import ( "github.com/hashicorp/nomad/testutil" "github.com/stretchr/testify/assert" - "github.com/hashicorp/nomad/client/allocrunner/taskrunner" + "github.com/hashicorp/nomad/client/allocrunnerdeprecated/taskrunner" consulApi "github.com/hashicorp/nomad/client/consul" "github.com/hashicorp/nomad/client/state" "github.com/stretchr/testify/require" diff --git a/client/allocrunner/taskrunner/consul_template.go b/client/allocrunnerdeprecated/taskrunner/consul_template.go similarity index 100% rename from client/allocrunner/taskrunner/consul_template.go rename to client/allocrunnerdeprecated/taskrunner/consul_template.go diff --git a/client/allocrunner/taskrunner/consul_template_test.go b/client/allocrunnerdeprecated/taskrunner/consul_template_test.go similarity index 100% rename from client/allocrunner/taskrunner/consul_template_test.go rename to client/allocrunnerdeprecated/taskrunner/consul_template_test.go diff --git a/client/allocrunner/taskrunner/getters.go b/client/allocrunnerdeprecated/taskrunner/getters.go similarity index 100% rename from client/allocrunner/taskrunner/getters.go rename to client/allocrunnerdeprecated/taskrunner/getters.go diff --git a/client/allocrunner/taskrunner/task_runner.go b/client/allocrunnerdeprecated/taskrunner/task_runner.go similarity index 99% rename from client/allocrunner/taskrunner/task_runner.go rename to client/allocrunnerdeprecated/taskrunner/task_runner.go index 386fb672a..d7054334c 100644 --- a/client/allocrunner/taskrunner/task_runner.go +++ b/client/allocrunnerdeprecated/taskrunner/task_runner.go @@ -21,8 +21,8 @@ import ( "github.com/hashicorp/go-multierror" version "github.com/hashicorp/go-version" "github.com/hashicorp/nomad/client/allocdir" - "github.com/hashicorp/nomad/client/allocrunner/getter" - "github.com/hashicorp/nomad/client/allocrunner/taskrunner/restarts" + "github.com/hashicorp/nomad/client/allocrunnerv2/taskrunner/getter" + "github.com/hashicorp/nomad/client/allocrunnerv2/taskrunner/restarts" "github.com/hashicorp/nomad/client/config" consulApi "github.com/hashicorp/nomad/client/consul" "github.com/hashicorp/nomad/client/driver" diff --git a/client/allocrunner/taskrunner/task_runner_test.go b/client/allocrunnerdeprecated/taskrunner/task_runner_test.go similarity index 99% rename from client/allocrunner/taskrunner/task_runner_test.go rename to client/allocrunnerdeprecated/taskrunner/task_runner_test.go index 68e082616..f5ba3063a 100644 --- a/client/allocrunner/taskrunner/task_runner_test.go +++ b/client/allocrunnerdeprecated/taskrunner/task_runner_test.go @@ -16,7 +16,7 @@ import ( "github.com/boltdb/bolt" "github.com/golang/snappy" "github.com/hashicorp/nomad/client/allocdir" - "github.com/hashicorp/nomad/client/allocrunner/taskrunner/restarts" + "github.com/hashicorp/nomad/client/allocrunnerv2/taskrunner/restarts" "github.com/hashicorp/nomad/client/config" consulApi "github.com/hashicorp/nomad/client/consul" "github.com/hashicorp/nomad/client/driver/env" diff --git a/client/allocrunner/taskrunner/task_runner_unix_test.go b/client/allocrunnerdeprecated/taskrunner/task_runner_unix_test.go similarity index 100% rename from client/allocrunner/taskrunner/task_runner_unix_test.go rename to client/allocrunnerdeprecated/taskrunner/task_runner_unix_test.go diff --git a/client/allocrunner/testing.go b/client/allocrunnerdeprecated/testing.go similarity index 100% rename from client/allocrunner/testing.go rename to client/allocrunnerdeprecated/testing.go diff --git a/client/allocrunnerv2/alloc_runner.go b/client/allocrunnerv2/alloc_runner.go index 19ff1b32b..ed77eddf5 100644 --- a/client/allocrunnerv2/alloc_runner.go +++ b/client/allocrunnerv2/alloc_runner.go @@ -9,7 +9,6 @@ import ( log "github.com/hashicorp/go-hclog" "github.com/hashicorp/nomad/client/allocdir" - "github.com/hashicorp/nomad/client/allocrunner" "github.com/hashicorp/nomad/client/allocrunnerv2/interfaces" "github.com/hashicorp/nomad/client/allocrunnerv2/state" "github.com/hashicorp/nomad/client/allocrunnerv2/taskrunner" @@ -501,7 +500,7 @@ func (ar *allocRunner) IsMigrating() bool { return ar.prevAllocWatcher.IsMigrating() } -func (ar *allocRunner) StatsReporter() allocrunner.AllocStatsReporter { +func (ar *allocRunner) StatsReporter() interfaces.AllocStatsReporter { return ar } diff --git a/client/allocrunnerv2/interfaces/runner.go b/client/allocrunnerv2/interfaces/runner.go index 3925e2384..4658e3aa3 100644 --- a/client/allocrunnerv2/interfaces/runner.go +++ b/client/allocrunnerv2/interfaces/runner.go @@ -3,6 +3,8 @@ package interfaces import ( "github.com/hashicorp/nomad/client/allocrunnerv2/state" "github.com/hashicorp/nomad/nomad/structs" + + cstructs "github.com/hashicorp/nomad/client/structs" ) // AllocRunner is the interface for an allocation runner. @@ -25,3 +27,9 @@ type TaskStateHandler interface { // TaskStateUpdated is used to emit updated task state TaskStateUpdated(task string, state *structs.TaskState) } + +// AllocStatsReporter gives acess to the latest resource usage from the +// allocation +type AllocStatsReporter interface { + LatestAllocStats(taskFilter string) (*cstructs.AllocResourceUsage, error) +} diff --git a/client/allocrunnerv2/taskrunner/artifact_hook.go b/client/allocrunnerv2/taskrunner/artifact_hook.go index 2253fdfe3..de8e1703e 100644 --- a/client/allocrunnerv2/taskrunner/artifact_hook.go +++ b/client/allocrunnerv2/taskrunner/artifact_hook.go @@ -5,8 +5,8 @@ import ( "fmt" log "github.com/hashicorp/go-hclog" - "github.com/hashicorp/nomad/client/allocrunner/getter" "github.com/hashicorp/nomad/client/allocrunnerv2/interfaces" + "github.com/hashicorp/nomad/client/allocrunnerv2/taskrunner/getter" ti "github.com/hashicorp/nomad/client/allocrunnerv2/taskrunner/interfaces" "github.com/hashicorp/nomad/nomad/structs" ) diff --git a/client/allocrunner/getter/getter.go b/client/allocrunnerv2/taskrunner/getter/getter.go similarity index 100% rename from client/allocrunner/getter/getter.go rename to client/allocrunnerv2/taskrunner/getter/getter.go diff --git a/client/allocrunner/getter/getter_test.go b/client/allocrunnerv2/taskrunner/getter/getter_test.go similarity index 100% rename from client/allocrunner/getter/getter_test.go rename to client/allocrunnerv2/taskrunner/getter/getter_test.go diff --git a/client/allocrunner/getter/test-fixtures/archive.tar.gz b/client/allocrunnerv2/taskrunner/getter/test-fixtures/archive.tar.gz similarity index 100% rename from client/allocrunner/getter/test-fixtures/archive.tar.gz rename to client/allocrunnerv2/taskrunner/getter/test-fixtures/archive.tar.gz diff --git a/client/allocrunner/getter/test-fixtures/archive/exist/my.config b/client/allocrunnerv2/taskrunner/getter/test-fixtures/archive/exist/my.config similarity index 100% rename from client/allocrunner/getter/test-fixtures/archive/exist/my.config rename to client/allocrunnerv2/taskrunner/getter/test-fixtures/archive/exist/my.config diff --git a/client/allocrunner/getter/test-fixtures/archive/new/my.config b/client/allocrunnerv2/taskrunner/getter/test-fixtures/archive/new/my.config similarity index 100% rename from client/allocrunner/getter/test-fixtures/archive/new/my.config rename to client/allocrunnerv2/taskrunner/getter/test-fixtures/archive/new/my.config diff --git a/client/allocrunner/getter/test-fixtures/archive/test.sh b/client/allocrunnerv2/taskrunner/getter/test-fixtures/archive/test.sh similarity index 100% rename from client/allocrunner/getter/test-fixtures/archive/test.sh rename to client/allocrunnerv2/taskrunner/getter/test-fixtures/archive/test.sh diff --git a/client/allocrunner/getter/test-fixtures/test.sh b/client/allocrunnerv2/taskrunner/getter/test-fixtures/test.sh similarity index 100% rename from client/allocrunner/getter/test-fixtures/test.sh rename to client/allocrunnerv2/taskrunner/getter/test-fixtures/test.sh diff --git a/client/allocrunner/taskrunner/restarts/restarts.go b/client/allocrunnerv2/taskrunner/restarts/restarts.go similarity index 100% rename from client/allocrunner/taskrunner/restarts/restarts.go rename to client/allocrunnerv2/taskrunner/restarts/restarts.go diff --git a/client/allocrunner/taskrunner/restarts/restarts_test.go b/client/allocrunnerv2/taskrunner/restarts/restarts_test.go similarity index 100% rename from client/allocrunner/taskrunner/restarts/restarts_test.go rename to client/allocrunnerv2/taskrunner/restarts/restarts_test.go diff --git a/client/allocrunnerv2/taskrunner/task_runner.go b/client/allocrunnerv2/taskrunner/task_runner.go index cf541e720..1171e8aaa 100644 --- a/client/allocrunnerv2/taskrunner/task_runner.go +++ b/client/allocrunnerv2/taskrunner/task_runner.go @@ -9,8 +9,8 @@ import ( metrics "github.com/armon/go-metrics" log "github.com/hashicorp/go-hclog" "github.com/hashicorp/nomad/client/allocdir" - "github.com/hashicorp/nomad/client/allocrunner/taskrunner/restarts" "github.com/hashicorp/nomad/client/allocrunnerv2/interfaces" + "github.com/hashicorp/nomad/client/allocrunnerv2/taskrunner/restarts" "github.com/hashicorp/nomad/client/allocrunnerv2/taskrunner/state" "github.com/hashicorp/nomad/client/config" "github.com/hashicorp/nomad/client/consul" diff --git a/client/client.go b/client/client.go index 2fbeaf7c5..837708bb9 100644 --- a/client/client.go +++ b/client/client.go @@ -18,6 +18,7 @@ import ( consulapi "github.com/hashicorp/consul/api" hclog "github.com/hashicorp/go-hclog" multierror "github.com/hashicorp/go-multierror" + "github.com/hashicorp/nomad/client/allocrunnerv2/interfaces" arstate "github.com/hashicorp/nomad/client/allocrunnerv2/state" consulApi "github.com/hashicorp/nomad/client/consul" cstructs "github.com/hashicorp/nomad/client/structs" @@ -27,7 +28,6 @@ import ( "github.com/hashicorp/consul/lib" "github.com/hashicorp/nomad/client/allocdir" - "github.com/hashicorp/nomad/client/allocrunner" "github.com/hashicorp/nomad/client/allocrunnerv2" "github.com/hashicorp/nomad/client/allocwatcher" "github.com/hashicorp/nomad/client/config" @@ -94,7 +94,7 @@ const ( type ClientStatsReporter interface { // GetAllocStats returns the AllocStatsReporter for the passed allocation. // If it does not exist an error is reported. - GetAllocStats(allocID string) (allocrunner.AllocStatsReporter, error) + GetAllocStats(allocID string) (interfaces.AllocStatsReporter, error) // LatestHostStats returns the latest resource usage stats for the host LatestHostStats() *stats.HostStats @@ -113,7 +113,7 @@ type AllocRunner interface { Listener() *cstructs.AllocListener Restore() error Run() - StatsReporter() allocrunner.AllocStatsReporter + StatsReporter() interfaces.AllocStatsReporter Update(*structs.Allocation) WaitCh() <-chan struct{} } @@ -600,7 +600,7 @@ func (c *Client) StatsReporter() ClientStatsReporter { return c } -func (c *Client) GetAllocStats(allocID string) (allocrunner.AllocStatsReporter, error) { +func (c *Client) GetAllocStats(allocID string) (interfaces.AllocStatsReporter, error) { c.allocLock.RLock() defer c.allocLock.RUnlock() ar, ok := c.allocs[allocID] diff --git a/command/alloc_status.go b/command/alloc_status.go index 773791c59..c4373fd7c 100644 --- a/command/alloc_status.go +++ b/command/alloc_status.go @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/nomad/api" "github.com/hashicorp/nomad/api/contexts" - "github.com/hashicorp/nomad/client/allocrunner/taskrunner/restarts" + "github.com/hashicorp/nomad/client/allocrunnerv2/taskrunner/restarts" "github.com/posener/complete" )