{"record":{"id":"a964ef71fb62ea12","repo":"hashicorp/nomad","slug":"stopafterclientdisconnect-is-deprecated-and-ignore","errorCode":null,"errorMessage":"StopAfterClientDisconnect is deprecated and ignored favor of Disconnect.StopOnClientAfter","messagePattern":"StopAfterClientDisconnect is deprecated and ignored favor of Disconnect\\.StopOnClientAfter","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":7657,"sourceCode":"func (tg *TaskGroup) Warnings(j *Job) error {\n\tvar mErr multierror.Error\n\n\t// Validate the update strategy\n\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}","sourceCodeStart":7639,"sourceCodeEnd":7675,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L7639-L7675","documentation":"TaskGroup.Validate rejects the deprecated task-group field StopAfterClientDisconnect. Nomad replaced the ad-hoc client-disconnect handling fields with the structured `disconnect` block; setting the old field makes the job specification invalid. The error is accumulated into the group's multierror during job validation.","triggerScenarios":"Submitting or validating a job whose group still sets `stop_after_client_disconnect` (or StopAfterClientDisconnect in Go) after upgrading to a Nomad version that deprecates it in favor of `disconnect { stop_on_client_after = ... }`.","commonSituations":"Upgrading an older Nomad job file (pre-1.7/1.8 style) that used stop_after_client_disconnect for lost-client behavior; copy-pasting legacy HCL/JSON jobs into a newer cluster.","solutions":["Remove stop_after_client_disconnect from the task group.","Add a `disconnect { stop_on_client_after = <duration> }` block with the equivalent value.","Re-run `nomad job validate` (or the API validate endpoint) to confirm no other deprecated fields remain."],"exampleFix":"// before\ngroup \"web\" {\n  stop_after_client_disconnect = \"15m\"\n}\n// after\ngroup \"web\" {\n  disconnect {\n    stop_on_client_after = \"15m\"\n  }\n}","handlingStrategy":"validation","validationCode":"for _, dep := range []string{\"stop_after_client_disconnect\"} {\n  if strings.Contains(jobHCL, dep) {\n    return fmt.Errorf(\"group uses deprecated %s; migrate to disconnect { stop_on_client_after }\", dep)\n  }\n}","typeGuard":"func usesLegacyDisconnect(tg *structs.TaskGroup) bool {\n  return tg.StopAfterClientDisconnect != nil\n}","tryCatchPattern":null,"preventionTips":["Run `nomad job validate` in CI on every job file.","Grep job repos for deprecated fields after each Nomad upgrade.","Prefer the disconnect block in all new job specs.","Pin a lint rule banning stop_after_client_disconnect."],"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"}