hashicorp/nomad · error

volume %s is in nonexistent namespace %s

Error message

volume %s is in nonexistent namespace %s

What it means

During CSI volume registration, each volume's namespace is checked with namespaceExists. If the volume references a namespace that does not exist in the state store, registration is rejected with this error. It is a referential-integrity guard preventing volumes from being created in nonexistent namespaces.

Source

Thrown at nomad/state/state_store.go:2656

	if err != nil {
		return nil, fmt.Errorf("job_summary lookup failed: %v", err)
	}

	ws.Add(iter.WatchCh())

	return iter, nil
}

// UpsertCSIVolume inserts a volume in the state store.
func (s *StateStore) UpsertCSIVolume(index uint64, volumes []*structs.CSIVolume) error {
	txn := s.db.WriteTxnMsgT(structs.CSIVolumeRegisterRequestType, index)
	defer txn.Abort()

	for _, v := range volumes {
		if exists, err := s.namespaceExists(txn, v.Namespace); err != nil {
			return err
		} else if !exists {
			return fmt.Errorf("volume %s is in nonexistent namespace %s", v.ID, v.Namespace)
		}

		obj, err := txn.First(TableCSIVolumes, "id", v.Namespace, v.ID)
		if err != nil {
			return fmt.Errorf("volume existence check error: %v", err)
		}
		if obj != nil {
			// Allow some properties of a volume to be updated in place, but
			// prevent accidentally overwriting important properties.
			old := obj.(*structs.CSIVolume)
			if old.ExternalID != v.ExternalID ||
				old.PluginID != v.PluginID ||
				old.Provider != v.Provider {
				return fmt.Errorf("volume identity cannot be updated: %s", v.ID)
			}
		} else {
			v.CreateIndex = index
		}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Create the namespace first: nomad namespace create <name> or via the Namespaces API
  2. Verify the namespace field in the volume HCL matches an existing namespace (nomad namespace status)
  3. If running without ACLs, ensure you're not implicitly targeting a non-default namespace

Example fix

// before: volume.hcl references missing namespace
namespace = "team-a"
// after: create it first
// $ nomad namespace create team-a
namespace = "team-a"
Defensive patterns

Strategy: validation

Validate before calling

ns, _, err := client.Namespaces().Info(vol.Namespace, nil)
if err != nil {
  return fmt.Errorf("namespace %q does not exist: create it before registering volume", vol.Namespace)
}

Try / catch

_, err := client.CSIVolumes().Register(vol, nil, nil)
if err != nil && strings.Contains(err.Error(), "nonexistent namespace") {
  client.Namespaces().Register(&api.Namespace{Name: vol.Namespace}, nil)
  // then retry registration
}

Prevention

When it happens

Trigger: Calling CSIVolumeRegister (nomad volume register / CSI volume create) with a volume spec whose Namespace field names a namespace that hasn't been created.

Common situations: New Nomad setups where ACL namespaces were introduced but the target namespace was never created; copy-pasted HCL referencing the wrong or deleted namespace; default namespace assumptions after enabling namespaces.

Related errors


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