{"record":{"id":"63710866761d5b7e","repo":"hashicorp/nomad","slug":"deleting-node-pool-q-is-not-allowed","errorCode":null,"errorMessage":"deleting node pool %q is not allowed","messagePattern":"deleting node pool %q is not allowed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/state/state_store_node_pools.go","lineNumber":210,"sourceCode":"\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":192,"sourceCodeEnd":220,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store_node_pools.go#L192-L220","documentation":"Nomad's state store refuses to delete built-in node pools (e.g. 'default', 'all'). Node pools marked IsBuiltIn() are foundational to cluster operation, so deleteNodePoolTxn rejects the delete with this error before touching the table. It is a deliberate policy guard, not an infrastructure failure.","triggerScenarios":"Calling StateStore.DeleteNodePools (via the NodePools.Delete RPC / `nomad node pool delete`) for a built-in pool such as 'default' or 'all'.","commonSituations":"Operators scripting node pool cleanup accidentally targeting 'default'; tools that iterate all node pools and attempt deletion of each; automation that deletes pools before checking pool origin.","solutions":["Skip pools where structs.NodePool.IsBuiltIn() returns true before issuing the delete","Filter out built-in pool names (default, all) in client-side tooling before calling the node-pool delete API","If a custom pool was misconfigured as built-in, it is not — built-ins are hard-coded; recreate your workload pool under a non-built-in name"],"exampleFix":"// before\nfor _, pool := range pools {\n    if err := client.NodePools().Delete(pool.Name, nil); err != nil { ... }\n}\n// after\nfor _, pool := range pools {\n    if structs.NewNodePool(pool.Name).IsBuiltIn() {\n        continue // skip built-in pools\n    }\n    if err := client.NodePools().Delete(pool.Name, nil); err != nil { ... }\n}","handlingStrategy":"validation","validationCode":"func canDeleteNodePool(name string) bool {\n    switch structs.NodePoolDefault, structs.NodePoolAll { // built-in names\n    case name:\n        return false\n    }\n    return true\n}\nif !canDeleteNodePool(poolName) {\n    return fmt.Errorf(\"refusing to delete built-in node pool %q\", poolName)\n}","typeGuard":null,"tryCatchPattern":"if err := client.NodePools().Delete(name, nil); err != nil {\n    if strings.Contains(err.Error(), \"is not allowed\") {\n        // built-in pool: treat as no-op / skip\n        return nil\n    }\n    return err\n}","preventionTips":["Always check pool.IsBuiltIn() (or compare against 'default'/'all') before deleting","In bulk-cleanup scripts, filter the node pool list first","Treat this error as expected control flow, not a retryable fault"],"tags":["nomad","state-store","node-pools","validation"],"backgroundTag":"builtin-resource-deletion-forbidden","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"}