{"record":{"id":"4c1b00ce06dd98a8","repo":"hashicorp/nomad","slug":"node-pool-s-not-found","errorCode":null,"errorMessage":"node pool %s not found","messagePattern":"node pool (.+?) not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/state/state_store_node_pools.go","lineNumber":203,"sourceCode":"\t\t}\n\t}\n\n\t// Update index table.\n\tif err := txn.Insert(\"index\", &IndexEntry{TableNodePools, index}); err != nil {\n\t\treturn fmt.Errorf(\"index update failed: %w\", err)\n\t}\n\n\treturn txn.Commit()\n}\n\nfunc (s *StateStore) deleteNodePoolTxn(txn *txn, index uint64, name string) error {\n\t// Check if node pool exists.\n\texisting, err := txn.First(TableNodePools, \"id\", name)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"node pool lookup failed: %w\", err)\n\t}\n\tif existing == nil {\n\t\treturn fmt.Errorf(\"node pool %s not found\", name)\n\t}\n\n\tpool := existing.(*structs.NodePool)\n\n\t// Prevent deletion of built-in node pools.\n\tif pool.IsBuiltIn() {\n\t\treturn fmt.Errorf(\"deleting node pool %q is not allowed\", pool.Name)\n\t}\n\n\t// Delete node pool.\n\tif err := txn.Delete(TableNodePools, pool); err != nil {\n\t\treturn fmt.Errorf(\"node pool deletion failed: %w\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":185,"sourceCodeEnd":220,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store_node_pools.go#L185-L220","documentation":"deleteNodePoolTxn fails when the named node pool does not exist in the node_pools table. The lookup `txn.First(TableNodePools, \"id\", name)` returns nil, so the delete is rejected with this message rather than silently succeeding. Note deletion of existing non-built-in pools proceeds afterward only if the pool is not built-in and has no nodes.","triggerScenarios":"Calling DeleteNodePools with a name that was never created or has already been deleted — e.g. `nomad node pool delete <name>` for a typo'd name, or an automation deleting pools idempotently without an existence check.","commonSituations":"Typo'd pool name in CLI or Terraform config; racing deletions where two processes delete the same pool; environment drift where the pool exists in one cluster but not another (staging vs prod).","solutions":["Verify the pool name with `nomad node pool list` and correct any typo in the delete request.","Add an existence check (GET the node pool or txn.First on the table) before deleting to make automation idempotent.","Treat 'not found' as success in idempotent cleanup scripts and skip the delete.","Recreate the pool first if it was deleted accidentally and the delete is part of a larger transaction."],"exampleFix":"// before\nstateStore.DeleteNodePools(idx, []string{\"prod-pool\"}, nil) // may not exist\n\n// after\nif pool, _ := stateStore.NodePoolByName(nil, \"prod-pool\"); pool != nil {\n    stateStore.DeleteNodePools(idx, []string{\"prod-pool\"}, nil)\n}","handlingStrategy":"validation","validationCode":"existing, err := s.NodePoolByName(nil, name)\nif err != nil {\n    return err\n}\nif existing == nil {\n    return nil // already gone; treat as idempotent success\n}\nerr = s.DeleteNodePools(idx, []string{name}, nil)","typeGuard":"func poolExists(s *state.StateStore, name string) bool {\n    p, err := s.NodePoolByName(nil, name)\n    return err == nil && p != nil\n}","tryCatchPattern":"err := s.DeleteNodePools(idx, []string{name}, nil)\nif err != nil && strings.Contains(err.Error(), \"not found\") {\n    return nil // idempotent: pool already deleted\n}","preventionTips":["List pools with `nomad node pool list` and confirm the exact name before deleting.","Make cleanup scripts idempotent by treating not-found as success.","Use a single serialized process for pool lifecycle to avoid double-deletes.","Verify environment (cluster/namespace) before delete to avoid cross-env name mismatches."],"tags":["nomad","state-store","node-pool","not-found"],"backgroundTag":"entity-not-found","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"}