Commit Graph

4242 Commits

Author SHA1 Message Date
Sean Chittenden
d87c697c87 Update Syncer.Run() to call SyncServices(). 2016-06-10 15:54:39 -04:00
Sean Chittenden
8be79cf28c Add "Service Groups" to the Syncer.
Now the right way to register services with the Syncer is to call
`SetServices(groupName, []*services)`.  This was required to allow
the Syncer to sync either the Client, Server, or Both using a
single Syncer.
2016-06-10 15:54:39 -04:00
Sean Chittenden
a4f605a789 Initialize Consul for the Nomad Agent in a more uniform way.
Decompose Client and Server registration into `setupClient()` and
`setupServer()`, respectively.
2016-06-10 15:54:39 -04:00
Sean Chittenden
3e95ca61ef Per-comment, remove structs.Allocation's Services attribute.
Nuke PopulateServiceIDs() now that it's also no longer needed.
2016-06-10 15:54:39 -04:00
Sean Chittenden
802a8c459c Rename command/agent/consul/sync.go to syncer.go 2016-06-10 15:54:39 -04:00
Sean Chittenden
7ad5cd571c Begin leveraging the Agent-level consul.Syncer 2016-06-10 15:54:39 -04:00
Sean Chittenden
3052e7477a Move the start of the UniversalExecutor's consulSyncer to initialize once
This should be handled via a sync.Once primative, but I don't want to
unpack that atm.
2016-06-10 15:54:39 -04:00
Sean Chittenden
54838b9eba Rename structs.Task's Service attribute to ConsulService 2016-06-10 15:54:39 -04:00
Sean Chittenden
b6a2ec2db8 Remove Syncer.registerService()
This call is obsolete by a future commit that changes the canonical
source of truth to be consul.AgentServiceRegistration structs, which
means it is not necessary to construct AgentServiceRegistration
objects every time a registration is made, we just reuse the existing
object.
2016-06-10 15:54:39 -04: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
acb3d58b82 Refine Nomad's Consul port handling.
Previously this would immediately default to '127.0.0.1' if the
config was set to `:some-port-number`.  Now it uses the BindAddr
if available.  Also, if the `port` option is set to just a port`
number (e.g. '1234'), attempt to parse the port number by itself
to allow statically configured ports to work, even when no host is
specified.
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
4e03dc5fbc Remove named return parameters 2016-06-10 15:50:11 -04:00
Sean Chittenden
68f7afcd23 Collapse server_endpoint_internal_test.go into server_endpoint_test.go
Requested by: @dadgar
2016-06-10 15:50:11 -04:00
Sean Chittenden
273e8cf3c9 Collapse rpcproxy_internal_test.go into rpcproxy_test.go
Requested by: @dadgar
2016-06-10 15:50:11 -04:00
Sean Chittenden
bbf7348abc Bump the default Consul client timeout from 500ms to 5s.
Requsted by: @dadgar
2016-06-10 15:50:11 -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
998f285be0 Ensure that all accesses to Client.alloc are wrapped by allocLock. 2016-06-10 15:50:11 -04:00
Sean Chittenden
8bbd763740 Use client.getAllocRunners() where appropriate. 2016-06-10 15:50:11 -04:00
Sean Chittenden
cf052e5f29 Line wrap long line. 2016-06-10 15:50:11 -04:00
Sean Chittenden
1ec537450e Rename rpcproxy.UpdateFromNodeUpdateResponse to RefreshServerLists
While breaking the API within this PR, break out the individual
arguments to RefreshServerLists.  The servers parameter is reusing
`structs.NodeServerInfo` for the time being, but this can be revisited
if the needs of the strucutre diverge in the future.
2016-06-10 15:50:11 -04:00
Sean Chittenden
f0c6b70911 Fix up the comments
Pointed out by: @dadgar
2016-06-10 15:50:11 -04:00
Sean Chittenden
8d478b96f7 Make the locking protocol more explicit in client.NewClient
With an over abundance of caution, preevnt future copy/pasta by
using the right locks when bootstrapping a Client.  Strictly speaking
this is not necessary, but it makes explicit the locking semantics
and guards against future concurrent or parallel initialization.
2016-06-10 15:50:11 -04:00
Sean Chittenden
8dd833f9a8 Use the client configCopy and lock appropriately. 2016-06-10 15:50:11 -04:00
Sean Chittenden
c8b2f7ce33 Flesh out the comment re: the client.rpcproxy.Run() task.
Requested by: Alex
2016-06-10 15:50:11 -04:00
Sean Chittenden
9de963497b Clean up various comments 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
73c15603a9 Rename backupServerDeadline to consulPullHeartbeatDeadline
Suggested by: @alex
2016-06-10 15:50:11 -04:00
Sean Chittenden
f15d84e5e7 Use a monotonically incrementing number to create unique node names.
Also remove the space from the "name" of the node
2016-06-10 15:50:11 -04:00
Sean Chittenden
7538667837 Push down the server list even on node registration and evaluation
Be mindful of the cost of taking a snapshot from the statestore and
reuse the snapshot if one has already been taken.
2016-06-10 15:50:11 -04:00
Sean Chittenden
66dc946852 Don't clobber the default consul config in tests 2016-06-10 15:50:11 -04:00
Sean Chittenden
ab434b4079 Fix typo in comment 2016-06-10 15:50:11 -04:00
Sean Chittenden
4300cb31d9 Remove unused variable 2016-06-10 15:50:11 -04:00
Sean Chittenden
41904f262f Clean up some docs and comments to be more accurate 2016-06-10 15:50:11 -04:00
Sean Chittenden
445386bb3f Remove unused constants 2016-06-10 15:50:11 -04:00
Sean Chittenden
503c6a996f Fix test TestClientConfigCommand_UpdateServers()
Now that hostnames are validated on input, switch to IPs since they
bypass DNS resolution.
2016-06-10 15:50:11 -04:00
Sean Chittenden
329057e22b Only actively test Consul when env CONSUL_HTTP_ADDR is set 2016-06-10 15:50:11 -04:00
Sean Chittenden
f9862d4043 Update godoc for newServer to reflect DNS and IP-based inputs
Requested by: alex
2016-06-10 15:50:11 -04:00
Sean Chittenden
453a7556b6 Pick the right DefaultConfig from the right package.
Overly zealous search && replace at work here.
2016-06-10 15:50:11 -04:00
Sean Chittenden
6908846086 Add a quick set of client/rpcproxy.ServerEndpoint equality tests 2016-06-10 15:50:11 -04:00
Sean Chittenden
ac174dbb6b Fix building tests that used DefaultConfig() but didn't pickup the package move. 2016-06-10 15:50:11 -04:00
Sean Chittenden
f03765814e Add some trace-level logging for /v1/agent/servers when writing
This endpoint shouldn't be hit often, but this could be useful in
logs down the road.
2016-06-10 15:50:11 -04:00
Sean Chittenden
37e7038a27 Fix config_parse_test to reflect that consul.addr does not exist.
`consul.address` does, but not `consul.addr`.
2016-06-10 15:50:11 -04:00
Sean Chittenden
a55395678f Fix tests for client.TestAgent_ServerConfig
Add similar logic in Agent `serverConfig()` to set up the
`serverSerfAddr` the same as `serverHttpAddr` and `serverRpcAddr`.
2016-06-10 15:50:11 -04:00
Sean Chittenden
5b0a969a36 Fix the client/rpcproxy unit tests. 2016-06-10 15:50:11 -04:00