hashicorp/nomad · error

no such volume: %s

Error message

no such volume: %s

What it means

After a successful lookup, HostVolume.Delete checks whether the volume exists in the namespace; a nil result means there is nothing to delete, so it returns 'no such volume: <id>'. This is the expected error when the ID/namespace pair doesn't match any registered host volume.

Source

Thrown at nomad/host_volume_endpoint.go:699

	if args.VolumeID == "" {
		return fmt.Errorf("missing volume ID to delete")
	}

	snap, err := v.srv.State().Snapshot()
	if err != nil {
		return err
	}

	ns := args.RequestNamespace()
	id := args.VolumeID

	vol, err := snap.HostVolumeByID(nil, ns, id, true)
	if err != nil {
		return fmt.Errorf("could not query host volume: %w", err)
	}
	if vol == nil {
		return fmt.Errorf("no such volume: %s", id)
	}
	if len(vol.Allocations) > 0 {
		allocIDs := helper.ConvertSlice(vol.Allocations,
			func(a *structs.AllocListStub) string { return a.ID })
		return fmt.Errorf("volume %s in use by allocations: %v", id, allocIDs)
	}

	// serialize client RPC and raft write per volume ID
	index, err := v.serializeCall(vol.ID, "delete", func() (uint64, error) {
		if err := v.deleteVolume(vol); err != nil {
			if structs.IsErrUnknownNode(err) || structs.IsErrNoNodeConn(err) {
				if !args.Force {
					return 0, fmt.Errorf(
						"volume cannot be removed from unknown node without force=true")
				}
			} else {
				return 0, err
			}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Verify the volume exists: `nomad host volume status <id> -namespace <ns>` and confirm the exact ID and namespace.
  2. Correct the -namespace flag to the volume's actual namespace.
  3. Make deletion idempotent in automation — treat 'no such volume' as already-deleted success.

Example fix

// before
err := delete(ns="prod", id) // volume lives in "default"
// after
err := delete(ns="default", id)
// or idempotent:
if err != nil && strings.Contains(err.Error(), "no such volume") { err = nil }
Defensive patterns

Strategy: validation

Validate before calling

vol, _, err := client.HostVolumes().Info(id, nil, nil)
if err != nil || vol == nil {
    return fmt.Errorf("volume %s not found in namespace %q; skip delete", id, ns)
}

Try / catch

err := client.HostVolumes().Delete(ns, id, nil)
if err != nil && strings.Contains(err.Error(), "no such volume") {
    log.Printf("volume %s already deleted; treating as success", id)
    err = nil // idempotent delete
}

Prevention

When it happens

Trigger: Deleting with a volume ID that doesn't exist, using the wrong -namespace, deleting an already-deleted volume, or passing a volume name where an ID is required.

Common situations: Typo'd or truncated ID; volume created in a different namespace; double-delete in automation races; switching clusters/regions where the volume doesn't exist.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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