mirror of
https://github.com/kemko/nomad.git
synced 2026-01-14 22:35:42 +03:00
fix integration slightly
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user