hashicorp/nomad · error

node pool %q has non-terminal jobs in regions: %v

Error message

node pool %q has non-terminal jobs in regions: %v

What it means

DeleteNodePools refuses to delete a node pool that still has non-terminal (running/pending) jobs in any region. The endpoint checks via nodePoolRegionsInUse and reports which regions block the deletion, appended to a multierror.

Source

Thrown at nomad/node_pool_endpoint.go:280

	// Validate request.
	if len(args.Names) == 0 {
		return structs.NewErrRPCCodedf(http.StatusBadRequest, "must specify at least one node pool to delete")
	}
	if slices.Contains(args.Names, "") {
		return structs.NewErrRPCCodedf(http.StatusBadRequest, "node pool name is empty")
	}

	// Verify that the node pools we're deleting do not have nodes or
	// non-terminal jobs in this region or in any federated region.
	var mErr multierror.Error
	for _, name := range args.Names {
		regionsWithNonTerminal, regionsWithNodes, err := n.nodePoolRegionsInUse(args.AuthToken, name)
		if err != nil {
			_ = multierror.Append(&mErr, err)
		}
		if len(regionsWithNonTerminal) != 0 {
			_ = multierror.Append(&mErr, fmt.Errorf(
				"node pool %q has non-terminal jobs in regions: %v", name, regionsWithNonTerminal))
		}
		if len(regionsWithNodes) != 0 {
			_ = multierror.Append(&mErr, fmt.Errorf(
				"node pool %q has nodes in regions: %v", name, regionsWithNodes))
		}
	}

	if err := mErr.ErrorOrNil(); err != nil {
		return err
	}

	// Delete via Raft.
	_, index, err := n.srv.raftApply(structs.NodePoolDeleteRequestType, args)
	if err != nil {
		return err
	}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. List and stop/purge all jobs in the pool: `nomad job list` / `nomad job stop -purge <job>` in each listed region
  2. Re-run the delete once all jobs in the pool are terminal (dead/complete)
  3. If jobs are orphaned, force-purge them via the API with the correct region
  4. Move jobs to another node pool before deleting the pool

Example fix

// before
$ nomad node pool delete prod
Error: node pool "prod" has non-terminal jobs in regions: [us-east]
// after
$ nomad job stop -purge -region us-east webapp
$ nomad node pool delete prod
Defensive patterns

Strategy: validation

Validate before calling

jobs, _ := client.Jobs().List(nil)
for _, j := range jobs {
    if *j.NodePool == poolName && j.Status != "dead" && j.Status != "complete" {
        return fmt.Errorf("job %s still non-terminal in pool %s", j.ID, poolName)
    }
}

Try / catch

err := client.NodePools().Delete([]string{poolName}, wr)
if err != nil && strings.Contains(err.Error(), "non-terminal jobs") {
    // stop/purge listed jobs, then retry
}

Prevention

When it happens

Trigger: `nomad node pool delete <pool>` or DELETE /v1/node/pools where jobs assigned to the pool are still in pending or running state in one or more regions (enterprise multi-region setups).

Common situations: Operators cleaning up pools without first stopping/purging the jobs running in them; multi-region deployments where a job in a remote region is easily overlooked.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/2a481c27ec78b6b0. Report an issue: GitHub.