hashicorp/nomad · error

failed to computed node class: %v

Error message

failed to computed node class: %v

What it means

During Node.Register the server computes the node's computed node class (derived constraints/affinities from node attributes and drivers) via Node.ComputeClass. If that internal computation fails, registration is aborted with 'failed to computed node class: %v' wrapping the underlying cause. The node is not registered.

Source

Thrown at nomad/node_endpoint.go:162

		args.Node.SchedulingEligibility = structs.NodeSchedulingEligible
	}

	// Default the node pool if none is given.
	if args.Node.NodePool == "" {
		args.Node.NodePool = structs.NodePoolDefault
	}

	// The current time is used at a number of places in the registration
	// workflow. Generating it once avoids multiple calls to time.Now() and also
	// means the same time is used across all checks and sets.
	timeNow := time.Now()

	// Set the timestamp when the node is registered
	args.Node.StatusUpdatedAt = timeNow.Unix()

	// Compute the node class
	if err := args.Node.ComputeClass(); err != nil {
		return fmt.Errorf("failed to computed node class: %v", err)
	}

	// Look for the node so we can detect a state transition
	snap, err := n.srv.fsm.State().Snapshot()
	if err != nil {
		return err
	}

	ws := memdb.NewWatchSet()
	originalNode, err := snap.NodeByID(ws, args.Node.ID)
	if err != nil {
		return err
	}

	// If the node has an entry in the state store, we perform a check to ensure
	// the secret ID matches the one stored. If there is no entry, we perform a
	// check to ensure the node is allowed to register given the request and the
	// server introduction enforcement configuration.

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Read the wrapped %v cause in the server error/log for the real failure.
  2. Fix the node's attributes/meta on the client (client.meta, plugin settings) so ComputeClass can evaluate them.
  3. Align client and server Nomad versions and restart the agent to resend a clean node payload.
  4. If it persists on an up-to-date agent, file a Nomad issue with the wrapped error — ComputeClass should not fail on well-formed input.

Example fix

// before (client config with problematic meta)
client { meta { tags = "${bad-expression" } }
// after
client { meta { tags = "prod,web" } }
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure node fields sent by custom clients are well-formed before registering
if n.Attributes == nil || n.Datacenter == "" || n.Name == "" {
    return fmt.Errorf("node payload incomplete; refusing to register")
}

Try / catch

_, err := client.Nodes().Register(node, nil)
if err != nil && strings.Contains(err.Error(), "failed to computed node class") {
    // inspect wrapped cause in server logs; fix node meta/attributes and re-register
}

Prevention

When it happens

Trigger: Registering a node whose attributes/meta cause ComputeClass to fail — e.g. malformed meta values or attribute data the evaluation logic cannot process; a corrupt or hand-crafted node payload.

Common situations: Custom clients sending malformed Node fields; Nomad version mismatches where the server cannot evaluate client-provided data; agent misconfiguration producing unparseable attributes/meta.

Related errors


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