{"record":{"id":"5ccfede6f8819160","repo":"hashicorp/nomad","slug":"preventrescheduleonlost-is-deprecated-and-ignored","errorCode":null,"errorMessage":"PreventRescheduleOnLost is deprecated and ignored in favor of Disconnect.Replace","messagePattern":"PreventRescheduleOnLost is deprecated and ignored in favor of Disconnect\\.Replace","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":7661,"sourceCode":"\tif u := tg.Update; u != nil {\n\t\t// Check the counts are appropriate\n\t\tif tg.Count > 1 && u.MaxParallel > tg.Count && !(j.IsMultiregion() && tg.Count == 0) {\n\t\t\tmErr.Errors = append(mErr.Errors,\n\t\t\t\tfmt.Errorf(\"Update max parallel count is greater than task group count (%d > %d). \"+\n\t\t\t\t\t\"A destructive change would result in the simultaneous replacement of all allocations.\", u.MaxParallel, tg.Count))\n\t\t}\n\t}\n\n\tif tg.MaxClientDisconnect != nil {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"MaxClientDisconnect is deprecated and ignored in favor of Disconnect.LostAfter\"))\n\t}\n\n\tif tg.StopAfterClientDisconnect != nil {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"StopAfterClientDisconnect is deprecated and ignored favor of Disconnect.StopOnClientAfter\"))\n\t}\n\n\tif tg.PreventRescheduleOnLost {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"PreventRescheduleOnLost is deprecated and ignored in favor of Disconnect.Replace\"))\n\t}\n\n\t// Warn about unbounded rescheduling which may cause thrashing if tasks have\n\t// unlimited attempts and a low delay.\n\t//\n\t// The 5 second gate on the delay is used as this was the previous minimum\n\t// value which did not produce a warning. It therefore feels like the right\n\t// gate to use.\n\tif rp := tg.ReschedulePolicy; rp != nil && rp.Unlimited && rp.Delay < 5*time.Second {\n\t\tmErr.Errors = append(\n\t\t\tmErr.Errors,\n\t\t\terrors.New(\"Reschedule policy has unlimited attempts enabled and a low delay; reschedule thrashing possible\"),\n\t\t)\n\t}\n\n\t// Check for mbits network field\n\tif len(tg.Networks) > 0 && tg.Networks[0].MBits > 0 {\n\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"mbits has been deprecated as of Nomad 0.12.0. Please remove mbits from the network block\"))","sourceCodeStart":7643,"sourceCodeEnd":7679,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L7643-L7679","documentation":"TaskGroup.Validate rejects the deprecated task-group field PreventRescheduleOnLost. Its behavior was replaced by the `disconnect { replace = ... }` field, so any job still setting it fails validation. It is appended to the same multierror as the other deprecated disconnect-related fields.","triggerScenarios":"Submitting a job whose group sets `prevent_reschedule_on_lost = true` (or false) on a Nomad version where the disconnect block supersedes it.","commonSituations":"Old job files carried forward across upgrades; documentation or modules generated before the disconnect block existed.","solutions":["Remove prevent_reschedule_on_lost from the task group.","Add `disconnect { replace = true }` (or false) to express the same intent.","Validate the job with `nomad job validate` before submitting."],"exampleFix":"// before\ngroup \"batch\" {\n  prevent_reschedule_on_lost = true\n}\n// after\ngroup \"batch\" {\n  disconnect {\n    replace = true\n  }\n}","handlingStrategy":"validation","validationCode":"if strings.Contains(jobHCL, \"prevent_reschedule_on_lost\") {\n  return errors.New(\"deprecated field prevent_reschedule_on_lost; use disconnect { replace }\")\n}","typeGuard":"func usesPreventRescheduleOnLost(tg *structs.TaskGroup) bool {\n  return tg.PreventRescheduleOnLost\n}","tryCatchPattern":null,"preventionTips":["Migrate all job files to the disconnect block.","Add deprecated-field checks to CI validation.","Review Nomad upgrade notes before bumping cluster version."],"tags":["nomad","job-spec","deprecation","validation"],"backgroundTag":"deprecated-job-field","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"}