Skip to content

Consul service tokens derived from WI fail binding if service name is not all lowercase #25704

Open
@jinnatar

Description

@jinnatar

Nomad version

Nomad v1.9.7
BuildDate 2025-03-11T09:07:15Z
Revision f869597+CHANGES
(attempting to move to v1.10.0 but blocked by this issue)

Operating system and Environment details

Debian 12, native deb install of CE nomad & consul.

Issue

Following the WI for Consul tutorial I can successfully start jobs using the created example service type binding. However, if I change the service name to contain non-lowercase characters the binding does not allow write access to the capitalized service. Ergo, I'm inferring that somewhere along the way either Nomad or Consul implicitly lowercases the ${value.nomad_service} value.

Reproduction steps

  1. Follow the Consul ACL integration tutorial: https://developer.hashicorp.com/nomad/tutorials/integrate-consul/consul-acl
  2. Submit a working job as per the job file listed further down.
  3. Modify the service.name value to Identity-demo-dev. This causes the following plan diff for the Identity block, ServiceName correctly does not get lowercased here:
+/- Name:         "consul-service_identity-demo-dev-http" => "consul-service_Identity-demo-dev-http"
+/- ServiceName:  "identity-demo-dev" => "Identity-demo-dev"
  1. and purge & re-run the job.

Expected Result

Service is registered.

Actual Result

As per Consul logs:

[ERROR] agent.http: Request error: method=PUT url=/v1/agent/service/register from=127.0.0.1:42364 error="Permission denied: token with AccessorID '0bc001cb-7579-a334-c525-50519011f082' lacks permission 'service:write' on \"Identity-demo-dev\"""

If the job was purged before running the changed version the deployment fails due to service registration failing. If a purge is not done and it's an update, the service registration still fails but the task remains "healthy" and all seems fine from Nomad, but it sure ain't actually there in Consul.

Job file (if appropriate)

job "identity_demo" {
  group "httpd_group" {
    count = 1

    network {
      port "http" {}
    }

    service {
      name     = "identity-demo-dev"
      port     = "http"
      identity {
        aud = ["consul.io"]
        ttl = "1h"
      }
    }

    task "httpd_task" {
      driver = "docker"

      config {
        image   = "busybox:1.36"
        command = "httpd"
        args    = ["-f", "-p", "${NOMAD_PORT_http}"]
        ports   = ["http"]
      }

      identity {
        name = "consul_default"
        aud  = ["consul.io"]
        ttl  = "1h"
      }
    }
  }
}

Nomad Server logs (if appropriate)

Nomad Client logs (if appropriate)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Needs Roadmapping

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions