hashicorp/nomad · error
namespace %q using non-existent quota %q
Error message
namespace %q using non-existent quota %q
What it means
When upserting a namespace that references a Quota, the state store validates the quota spec exists. This error means the namespace's Quota field names a quota that has never been created (or was deleted), so the namespace write is rejected.
Source
Thrown at nomad/state/state_store.go:7098
if existing != nil {
exist := existing.(*structs.Namespace)
ns.CreateIndex = exist.CreateIndex
ns.ModifyIndex = index
// Grab the old quota on the namespace
oldQuota = exist.Quota
} else {
ns.CreateIndex = index
ns.ModifyIndex = index
}
// Validate that the quota on the new namespace exists
if ns.Quota != "" {
exists, err := s.quotaSpecExists(txn, ns.Quota)
if err != nil {
return fmt.Errorf("looking up namespace quota %q failed: %v", ns.Quota, err)
} else if !exists {
return fmt.Errorf("namespace %q using non-existent quota %q", ns.Name, ns.Quota)
}
}
// Insert the namespace
if err := txn.Insert(TableNamespaces, ns); err != nil {
return fmt.Errorf("namespace insert failed: %v", err)
}
// Reconcile changed quotas
return s.quotaReconcile(index, txn, ns.Quota, oldQuota)
}
// DeleteNamespaces is used to remove a set of namespaces
func (s *StateStore) DeleteNamespaces(index uint64, names []string) error {
txn := s.db.WriteTxn(index)
defer txn.Abort()
for _, name := range names {View on GitHub (pinned to 482b49bf1a)
Solutions
- Create the quota first: `nomad quota create <spec>` or apply the quota spec before the namespace
- Fix the namespace's quota name to match an existing quota spec
- If the quota should not apply, re-apply the namespace with -quota="" (empty)
- Reorder your IaC/apply steps so quota creation precedes namespace upsert
Example fix
// before nomad namespace apply -quota=team-a-quota team-a // quota missing // after nomad quota create quota-spec.hcl nomad namespace apply -quota=team-a-quota team-a
Defensive patterns
Strategy: validation
Validate before calling
q, _, err := client.Quotas().Info(ns.Quota, nil)
if err != nil || q == nil {
return fmt.Errorf("quota %q must exist before namespace %q is applied", ns.Quota, ns.Name)
} Type guard
func quotaExists(name string) bool { _, _, err := client.Quotas().Info(name, nil); return err == nil } Try / catch
_, _, err := client.Namespaces().Register(ns, nil)
if err != nil && strings.Contains(err.Error(), "non-existent quota") {
return fmt.Errorf("create the quota spec first or clear -quota on the namespace: %w", err)
} Prevention
- Apply quota specs before namespaces in IaC ordering
- Lint namespace definitions against the live quota list before apply
- Use empty Quota field when no quota is intended
When it happens
Trigger: `nomad namespace apply -quota=<name>` or Namespace.Upsert API where the quota spec does not exist in the state store (quotaSpecExists returns false).
Common situations: Typo in the quota name; quota deleted before the namespace referencing it is updated; namespace config applied to a region/cluster where the quota was never created; infrastructure-as-code ordering issue (namespace applied before quota).
Related errors
- invalid variables limit: %v
- volume validation failed: no such namespace %q
- mismatched request namespace in request: %q, %q
- must specify at least one namespace
- Invalid namespace %q: %v
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/0ccc7f147c2ed140.
Report an issue: GitHub.