mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
Merge branch 'main' into f-NMD-763-identity
This commit is contained in:
@@ -307,6 +307,7 @@ type AllocationMetric struct {
|
||||
NodesEvaluated int
|
||||
NodesFiltered int
|
||||
NodesInPool int
|
||||
NodePool string
|
||||
NodesAvailable map[string]int
|
||||
ClassFiltered map[string]int
|
||||
ConstraintFiltered map[string]int
|
||||
|
||||
@@ -161,7 +161,7 @@ func TestSetQueryOptions(t *testing.T) {
|
||||
c, s := makeClient(t, nil, nil)
|
||||
defer s.Stop()
|
||||
|
||||
r, _ := c.newRequest("GET", "/v1/jobs")
|
||||
r, _ := c.newRequest("GET", "/v1/jobs?format=baz")
|
||||
q := &QueryOptions{
|
||||
Region: "foo",
|
||||
Namespace: "bar",
|
||||
@@ -188,6 +188,7 @@ func TestSetQueryOptions(t *testing.T) {
|
||||
try("index", "1000")
|
||||
try("wait", "100000ms")
|
||||
try("reverse", "true")
|
||||
try("format", "baz")
|
||||
}
|
||||
|
||||
func TestQueryOptionsContext(t *testing.T) {
|
||||
|
||||
@@ -46,7 +46,7 @@ func (e *Evaluations) Count(q *QueryOptions) (*EvalCountResponse, *QueryMeta, er
|
||||
// Info is used to query a single evaluation by its ID.
|
||||
func (e *Evaluations) Info(evalID string, q *QueryOptions) (*Evaluation, *QueryMeta, error) {
|
||||
var resp Evaluation
|
||||
qm, err := e.client.query("/v1/evaluation/"+evalID, &resp, q)
|
||||
qm, err := e.client.query("/v1/evaluation/"+evalID+"?related=true", &resp, q)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -116,6 +116,7 @@ type Evaluation struct {
|
||||
BlockedEval string
|
||||
RelatedEvals []*EvaluationStub
|
||||
FailedTGAllocs map[string]*AllocationMetric
|
||||
PlanAnnotations *PlanAnnotations
|
||||
ClassEligibility map[string]bool
|
||||
EscapedComputedClass bool
|
||||
QuotaLimitReached string
|
||||
|
||||
@@ -1596,6 +1596,10 @@ type DesiredUpdates struct {
|
||||
DestructiveUpdate uint64
|
||||
Canary uint64
|
||||
Preemptions uint64
|
||||
Disconnect uint64
|
||||
Reconnect uint64
|
||||
RescheduleNow uint64
|
||||
RescheduleLater uint64
|
||||
}
|
||||
|
||||
type JobDispatchRequest struct {
|
||||
|
||||
@@ -254,6 +254,9 @@ type Service struct {
|
||||
|
||||
// Cluster is valid only for Nomad Enterprise with provider: consul
|
||||
Cluster string `hcl:"cluster,optional"`
|
||||
|
||||
// Kind defines the consul service kind, valid only when provider: consul
|
||||
Kind string `hcl:"kind,optional"`
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
24
api/tasks.go
24
api/tasks.go
@@ -202,6 +202,9 @@ func (r *ReschedulePolicy) Merge(rp *ReschedulePolicy) {
|
||||
}
|
||||
|
||||
func (r *ReschedulePolicy) Canonicalize(jobType string) {
|
||||
if r == nil || jobType == JobTypeSystem || jobType == JobTypeSysbatch {
|
||||
return
|
||||
}
|
||||
dp := NewDefaultReschedulePolicy(jobType)
|
||||
if r.Interval == nil {
|
||||
r.Interval = dp.Interval
|
||||
@@ -282,16 +285,6 @@ func NewDefaultReschedulePolicy(jobType string) *ReschedulePolicy {
|
||||
Unlimited: pointerOf(false),
|
||||
}
|
||||
|
||||
case "system":
|
||||
dp = &ReschedulePolicy{
|
||||
Attempts: pointerOf(0),
|
||||
Interval: pointerOf(time.Duration(0)),
|
||||
Delay: pointerOf(time.Duration(0)),
|
||||
DelayFunction: pointerOf(""),
|
||||
MaxDelay: pointerOf(time.Duration(0)),
|
||||
Unlimited: pointerOf(false),
|
||||
}
|
||||
|
||||
default:
|
||||
// GH-7203: it is possible an unknown job type is passed to this
|
||||
// function and we need to ensure a non-nil object is returned so that
|
||||
@@ -583,13 +576,10 @@ func (g *TaskGroup) Canonicalize(job *Job) {
|
||||
jobReschedule := job.Reschedule.Copy()
|
||||
g.ReschedulePolicy = jobReschedule
|
||||
}
|
||||
// Only use default reschedule policy for non system jobs
|
||||
if g.ReschedulePolicy == nil && *job.Type != "system" {
|
||||
if g.ReschedulePolicy == nil && *job.Type != JobTypeSysbatch && *job.Type != JobTypeSystem {
|
||||
g.ReschedulePolicy = NewDefaultReschedulePolicy(*job.Type)
|
||||
}
|
||||
if g.ReschedulePolicy != nil {
|
||||
g.ReschedulePolicy.Canonicalize(*job.Type)
|
||||
}
|
||||
g.ReschedulePolicy.Canonicalize(*job.Type)
|
||||
|
||||
// Merge the migrate strategy from the job
|
||||
if jm, tm := job.Migrate != nil, g.Migrate != nil; jm && tm {
|
||||
@@ -757,13 +747,13 @@ const (
|
||||
)
|
||||
|
||||
type TaskLifecycle struct {
|
||||
Hook string `mapstructure:"hook" hcl:"hook,optional"`
|
||||
Hook string `mapstructure:"hook" hcl:"hook"`
|
||||
Sidecar bool `mapstructure:"sidecar" hcl:"sidecar,optional"`
|
||||
}
|
||||
|
||||
// Determine if lifecycle has user-input values
|
||||
func (l *TaskLifecycle) Empty() bool {
|
||||
return l == nil || (l.Hook == "")
|
||||
return l == nil
|
||||
}
|
||||
|
||||
// Task is a single process in a task group.
|
||||
|
||||
@@ -344,10 +344,36 @@ func TestTask_Canonicalize_TaskLifecycle(t *testing.T) {
|
||||
{
|
||||
name: "empty",
|
||||
task: &Task{
|
||||
Lifecycle: &TaskLifecycle{},
|
||||
Lifecycle: nil,
|
||||
},
|
||||
expected: nil,
|
||||
},
|
||||
{
|
||||
name: "missing hook",
|
||||
task: &Task{
|
||||
Lifecycle: &TaskLifecycle{},
|
||||
},
|
||||
expected: &TaskLifecycle{},
|
||||
},
|
||||
{
|
||||
name: "with sidecar",
|
||||
task: &Task{
|
||||
Lifecycle: &TaskLifecycle{
|
||||
Sidecar: true,
|
||||
},
|
||||
},
|
||||
expected: &TaskLifecycle{Sidecar: true},
|
||||
},
|
||||
{
|
||||
name: "valid",
|
||||
task: &Task{
|
||||
Lifecycle: &TaskLifecycle{
|
||||
Hook: "prestart",
|
||||
Sidecar: true,
|
||||
},
|
||||
},
|
||||
expected: &TaskLifecycle{Hook: "prestart", Sidecar: true},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
||||
Reference in New Issue
Block a user