fix integration slightly

This commit is contained in:
Alex Dadgar
2017-06-28 16:14:50 -07:00
parent c86af4d9e9
commit 6aae18ec1f
3 changed files with 26 additions and 1 deletions

View File

@@ -6,6 +6,10 @@ import "github.com/hashicorp/nomad/nomad/structs"
// methods. These should be set by the server and passed to the deployment
// watcher.
type deploymentWatcherStateShim struct {
// region is the region the server is a member of. It is used to
// auto-populate requests that do not have it set
region string
// evaluations returns the set of evaluations for the given job
evaluations func(args *structs.JobSpecificRequest, reply *structs.JobEvaluationsResponse) error
@@ -25,22 +29,42 @@ type deploymentWatcherStateShim struct {
}
func (d *deploymentWatcherStateShim) Evaluations(args *structs.JobSpecificRequest, reply *structs.JobEvaluationsResponse) error {
if args.Region == "" {
args.Region = d.region
}
return d.evaluations(args, reply)
}
func (d *deploymentWatcherStateShim) Allocations(args *structs.DeploymentSpecificRequest, reply *structs.AllocListResponse) error {
if args.Region == "" {
args.Region = d.region
}
return d.allocations(args, reply)
}
func (d *deploymentWatcherStateShim) List(args *structs.DeploymentListRequest, reply *structs.DeploymentListResponse) error {
if args.Region == "" {
args.Region = d.region
}
return d.list(args, reply)
}
func (d *deploymentWatcherStateShim) GetJobVersions(args *structs.JobSpecificRequest, reply *structs.JobVersionsResponse) error {
if args.Region == "" {
args.Region = d.region
}
return d.getJobVersions(args, reply)
}
func (d *deploymentWatcherStateShim) GetJob(args *structs.JobSpecificRequest, reply *structs.SingleJobResponse) error {
if args.Region == "" {
args.Region = d.region
}
return d.getJob(args, reply)
}

View File

@@ -686,6 +686,7 @@ func (s *Server) setupDeploymentWatcher() error {
// Create the shims
stateShim := &deploymentWatcherStateShim{
region: s.Region(),
evaluations: s.endpoints.Job.Evaluations,
allocations: s.endpoints.Deployment.Allocations,
list: s.endpoints.Deployment.List,

View File

@@ -383,7 +383,7 @@ func allocTableSchema() *memdb.TableSchema {
// Deployment index is used to lookup allocations by deployment
"deployment": &memdb.IndexSchema{
Name: "deployment",
AllowMissing: false,
AllowMissing: true,
Unique: false,
Indexer: &memdb.UUIDFieldIndex{
Field: "DeploymentID",