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

client: add Nomad template service functionality to runner. #12458

Merged
merged 4 commits into from
Apr 6, 2022

Conversation

jrasell
Copy link
Member

@jrasell jrasell commented Apr 5, 2022

This change modifies the template task runner to utilise the
new consul-template which includes Nomad service lookup template
funcs.

In order to provide security and auth to consul-template, we use
a custom HTTP dialer which is passed to consul-template when
setting up the runner. This method follows Vault implementation.

This PR also includes an E2E test in lieu of integration tests. This
is due to the taskrunner/template pkg being in a long import chain
making utilising current test agents/clients impossible without a
large refactor. We will therefore step back and address this
properly in the future.

This change modifies the template task runner to utilise the
new consul-template which includes Nomad service lookup template
funcs.

In order to provide security and auth to consul-template, we use
a custom HTTP dialer which is passed to consul-template when
setting up the runner. This method follows Vault implementation.
@jrasell jrasell added this to the 1.3.0 milestone Apr 5, 2022
@jrasell jrasell requested a review from schmichael April 5, 2022 16:42
@jrasell jrasell self-assigned this Apr 5, 2022
schmichael added a commit to hashicorp/consul-template that referenced this pull request Apr 6, 2022
Adds 2 functions for retrieving services from Nomad:

- nomadServices - retrieves all services from Nomad
- nomadService - retrieves all registrations for a service

Tag filtering for `nomadService` is currently implemented in
consul-template as the Nomad API does not support it directly.

Tests use a Nomad binary on path and require Nomad 1.3.0-beta or a
binary built from the PR: hashicorp/nomad#12458

Tests also require Docker.
Copy link
Member

@schmichael schmichael left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 No functional changes, so feel free to merge as-is if we just want to clean up comments after the fact.

Comment on lines +916 to +921
// Set up a custom listener and dialer. This is used by Nomad clients when
// running consul-template functions that utilise the Nomad API. We lazy
// load this into the client config, therefore this needs to happen before
// we call NewClient.
a.builtinListener, a.builtinDialer = bufconndialer.New()
conf.TemplateDialer = a.builtinDialer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great placement 👍

command/agent/http.go Outdated Show resolved Hide resolved
@@ -0,0 +1,48 @@
// BufConnWrapper implements consul-template's TransportDialer using a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, no tests. I'll try to get to that later today. #12483

@vercel vercel bot temporarily deployed to Preview – nomad April 6, 2022 16:58 Inactive
@jrasell jrasell merged commit 9dc0b88 into main Apr 6, 2022
@jrasell jrasell deleted the f-gh-268-dialer branch April 6, 2022 17:17
schmichael added a commit to hashicorp/consul-template that referenced this pull request Apr 7, 2022
Adds 2 functions for retrieving services from Nomad:

- nomadServices - retrieves all services from Nomad
- nomadService - retrieves all registrations for a service

Tag filtering for `nomadService` is currently implemented in
consul-template as the Nomad API does not support it directly.

Tests use a Nomad binary on path and require Nomad 1.3.0-beta or a
binary built from the PR: hashicorp/nomad#12458

Tests also require Docker.
schmichael added a commit to hashicorp/consul-template that referenced this pull request Apr 8, 2022
Adds 2 functions for retrieving services from Nomad:

- nomadServices - retrieves all services from Nomad
- nomadService - retrieves all registrations for a service

Tag filtering for `nomadService` is currently implemented in
consul-template as the Nomad API does not support it directly.

Tests use a Nomad binary on path and require Nomad 1.3.0-beta or a
binary built from the PR: hashicorp/nomad#12458

Tests also require Docker.
schmichael added a commit to hashicorp/consul-template that referenced this pull request Apr 12, 2022
Adds 2 functions for retrieving services from Nomad:

- nomadServices - retrieves all services from Nomad
- nomadService - retrieves all registrations for a service

Tag filtering for `nomadService` is currently implemented in
consul-template as the Nomad API does not support it directly.

Tests use a Nomad binary on path and require Nomad 1.3.0-beta or a
binary built from the PR: hashicorp/nomad#12458

Tests also require Docker.
@github-actions
Copy link

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 Oct 22, 2022
This pull request was closed.
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.

2 participants