Frank Schroeder
b97ab367f4
config: return error on extra command line arguments ( #3397 )
...
The `consul agent` command was ignoring extra command line arguments
which can lead to confusion when the user has for example forgotten to
add a dash in front of an argument or is not using an `=` when setting
boolean flags to `true`. `-bootstrap true` is not the same as
`-bootstrap=true`, for example.
Since all command line flags are known and we don't expect unparsed
arguments we can return an error. However, this may make it slightly
more difficult in the future if we ever wanted to have these kinds of
arguments.
Fixes #3397
2017-10-23 08:07:48 +02:00
Frank Schroeder
b3292d13fb
commands: get HTTP API flags for usage automatically
2017-10-18 00:08:45 +02:00
Frank Schroeder
56b24d3d4f
commands: cleanup help and synopsis.
...
* move Help and Synopsis to bottom
* make help and synopsis constants
* make sure help output is formatted
2017-10-18 00:08:45 +02:00
Frank Schroeder
31d5fb7f47
commands: move agent command to separate pkg
2017-10-18 00:08:45 +02:00
Frank Schroeder
1c75cf1af5
pkg refactor
...
command/agent/* -> agent/*
command/consul/* -> agent/consul/*
command/agent/command{,_test}.go -> command/agent{,_test}.go
command/base/command.go -> command/base.go
command/base/* -> command/*
commands.go -> command/commands.go
The script which did the refactor is:
(
cd $GOPATH/src/github.com/hashicorp/consul
git mv command/agent/command.go command/agent.go
git mv command/agent/command_test.go command/agent_test.go
git mv command/agent/flag_slice_value{,_test}.go command/
git mv command/agent .
git mv command/base/command.go command/base.go
git mv command/base/config_util{,_test}.go command/
git mv commands.go command/
git mv consul agent
rmdir command/base/
gsed -i -e 's|package agent|package command|' command/agent{,_test}.go
gsed -i -e 's|package agent|package command|' command/flag_slice_value{,_test}.go
gsed -i -e 's|package base|package command|' command/base.go command/config_util{,_test}.go
gsed -i -e 's|package main|package command|' command/commands.go
gsed -i -e 's|base.Command|BaseCommand|' command/commands.go
gsed -i -e 's|agent.Command|AgentCommand|' command/commands.go
gsed -i -e 's|\tCommand:|\tBaseCommand:|' command/commands.go
gsed -i -e 's|base\.||' command/commands.go
gsed -i -e 's|command\.||' command/commands.go
gsed -i -e 's|command|c|' main.go
gsed -i -e 's|range Commands|range command.Commands|' main.go
gsed -i -e 's|Commands: Commands|Commands: command.Commands|' main.go
gsed -i -e 's|base\.BoolValue|BoolValue|' command/operator_autopilot_set.go
gsed -i -e 's|base\.DurationValue|DurationValue|' command/operator_autopilot_set.go
gsed -i -e 's|base\.StringValue|StringValue|' command/operator_autopilot_set.go
gsed -i -e 's|base\.UintValue|UintValue|' command/operator_autopilot_set.go
gsed -i -e 's|\bCommand\b|BaseCommand|' command/base.go
gsed -i -e 's|BaseCommand Options|Command Options|' command/base.go
gsed -i -e 's|base.Command|BaseCommand|' command/*.go
gsed -i -e 's|c\.Command|c.BaseCommand|g' command/*.go
gsed -i -e 's|\tCommand:|\tBaseCommand:|' command/*_test.go
gsed -i -e 's|base\.||' command/*_test.go
gsed -i -e 's|\bCommand\b|AgentCommand|' command/agent{,_test}.go
gsed -i -e 's|cmd.AgentCommand|cmd.BaseCommand|' command/agent.go
gsed -i -e 's|cli.AgentCommand = new(Command)|cli.Command = new(AgentCommand)|' command/agent_test.go
gsed -i -e 's|exec.AgentCommand|exec.Command|' command/agent_test.go
gsed -i -e 's|exec.BaseCommand|exec.Command|' command/agent_test.go
gsed -i -e 's|NewTestAgent|agent.NewTestAgent|' command/agent_test.go
gsed -i -e 's|= TestConfig|= agent.TestConfig|' command/agent_test.go
gsed -i -e 's|: RetryJoin|: agent.RetryJoin|' command/agent_test.go
gsed -i -e 's|\.\./\.\./|../|' command/config_util_test.go
gsed -i -e 's|\bverifyUniqueListeners|VerifyUniqueListeners|' agent/config{,_test}.go command/agent.go
gsed -i -e 's|\bserfLANKeyring\b|SerfLANKeyring|g' agent/{agent,keyring,testagent}.go command/agent.go
gsed -i -e 's|\bserfWANKeyring\b|SerfWANKeyring|g' agent/{agent,keyring,testagent}.go command/agent.go
gsed -i -e 's|\bNewAgent\b|agent.New|g' command/agent{,_test}.go
gsed -i -e 's|\bNewAgent|New|' agent/{acl_test,agent,testagent}.go
gsed -i -e 's|\bAgent\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bBool\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bConfig\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bDefaultConfig\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bDevConfig\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bMergeConfig\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bReadConfigPaths\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bParseMetaPair\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bSerfLANKeyring\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bSerfWANKeyring\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|circonus\.agent|circonus|g' command/agent{,_test}.go
gsed -i -e 's|logger\.agent|logger|g' command/agent{,_test}.go
gsed -i -e 's|metrics\.agent|metrics|g' command/agent{,_test}.go
gsed -i -e 's|// agent.Agent|// agent|' command/agent{,_test}.go
gsed -i -e 's|a\.agent\.Config|a.Config|' command/agent{,_test}.go
gsed -i -e 's|agent\.AppendSliceValue|AppendSliceValue|' command/{configtest,validate}.go
gsed -i -e 's|consul/consul|agent/consul|' GNUmakefile
gsed -i -e 's|\.\./test|../../test|' agent/consul/server_test.go
# fix imports
f=$(grep -rl 'github.com/hashicorp/consul/command/agent' * | grep '\.go')
gsed -i -e 's|github.com/hashicorp/consul/command/agent|github.com/hashicorp/consul/agent|' $f
goimports -w $f
f=$(grep -rl 'github.com/hashicorp/consul/consul' * | grep '\.go')
gsed -i -e 's|github.com/hashicorp/consul/consul|github.com/hashicorp/consul/agent/consul|' $f
goimports -w $f
goimports -w command/*.go main.go
)
2017-06-10 18:52:45 +02:00
Frank Schroeder
902f4caff2
agent: move watch plans into agent
2017-06-10 18:52:45 +02:00
Frank Schroeder
4a223111d2
log: use prefix [ERR] instead of [ERROR]
2017-06-08 09:50:47 +02:00
Frank Schröder
825f72f5ef
agent: support custom header and method for http checks ( #3106 )
...
This patch adds support for custom headers and
method for HTTP checks.
Fixes #2474
Fixes #2657
Fixes #3106
2017-06-07 01:11:56 +02:00
James Phillips
240413f5d6
Merge pull request #3105 from hashicorp/test-stability
...
Tweaks things for better test stability.
2017-06-03 10:09:12 -07:00
Frank Schroeder
51e0e158f1
agent: fix graceful http server shutdown
2017-06-03 19:08:50 +02:00
Frank Schroeder
34fd31b7b1
agent: move config reloading into the agent
2017-06-03 19:08:50 +02:00
Frank Schroeder
aa1519c9f7
agent: move parseMetaPair to config and export
2017-06-03 19:08:50 +02:00
Frank Schroeder
d977aa1fe7
agent: move retry join into agent
2017-06-03 19:08:50 +02:00
Frank Schroeder
55a513da2e
agent: add GossipEncrypted function
...
Remove dead code and expose a GossipEncrypted() method
on the agent instead of accessing the internal delegate.
2017-06-03 19:08:50 +02:00
James Phillips
b0b5df579f
Cleans up an unrelated vet error.
2017-06-02 21:07:15 -07:00
Frank Schroeder
4034d0ac0b
agent: use agent logger for consul client and deps
2017-05-31 11:05:02 +02:00
Frank Schroeder
a9451d596f
agent: set tcpKeepAliveListener when there is no error
2017-05-31 10:24:32 +02:00
Frank Schroeder
d6c7404b34
agent: simplify shutdown timeout logging
...
Note that we are currently timing out every time. This still
needs to be investigated.
2017-05-31 09:41:58 +02:00
Frank Schroeder
30ba712857
agent: set proto to http since we are logging it now
2017-05-31 09:41:16 +02:00
Frank Schroeder
ec729693d7
Address review comments
2017-05-31 01:05:21 +02:00
Frank Schroeder
b6c69ebf5d
agent: refactor DNS and HTTP server
...
* refactor DNS server to be ready for multiple bind addresses
* drop tcpKeepAliveListener since it is default for the HTTP servers
* add startup timeout watcher for HTTP servers identical to DNS server
2017-05-31 00:29:29 +02:00
Frank Schroeder
10540f8d5f
agent: fix logging
...
* use agent logger for consul/serf/raft/dns/agent/...
* support optional id for concurrent tests
2017-05-31 00:29:27 +02:00
Frank Schroeder
1df74e36bd
agent: print more useful shutdown message
2017-05-31 00:29:27 +02:00
Frank Schroeder
0325a42089
test: fix data race with endpoints
2017-05-31 00:29:26 +02:00
Frank Schroeder
e16589c079
agent: shutdown delegate if created
...
When the TestAgent shuts down a half-started agent
the delegate may not have been created at this point.
2017-05-31 00:29:26 +02:00
Frank Schroeder
3658d4d428
test: address pull request comments
2017-05-31 00:29:25 +02:00
Frank Schroeder
3865f14a25
agent: simplify agent creation
...
This patch creates an agent with just a config struct
and allows for other fields to be set as required.
2017-05-31 00:29:23 +02:00
Frank Schroeder
82650f73e3
agent: move http/dns endpoints into agent
...
Move the HTTP and DNS endpoints into the agent and control
their lifespan via the agent.
This removes the requirement to manage HTTP and DNS servers
indpendent of the agent since the agent is mostly useless
without an endpoint and the endpoints without the agent.
2017-05-31 00:29:23 +02:00
Kyle Havlovitz
62f72f104c
Add settings for upshifting to encrypted gossip ( #3079 )
2017-05-30 08:51:37 -07:00
Frank Schroeder
8ad66f4bea
agent: support custom check id and name
...
This patch adds support for a custom check id and name when
registering a service.
This is achieved by adding a CheckID and a Name field to the
CheckType structure which is used to register checks with a
service and when returning health check definitions.
CheckDefinition is a superset of CheckType which duplicates
some of the fields of CheckType. This patch decouples these
two structures by removing the embedding of CheckType in
CheckDefinition.
Fixes #3047
2017-05-17 20:17:08 +02:00
Frank Schroeder
ad40a855bd
agent: move isAddrANY to separate package
2017-05-15 22:44:43 +02:00
Frank Schroeder
e2c37b47ee
agent: Replace client/server with delegate interface
...
This patch adds a new internal interface clientServer
which defines the common methods of consul.Client and
consul.Server. This allows to replace the following
code
if a.server != nil {
a.server.do()
} else {
a.client.do()
}
with
a.delegate.do()
In case a specific type is required a type check can
be performed:
if srv, ok := a.delegate.(*consul.Server); ok {
srv.doSrv()
}
2017-05-15 18:35:38 +02:00
Frank Schroeder
41f01a0cfc
agent: allow "::" as IPv6 bind address
...
Fixes #2285
2017-05-15 17:51:33 +02:00
Frank Schroeder
914a83cae0
agent: use bind address as src unless INADDR_ANY
...
Use the bind address as source address for outgoing
RPC connections unless it is INADDR_ANY.
The current code uses the advertise address which will
not work in certain environments where the advertise
address is not routable in the network of the agent,
e.g. NAT environment, container... After all, that is
the purpose of the advertise address.
See #2822
2017-05-11 00:34:14 +02:00
Frank Schroeder
e6c6f8cedd
agent: use helper for INADDR_ANY
2017-05-11 00:34:14 +02:00
Kyle Havlovitz
5bab68b9bb
Add a path for transitioning to TLS on an existing cluster ( #3001 )
...
Fixes #1705
2017-05-10 14:25:48 -07:00
Frank Schroeder
8c2b261c61
Use bind address as source for outgoing connections ( #2822 )
...
This patch configures consul to use the bind address as the
source address for outgoing connections.
Fixes #2822
2017-05-04 01:41:47 +02:00
Frank Schroeder
fb83790cb9
Do not modify config after creation II
...
Move code for finding the advertise address via a
template into consulConfig() so that the config
object is not modified after creation.
2017-05-04 01:41:47 +02:00
Frank Schroeder
a235986a28
Do not modify config after creation
...
Make sure the RPCAdvertise address is always set
so that the configuration does not have to be modified
after creation.
2017-05-04 01:41:47 +02:00
Frank Schroeder
d34ba3e823
Cleanup agent config
2017-05-04 01:41:47 +02:00
Kyle Havlovitz
cd56a5ebdd
Add separate option for verifying incoming HTTPS traffic ( #2974 )
...
* Add separate option for verifying incoming HTTPS traffic
2017-04-28 16:15:55 -07:00
Kyle Havlovitz
b70e419aeb
Add TLS cipher suite options and CA path support ( #2963 )
...
This patch adds options to configure the available
TLS cipher suites and adds support for a path
for multiple CA certificates.
Fixes #2959
2017-04-27 01:29:39 -07:00
Frank Schroeder
3e00e36f41
golint: Untangle if blocks with return in else
2017-04-25 09:26:13 -07:00
Frank Schroeder
eddb1af603
Remove duplicate constants
...
This patch removes duplicate internal copies of constants in the structs
package which are also defined in the api package. The api.KVOp type
with all its values for the TXN endpoint and the api.HealthXXX constants
are now used throughout the codebase.
This resulted in some circular dependencies in the testutil package
which have been resolved by copying code and constants and moving the
WaitForLeader function into a separate testrpc package.
2017-04-20 09:54:49 -07:00
James Phillips
fa04c24978
Adds a new -disable-host-node-id option to help when testing with containers.
...
Fixes #2877 .
2017-04-12 22:07:18 -07:00
Alex Dadgar
7f6d95f1c9
Hash host ID so its stable and well distributed
...
This PR takes the host ID and runs it through a hash so that it is well
distributed. This makes it so that machines that report similar host IDs
are easily distinguished.
Instances of similar IDs occur on EC2 where the ID is prefixed and on
motherboards created in the same batch.
2017-04-10 11:57:24 -07:00
James Phillips
8940d1c3fe
Keeps the service and check tokens around for deregistration.
...
We fixed a few related issues while we were in here. We now only let
services register checks with a matching token, and we also close out
service and check delete operations if the catalog deregister claims
it doesn't know about the ID of the service or check being deleted.
2017-03-24 17:15:20 -07:00
Kyle Havlovitz
390f41d8d5
Add advanced autopilot features
2017-03-22 15:25:16 -07:00
James Phillips
26dddb428c
Forces user-supplied node IDs to lower case for consistency.
2017-03-13 19:51:56 -07:00
Kyle Havlovitz
2eefe3ca5b
Add autopilot server health tracking
...
This adds two goroutines to perform autopilot tasks on the leader - one
to monitor the health of servers and another to periodically clean up
dead servers with a limit on removal count. Also adds a new http endpoint,
`/v1/operator/autopilot/health`, for querying this information through an
operator RPC endpoint.
2017-03-06 16:00:10 -08:00