{"record":{"id":"88b74e7c03b3b58b","repo":"hashicorp/nomad","slug":"reschedule-policy-with-attempts-v-interval","errorCode":null,"errorMessage":"Reschedule Policy with Attempts = %v, Interval = %v, and Unlimited = %v is ambiguous","messagePattern":"Reschedule Policy with Attempts = (.+?), Interval = (.+?), and Unlimited = (.+?) is ambiguous","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":6658,"sourceCode":"\treturn enabled\n}\n\n// Validate uses different criteria to validate the reschedule policy\n// Delay must be a minimum of 1 second\n// Delay Ceiling is ignored if Delay Function is \"constant\"\n// Number of possible attempts is validated, given the interval, delay and delay function\nfunc (r *ReschedulePolicy) Validate() error {\n\tif !r.Enabled() {\n\t\treturn nil\n\t}\n\tvar mErr multierror.Error\n\t// Check for ambiguous/confusing settings\n\tif r.Attempts > 0 {\n\t\tif r.Interval <= 0 {\n\t\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"Interval must be a non zero value if Attempts > 0\"))\n\t\t}\n\t\tif r.Unlimited {\n\t\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"Reschedule Policy with Attempts = %v, Interval = %v, \"+\n\t\t\t\t\"and Unlimited = %v is ambiguous\", r.Attempts, r.Interval, r.Unlimited))\n\t\t\t_ = multierror.Append(&mErr, errors.New(\"If Attempts >0, Unlimited cannot also be set to true\"))\n\t\t}\n\t}\n\n\tdelayPreCheck := true\n\t// Delay should be bigger than the default\n\tif r.Delay.Nanoseconds() < ReschedulePolicyMinDelay.Nanoseconds() {\n\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"Delay cannot be less than %v (got %v)\", ReschedulePolicyMinDelay, r.Delay))\n\t\tdelayPreCheck = false\n\t}\n\n\t// Must use a valid delay function\n\tif !isValidDelayFunction(r.DelayFunction) {\n\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"Invalid delay function %q, must be one of %q\", r.DelayFunction, RescheduleDelayFunctions))\n\t\tdelayPreCheck = false\n\t}\n","sourceCodeStart":6640,"sourceCodeEnd":6676,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L6640-L6676","documentation":"ReschedulePolicy.Validate() rejects a policy that both limits reschedules (Attempts > 0) and sets Unlimited = true. Unlimited means 'keep rescheduling forever', which contradicts a finite attempt count, so the combination is ambiguous and disallowed.","triggerScenarios":"A reschedule block with attempts > 0 and unlimited = true together, or programmatic policy construction where attempts defaults above 0 while unlimited is set true.","commonSituations":"Users adding unlimited = true to 'be safe' without zeroing attempts; templates that always emit unlimited; merging default policies (attempts>0) with user overrides (unlimited=true).","solutions":["Remove unlimited = true if you want a limited policy.","Set attempts = 0 (and drop interval) if you truly want unlimited rescheduling.","Choose one style: {attempts>0, interval>0, unlimited=false} or {attempts=0, unlimited=true}."],"exampleFix":"// before\nreschedule {\n  attempts  = 5\n  interval  = \"1h\"\n  unlimited = true\n}\n// after\nreschedule {\n  attempts  = 5\n  interval  = \"1h\"\n  unlimited = false\n}","handlingStrategy":"validation","validationCode":"if rsl != nil && rsl.Attempts > 0 && rsl.Unlimited {\n    return fmt.Errorf(\"reschedule policy cannot set both attempts>0 and unlimited=true\")\n}","typeGuard":"func rescheduleModeConsistent(r *structs.ReschedulePolicy) bool {\n    return !(r.Attempts > 0 && r.Unlimited)\n}","tryCatchPattern":null,"preventionTips":["Pick one mode: limited (attempts/interval) or unlimited; never mix.","When overriding defaults programmatically, reset conflicting fields.","Document unlimited=true semantics in job templates."],"tags":["nomad","validation","reschedule-policy","conflicting-options"],"backgroundTag":"invalid-config-combination","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}