{"record":{"id":"8a6433e619aba93e","repo":"hashicorp/nomad","slug":"no-such-consul-cluster-s","errorCode":null,"errorMessage":"no such consul cluster: %s","messagePattern":"no such consul cluster: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/allocrunner/consul_hook.go","lineNumber":143,"sourceCode":"\n\t// write the tokens to hookResources\n\tif err := h.resourcesBackend.setConsulTokens(tokens); err != nil {\n\t\th.logger.Error(\"unable to update tokens in state\", \"error\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (h *consulHook) prepareConsulTokensForTask(task *structs.Task, tg *structs.TaskGroup, tokens map[string]map[string]*consulapi.ACLToken) error {\n\tif task == nil {\n\t\t// programming error\n\t\treturn fmt.Errorf(\"cannot prepare consul tokens, no task specified\")\n\t}\n\n\tclusterName := task.GetConsulClusterName(tg)\n\tconsulConfig, ok := h.consulConfigs[clusterName]\n\tif !ok {\n\t\treturn fmt.Errorf(\"no such consul cluster: %s\", clusterName)\n\t}\n\n\t// Find task workload identity for Consul.\n\twidName := fmt.Sprintf(\"%s_%s\", structs.ConsulTaskIdentityNamePrefix, consulConfig.Name)\n\twid := task.GetIdentity(widName)\n\tif wid == nil {\n\t\t// Skip task if it doesn't have an identity for Consul since it doesn't\n\t\t// need a token.\n\t\treturn nil\n\t}\n\n\ttokenName := widName + \"/\" + task.Name\n\ttoken := tokens[clusterName][tokenName]\n\n\t// If no token was previously stored, create one.\n\tif token == nil {\n\t\t// Find signed workload identity.\n\t\tti := *task.IdentityHandle(wid)","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocrunner/consul_hook.go#L125-L161","documentation":"prepareConsulTokensForTask resolves the Consul cluster name for the task (via task.GetConsulClusterName(tg), driven by the consul.cluster config on the group/task) and looks it up in the client's h.consulConfigs map. If the resolved cluster name has no corresponding client Consul configuration, this error is returned. It means the allocation references a Consul cluster the Nomad client does not know about.","triggerScenarios":"A job sets consul.cluster (or the interpolated name resolves) to a cluster name absent from the agent's consul.blocks/consul configuration, then Prerun tries to derive a Consul workload-identity token for the task.","commonSituations":"Typo in the job's consul.cluster value; job written against a multi-cluster setup but the client agent lacks that cluster block; job submitted to clients running an older Nomad without Consul cluster support; client config changed/removed the cluster after the alloc was placed.","solutions":["Verify the consul.cluster value in the job matches a cluster name configured in the client agent's consul blocks","Run nomad node status / inspect the client config to confirm which Consul clusters the client knows","Update the client agent configuration to define the missing Consul cluster, then restart the nomad agent","Redeploy the job to a client whose configuration includes that cluster"],"exampleFix":"// before (job HCL)\nconsul { cluster = \"prod-east\" }\n// after (match client-configured cluster name)\nconsul { cluster = \"default\" }","handlingStrategy":"validation","validationCode":"clusterName := task.GetConsulClusterName(tg)\nif _, ok := clientConsulConfigs[clusterName]; !ok {\n    return fmt.Errorf(\"job references consul cluster %q not configured on client\", clusterName)\n}","typeGuard":null,"tryCatchPattern":"if err := hook.Prerun(); err != nil {\n    var missing *ConsulClusterError\n    if strings.Contains(err.Error(), \"no such consul cluster\") {\n        // reschedule after fixing client config\n    }\n}","preventionTips":["Keep job consul.cluster values in sync with every client agent's consul blocks","Use variable validation / template checks in job specs to pin cluster names","Pin jobs to node classes/datacenters where the required cluster is configured","Test job placement with nomad plan against clients running the target config"],"tags":["nomad","consul","config","multi-cluster"],"backgroundTag":"missing-cluster-configuration","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}