Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of WI: ensure Consul hook and WID manager interpolate services into release/1.7.x #20363

Conversation

hc-github-team-nomad-core
Copy link
Contributor

Backport

This PR is auto-generated from #20344 to be assessed for backporting due to the inclusion of the label backport/1.7.x.

The below text is copied from the body of the original PR.


Services can have some of their string fields interpolated. The new Workload Identity flow doesn't interpolate the services before requesting signed identities or using those identities to get Consul tokens.

Add support for interpolation to the WID manager and the Consul tokens hook by providing both with a taskenv builder. Add an "interpolate workload" field to the WI handle to allow passing the original workload name to the server so the server can find the correct service to sign.

This changeset also makes two related test improvements:

  • Remove the mock WID manager, which was only used in the Consul hook tests and isn't necessary so long as we provide the real WID manager with the mock signer and never call Run on it. It wasn't feasible to exercise the correct behavior without this refactor, as the mocks were bypassing the new code.
  • Fixed swapped expect-vs-actual assertions on the consul_hook tests.

Fixes: #20025


Smoke tested with the following jobspec:

jobspec
job "example" {

  group "web" {

    network {
      mode = "bridge"
      port "metrics" {
        to = 9000
      }
      port "www" {
        to = 8001
      }
    }

    service {
      name = "${NOMAD_GROUP_NAME}"
      port = "metrics"
    }

    task "http" {

      driver = "docker"

      service {
        name = "${NOMAD_TASK_NAME}"
        port = "www"
      }

      config {
        image   = "busybox:1"
        command = "httpd"
        args    = ["-vv", "-f", "-p", "8001", "-h", "/local"]
        ports   = ["www"]
      }

      resources {
        cpu    = 100
        memory = 100
      }

    }
  }
}

success


Overview of commits

@hc-github-team-nomad-core hc-github-team-nomad-core force-pushed the backport/b-consul-hook-interpolation/literally-active-ram branch from 652b098 to dd30133 Compare April 11, 2024 19:40
@vercel vercel bot temporarily deployed to Preview – nomad April 11, 2024 19:46 Inactive
Services can have some of their string fields interpolated. The new Workload
Identity flow doesn't interpolate the services before requesting signed
identities or using those identities to get Consul tokens.

Add support for interpolation to the WID manager and the Consul tokens hook by
providing both with a taskenv builder. Add an "interpolate workload" field to
the WI handle to allow passing the original workload name to the server so the
server can find the correct service to sign.

This changeset also makes two related test improvements:
* Remove the mock WID manager, which was only used in the Consul hook tests and
  isn't necessary so long as we provide the real WID manager with the mock
  signer and never call `Run` on it. It wasn't feasible to exercise the correct
  behavior without this refactor, as the mocks were bypassing the new code.
* Fixed swapped expect-vs-actual assertions on the `consul_hook` tests.

Fixes: #20025
@tgross tgross force-pushed the backport/b-consul-hook-interpolation/literally-active-ram branch from dd30133 to 3ee405d Compare April 11, 2024 19:46
@tgross tgross merged commit 951251a into release/1.7.x Apr 11, 2024
19 checks passed
@tgross tgross deleted the backport/b-consul-hook-interpolation/literally-active-ram branch April 11, 2024 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants