Commit Graph

85 Commits

Author SHA1 Message Date
Seth Hoenig
0957c24646 docs: remove erroneous characters from comment 2020-03-30 13:26:48 -06:00
Seth Hoenig
7a7701a4eb consul: annotate Consul interfaces with ACLs 2020-03-30 10:17:28 -06:00
Seth Hoenig
d24d470775 comments: cleanup some leftover debug comments and such 2020-01-31 19:04:35 -06:00
Seth Hoenig
674ccaa122 nomad: proxy requests for Service Identity tokens between Clients and Consul
Nomad jobs may be configured with a TaskGroup which contains a Service
definition that is Consul Connect enabled. These service definitions end
up establishing a Consul Connect Proxy Task (e.g. envoy, by default). In
the case where Consul ACLs are enabled, a Service Identity token is required
for these tasks to run & connect, etc. This changeset enables the Nomad Server
to recieve RPC requests for the derivation of SI tokens on behalf of instances
of Consul Connect using Tasks. Those tokens are then relayed back to the
requesting Client, which then injects the tokens in the secrets directory of
the Task.
2020-01-31 19:03:53 -06:00
Seth Hoenig
f8666bb1f9 client: enable nomad client to request and set SI tokens for tasks
When a job is configured with Consul Connect aware tasks (i.e. sidecar),
the Nomad Client should be able to request from Consul (through Nomad Server)
Service Identity tokens specific to those tasks.
2020-01-31 19:03:38 -06:00
Drew Bailey
3b033b2ef5 allow only positive shutdown delay
more explicit test case, remove select statement
2019-12-16 11:38:30 -05:00
Nick Ethier
387b016ac4 client: improve group service stanza interpolation and check_re… (#6586)
* client: improve group service stanza interpolation and check_restart support

Interpolation can now be done on group service stanzas. Note that some task runtime specific information
that was previously available when the service was registered poststart of a task is no longer available.

The check_restart stanza for checks defined on group services will now properly restart the allocation upon
check failures if configured.
2019-11-18 13:04:01 -05:00
Tim Gross
40368d2c63 support script checks for task group services (#6197)
In Nomad prior to Consul Connect, all Consul checks work the same
except for Script checks. Because the Task being checked is running in
its own container namespaces, the check is executed by Nomad in the
Task's context. If the Script check passes, Nomad uses the TTL check
feature of Consul to update the check status. This means in order to
run a Script check, we need to know what Task to execute it in.

To support Consul Connect, we need Group Services, and these need to
be registered in Consul along with their checks. We could push the
Service down into the Task, but this doesn't work if someone wants to
associate a service with a task's ports, but do script checks in
another task in the allocation.

Because Nomad is handling the Script check and not Consul anyways,
this moves the script check handling into the task runner so that the
task runner can own the script check's configuration and
lifecycle. This will allow us to pass the group service check
configuration down into a task without associating the service itself
with the task.

When tasks are checked for script checks, we walk back through their
task group to see if there are script checks associated with the
task. If so, we'll spin off script check tasklets for them. The
group-level service and any restart behaviors it needs are entirely
encapsulated within the group service hook.
2019-09-03 15:09:04 -04:00
Michael Schurter
eeacb87f3b connect: register group services with Consul
Fixes #6042

Add new task group service hook for registering group services like
Connect-enabled services.

Does not yet support checks.
2019-08-20 12:25:10 -07:00
Michael Schurter
df0a6dc34e test: add some extra logging 2019-01-14 09:56:53 -08:00
Michael Schurter
796f0ca063 fix build errors post merges 2018-10-16 16:53:31 -07:00
Michael Schurter
d0842e7b00 test: cleanup mock consul service client
Updated to hclog.

It exposed fields that required an unexported lock to access. Created a
getter methodn instead. Only old allocrunner currently used this
feature.
2018-10-16 16:53:31 -07:00
Alex Dadgar
40d095fd1a agent + consul 2018-09-13 10:43:40 -07:00
Alex Dadgar
a62e412b88 Refactor - wip 2018-06-12 10:23:45 -07:00
Sean Chittenden
57c2c819e8 Move package client/consul/sync to command/agent/consul.
This has been done to allow the Server and Client to reuse the same
Syncer because the Agent may be running Client, Server, or both
simultaneously and we only want one Syncer object alive in the agent.
2016-06-10 15:54:39 -04:00
Sean Chittenden
e858928d68 Rename Syncer.SetServiceIdentifier to SetServiceRegPrefix()
This attribute isn't actually an identifier because it can represent
a collection of services.  Rename `serviceIdentifier` to
`serviceRegPrefix which more accurately conveys the intention of this
Syncer attribute.

While here, also rename `SetServiceIdentifier()` to `SetServiceRegPrefix()`
and `GenerateServiceIdentifier()` to `GenerateServicePrefix()`.
2016-06-10 15:54:39 -04:00
Sean Chittenden
74e691cab1 Change the API signature of Syncer.SyncServices().
SyncServices() immediately attempts to sync whatever information
the process has with Consul.  Previously this method would take an
argument of the exclusive list of services that should exist,
however this is not condusive to having a Nomad Client and Nomad
Server share the same consul.Syncer.
2016-06-10 15:54:39 -04:00
Sean Chittenden
cf8beb7ba9 Change the signature of the PeriodicCallback to return an error
I *KNEW* I should have done this when I wrote it, but didn't want to
go back and audit the handlers to include the appropriate return
handling, but now that the code is taking shape, make this change.
2016-06-10 15:54:39 -04:00
Sean Chittenden
a2081159b4 Rename structs.Services to structs.ConsulServices 2016-06-10 15:54:39 -04:00
Sean Chittenden
107fc1bb81 Rename createCheck() to createDelegatedCheck() for clarity 2016-06-10 15:54:39 -04:00
Sean Chittenden
1352f7f0e6 Change client/consul.NewSyncer() to accept a shutdown channel
In addition to the API changing, consul.Syncer can now be signaled
to shutdown via the Shutdown() method, which will call the Run()'ing
sync task to exit gracefully.
2016-06-10 15:54:39 -04:00
Sean Chittenden
86b5d318f8 Move const block to the top of the file.
Requested by: @dadgar
2016-06-10 15:50:11 -04:00
Sean Chittenden
07799b636a Nuke the last of the explicit types in favor of using language idioms 2016-06-10 15:50:11 -04:00
Sean Chittenden
6264a8eff6 Unused code wasn't as unused as I thought. Restore. 2016-06-10 15:50:11 -04:00
Sean Chittenden
b2357598ba Register the serf service with the Nomad server service.
This will be unused in this PR.
2016-06-10 15:50:11 -04:00
Sean Chittenden
bf4f0310b4 Remove unused function. 2016-06-10 15:50:11 -04:00
Sean Chittenden
3d22c22bf5 Remove types.ShutdownChannel and replace with chan struct{} 2016-06-10 15:50:11 -04:00
Sean Chittenden
4d47eedd58 Teach Client to reuse an Agent's consulSyncer.
"There can be only one."
2016-06-10 15:50:11 -04:00
Sean Chittenden
bc86e897ed Register two services each for clients and servers, http and rpc.
In order to give clients a fighting chance to talk to the right port,
differentiate RPC services from HTTP services by registering two
services with different tags.  This yields
`rpc.nomad-server.service.consul` and
`http.nomad-server.service.consul` which is immensely more useful to
clients attempting to bootstrap their world.
2016-06-10 15:50:11 -04:00
Sean Chittenden
fc5658521c index on f-dyn-server-list: bd38cb4 Remove unused code 2016-06-10 15:50:11 -04:00
Sean Chittenden
17927c8b9c Only poll Consul for servers when Nomad heartbeats begin to fail
When a deadline timer of 2x Server's last requested TTL expires,
begin polling Consul for Nomad Servers.
2016-06-10 15:50:11 -04:00
Sean Chittenden
e07e77b79d s/availble/runChecks/g 2016-06-10 15:50:11 -04:00
Sean Chittenden
d268dcb85d Reduce all forms of ConsulConfig down to a single struct
nomad/structs/config/consul.go's ConsulConfig is the canonical definition
for all things Consul now.
2016-06-10 15:50:11 -04:00
Sean Chittenden
f6e3587321 Define a type for the PeriodicCallback handlers and ShutdownChannel 2016-06-10 15:50:11 -04:00
Sean Chittenden
ffcd2332d4 Rebalance Nomad client RPCs among different Nomad servers.
Implement client/rpc_proxy.RpcProxy.
2016-06-10 15:50:11 -04:00
Sean Chittenden
7c6ad53d89 Rename NewConsulService to NewSyncer 2016-06-10 15:49:37 -04:00
Sean Chittenden
f280c59633 Rename client/consul/sync.PeriodicSync to Run 2016-06-10 15:49:37 -04:00
Sean Chittenden
d84d71847c Rename client/consul/sync.ConsulService to client/consul/sync.Syncer
Syncer describes the responsibility and actions of the type.
2016-06-10 15:49:37 -04:00
Sean Chittenden
0e1bdad2a0 Rename consul.ConsulConfig to consul.AgentConfig
There were two `ConsulConfig` structs running around, one of them
needed to go away.  Rely on the package's path to provide context
for the type of AgentConfig.
2016-06-10 15:48:36 -04:00
Sean Chittenden
7db2eb03c4 Use consul/lib's RandomStagger
Removes four redundant copies of the method in the process.
2016-06-10 15:48:36 -04:00
Diptanu Choudhury
522eebcbc1 Using a helper method to create service identifiers 2016-05-14 00:43:25 -07:00
Diptanu Choudhury
8c5aa0fe65 Added some docs 2016-05-14 00:36:26 -07:00
Diptanu Choudhury
b2c18168a4 Making Nomad register services with consul in dev mode 2016-05-13 10:19:49 -07:00
Diptanu Choudhury
de660c4acf Removed allocID and task name from consul service 2016-05-11 16:26:41 -07:00
Diptanu Choudhury
50b03354f2 Fixed the consul tests 2016-05-11 15:22:58 -07:00
Diptanu Choudhury
2663ef9d6a Refactored the signature of NewConsulService 2016-05-11 15:22:58 -07:00
Diptanu Choudhury
2a4431b09b Added some docs 2016-05-05 11:52:22 -07:00
Diptanu Choudhury
03763d570b Added logs to indicate when checks timeout 2016-05-05 10:01:38 -07:00
Diptanu Choudhury
1b8e663af7 Allowing registration of services which don't expose any ports 2016-04-14 13:26:39 +05:30
Diptanu Choudhury
7555c2e705 Setting check state to critical if check result had an error 2016-04-05 10:15:38 -07:00