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

Add 'nomad.advertise.address' to client meta via NomadFingerPrint #4390

Merged
merged 3 commits into from
Jun 20, 2018

Conversation

jrasell
Copy link
Member

@jrasell jrasell commented Jun 7, 2018

This commit adds the Nomad local client advertise address in the form host:port to the client attributes. This is helpful in situation where the task is making Nomad API calls as the current alternative is to use hardcoded IPs, DNS LB names or create dummy ports and use the env vars resulting from this.

Once this is merged, I will raise a PR for doc updates to reflect the change.

Tested locally with job:

driver = "raw_exec"
      config {
        command = "echo"
        args = ["${attr.nomad.advertise.address}"]
      }

Result:

$ nomad logs 1e4148e2
127.0.0.1:4646

Nomad status output

$ nomad node status -verbose 0817b9ac |grep 'nomad.advertise.address'
nomad.advertise.address       = 127.0.0.1:4646

Tests pass locally:

$ /usr/local/bin/go test -timeout 30s github.com/hashicorp/nomad/client/fingerprint -run ^TestNomadFingerprint$

ok  	github.com/hashicorp/nomad/client/fingerprint
Success: Tests passed.

Closes #4381

This commit adds the Nomad local client advertise address in the
form host:port to the environment variables passed to each task.
@dadgar
Copy link
Contributor

dadgar commented Jun 7, 2018

@jrasell I would be more a fan of adding it to the client's meta via the nomad_fingerprinter and then tasks that need it can add it. Want to avoid infinite number of builtin env vars being exported.

@jrasell
Copy link
Member Author

jrasell commented Jun 7, 2018

@dadgar makes perfect sense; i'll work on updating to make the change in that manner.

This change removes the addition of the advertise address to the
exported task env vars and instead moves this work into the
NomadFingerprint.Fingerprint which adds this value to the client
attrs. This can then be used within a Nomad job like
${attr.nomad.advertise.address}.
@jrasell jrasell changed the title Add the local clients advertise address to interpolation env vars Add 'nomad.advertise.address' to client meta via NomadFingerPrint Jun 8, 2018
@jrasell
Copy link
Member Author

jrasell commented Jun 8, 2018

@dadgar updated as per your advice

@preetapan
Copy link
Member

@jrasell the most recent update looks good but there is a merge conflict, could you rebase your branch against master?

@jrasell
Copy link
Member Author

jrasell commented Jun 19, 2018

@preetapan merge conflict has been resolved

@preetapan preetapan merged commit 3ed221b into hashicorp:master Jun 20, 2018
@github-actions
Copy link

github-actions bot commented Mar 2, 2023

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants