Skip to content

Commit

Permalink
allocrunner: provide factory function so we can build mock ARs
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed May 12, 2023
1 parent 81eb6f1 commit ef63cdc
Show file tree
Hide file tree
Showing 23 changed files with 501 additions and 302 deletions.
14 changes: 4 additions & 10 deletions client/allocrunner/alloc_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/hashicorp/nomad/client/allocrunner/state"
"github.com/hashicorp/nomad/client/allocrunner/tasklifecycle"
"github.com/hashicorp/nomad/client/allocrunner/taskrunner"
"github.com/hashicorp/nomad/client/allocwatcher"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/client/consul"
"github.com/hashicorp/nomad/client/devicemanager"
Expand Down Expand Up @@ -152,10 +151,10 @@ type allocRunner struct {

// prevAllocWatcher allows waiting for any previous or preempted allocations
// to exit
prevAllocWatcher allocwatcher.PrevAllocWatcher
prevAllocWatcher config.PrevAllocWatcher

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

// dynamicRegistry contains all locally registered dynamic plugins (e.g csi
// plugins).
Expand Down Expand Up @@ -190,7 +189,7 @@ type allocRunner struct {

// rpcClient is the RPC Client that should be used by the allocrunner and its
// hooks to communicate with Nomad Servers.
rpcClient RPCer
rpcClient config.RPCer

// serviceRegWrapper is the handler wrapper that is used by service hooks
// to perform service and check registration and deregistration.
Expand All @@ -203,13 +202,8 @@ type allocRunner struct {
getter cinterfaces.ArtifactGetter
}

// RPCer is the interface needed by hooks to make RPC calls.
type RPCer interface {
RPC(method string, args interface{}, reply interface{}) error
}

// NewAllocRunner returns a new allocation runner.
func NewAllocRunner(config *Config) (*allocRunner, error) {
func NewAllocRunner(config *config.AllocRunnerConfig) (interfaces.AllocRunner, error) {
alloc := config.Alloc
tg := alloc.Job.LookupTaskGroup(alloc.TaskGroup)
if tg == nil {
Expand Down
Loading

0 comments on commit ef63cdc

Please sign in to comment.