Commit Graph

1700 Commits

Author SHA1 Message Date
Frank Schroeder 926aa72246 commands: move kv delete command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 50f039191d commands: move kv command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder bd825687dd commands: move keygen command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 74cf5c1c2c commands: move info command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder c1c883957f commands: move rExec helper to bottom 2017-10-18 00:08:45 +02:00
Frank Schroeder 8c7f013ae1 commands: move exec command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder ad50e2a410 commands: move event command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder dc3c722b2c commands: move join command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 8880ae714b commands: move validate command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder e65bd2a268 commands: move flag handling into flags pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 7568a19433 config: refactor commands to print help for flags (#3536)
This patch refactors the commands that use the mitchellh/cli library to
populate the command line flag set in both the Run() and the Help()
method. Earlier versions of the mitchellh/cli library relied on the
Run() method to populuate the flagset for generating the usage screen.
This has changed in later versions and was previously solved with a
small monkey patch to the library to restore the old behavior.

However, this makes upgrading the library difficult since the patch has
to be restored every time.

This patch addresses this by moving the command line flags into an
initFlags() method where appropriate and also moving all variables for
the flags from the Run() method into the command itself.

Fixes #3536
2017-10-18 00:08:45 +02:00
Ryan Slade 6f05ea91a3 Replace time.Now().Sub(x) with time.Since(x) 2017-10-17 20:38:24 +02:00
James Phillips e9670761f9
Cleans up some drift between the OSS and Enterprise trees. 2017-10-11 15:53:07 -07:00
Frank Schroeder db016a0c8d
command: show full help text on usage 2017-10-05 18:17:54 +02:00
Frank Schroeder 2320836d7f command: do not merge flags in-place 2017-10-05 18:08:35 +02:00
Frank Schroeder 56ebd5b30f command: simplify duplicate code 2017-10-05 18:08:35 +02:00
Frank Schroeder 3028d52158 command: drop hidden flags from base command 2017-10-05 18:08:35 +02:00
Frank Schroeder 13266a2e65 command: drop unused hidden flags for 'validate' 2017-10-05 18:08:35 +02:00
Frank Schroeder 7182829f15
command: drop legacy 'operator raft' tests 2017-10-05 17:56:16 +02:00
Frank Schroeder a4be9e2e67 command: simplify 'operator raft'
The cli library can handle subcommands. Therefore, most of the code is
no longer necessary.
2017-10-05 17:40:57 +02:00
Frank Schroeder cac55a1e80 command: don't show confusing error on usage output 2017-10-05 17:29:45 +02:00
Frank Schroeder 7bab8d3eb7 command: drop deprecated 'configtest' command
'configtest' has been replaced with 'validate'
2017-10-05 17:22:34 +02:00
Kyle Havlovitz dde743700f Merge pull request #3535 from hashicorp/metric-docs
Update metric names and add a legacy config flag
2017-10-04 17:39:16 -07:00
Kyle Havlovitz be04bfed34 Clean up subprocess handling and make shell use optional (#3509)
* Clean up handling of subprocesses and make using a shell optional

* Update docs for subprocess changes

* Fix tests for new subprocess behavior

* More cleanup of subprocesses

* Minor adjustments and cleanup for subprocess logic

* Makes the watch handler reload test use the new path.

* Adds check tests for new args path, and updates existing tests to use new path.

* Adds support for script args in Docker checks.

* Fixes the sanitize unit test.

* Adds panic for unknown watch type, and reverts back to Run().

* Adds shell option back to consul lock command.

* Adds shell option back to consul exec command.

* Adds shell back into consul watch command.

* Refactors signal forwarding and makes Windows-friendly.

* Adds a clarifying comment.

* Changes error wording to a warning.

* Scopes signals to interrupt and kill.

This avoids us trying to send SIGCHILD to the dead process.

* Adds an error for shell=false for consul exec.

* Adds notes about the deprecated script and handler fields.

* De-nests an if statement.
2017-10-04 16:48:00 -07:00
Kyle Havlovitz 0063516e5e
Update metric names and add a legacy config flag 2017-10-04 16:43:27 -07:00
Kyle Havlovitz 624be65d35
Split BaseCommand http config into a separate function 2017-09-29 12:26:14 -07:00
Kyle Havlovitz 8403a98ea7
Add base command option for hiding generated help for normal args 2017-09-28 18:43:28 -07:00
James Phillips 7f02f9dad2
Returns errors properly from the consul operator raft list-peers command. 2017-09-28 15:37:59 -07:00
Frank Schröder 707f8e329a Metrics service prefix (#3498)
* metrics: replace statsite_prefix with service_prefix

The metrics prefix isn't statsite specific and is in fact used
for all metrics providers. Since we are deprecating fields
anyway we should fix this one as well.

Fixes #3293

* Updates docs and sorts telemetry section.

* Renames to "metrics_prefix" to disambiguate with Consul services.

* Updates the change log.
2017-09-26 17:49:55 -07:00
Preetha Appan 318d0232f7 Move Raft protocol version for list peers end point to server side, fix unit tests. This fixes #3449 2017-09-26 09:35:39 -05:00
preetapan 4ced57c1f8 Merge pull request #3494 from hashicorp/enforce_json_extension
Enforce json or hcl extension to Consul config files, updated unit tests
2017-09-25 17:30:33 -05:00
James Phillips fcaa889116 Bumps default Raft protocol to version 3. (#3477)
* Changes default Raft protocol to 3.

* Changes numPeers() to report only voters.

This should have been there before, but it's more obvious that this
is incorrect now that we default the Raft protocol to 3, which puts
new servers in a read-only state while Autopilot waits for them to
become healthy.

* Fixes TestLeader_RollRaftServer.

* Fixes TestOperator_RaftRemovePeerByAddress.

* Fixes TestServer_*.

Relaxed the check for a given number of voter peers and instead do
a thorough check that all servers see each other in their Raft
configurations.

* Fixes TestACL_*.

These now just check for Raft replication to be set up, and don't
care about the number of voter peers.

* Fixes TestOperator_Raft_ListPeers.

* Fixes TestAutopilot_CleanupDeadServerPeriodic.

* Fixes TestCatalog_ListNodes_ConsistentRead_Fail.

* Fixes TestLeader_ChangeServerID and adjusts the conn pool to throw away
sockets when it sees io.EOF.

* Changes version to 1.0.0 in the options doc.

* Makes metrics test more deterministic with autopilot metrics possible.
2017-09-25 15:27:04 -07:00
Preetha Appan 1e8385df2c Enforce json or hcl extension to Consul config files, updated unit tests 2017-09-25 17:17:12 -05:00
Frank Schröder 69a088ca85 New config parser, HCL support, multiple bind addrs (#3480)
* new config parser for agent

This patch implements a new config parser for the consul agent which
makes the following changes to the previous implementation:

 * add HCL support
 * all configuration fragments in tests and for default config are
   expressed as HCL fragments
 * HCL fragments can be provided on the command line so that they
   can eventually replace the command line flags.
 * HCL/JSON fragments are parsed into a temporary Config structure
   which can be merged using reflection (all values are pointers).
   The existing merge logic of overwrite for values and append
   for slices has been preserved.
 * A single builder process generates a typed runtime configuration
   for the agent.

The new implementation is more strict and fails in the builder process
if no valid runtime configuration can be generated. Therefore,
additional validations in other parts of the code should be removed.

The builder also pre-computes all required network addresses so that no
address/port magic should be required where the configuration is used
and should therefore be removed.

* Upgrade github.com/hashicorp/hcl to support int64

* improve error messages

* fix directory permission test

* Fix rtt test

* Fix ForceLeave test

* Skip performance test for now until we know what to do

* Update github.com/hashicorp/memberlist to update log prefix

* Make memberlist use the default logger

* improve config error handling

* do not fail on non-existing data-dir

* experiment with non-uniform timeouts to get a handle on stalled leader elections

* Run tests for packages separately to eliminate the spurious port conflicts

* refactor private address detection and unify approach for ipv4 and ipv6.

Fixes #2825

* do not allow unix sockets for DNS

* improve bind and advertise addr error handling

* go through builder using test coverage

* minimal update to the docs

* more coverage tests fixed

* more tests

* fix makefile

* cleanup

* fix port conflicts with external port server 'porter'

* stop test server on error

* do not run api test that change global ENV concurrently with the other tests

* Run remaining api tests concurrently

* no need for retry with the port number service

* monkey patch race condition in go-sockaddr until we understand why that fails

* monkey patch hcl decoder race condidtion until we understand why that fails

* monkey patch spurious errors in strings.EqualFold from here

* add test for hcl decoder race condition. Run with go test -parallel 128

* Increase timeout again

* cleanup

* don't log port allocations by default

* use base command arg parsing to format help output properly

* handle -dc deprecation case in Build

* switch autopilot.max_trailing_logs to int

* remove duplicate test case

* remove unused methods

* remove comments about flag/config value inconsistencies

* switch got and want around since the error message was misleading.

* Removes a stray debug log.

* Removes a stray newline in imports.

* Fixes TestACL_Version8.

* Runs go fmt.

* Adds a default case for unknown address types.

* Reoders and reformats some imports.

* Adds some comments and fixes typos.

* Reorders imports.

* add unix socket support for dns later

* drop all deprecated flags and arguments

* fix wrong field name

* remove stray node-id file

* drop unnecessary patch section in test

* drop duplicate test

* add test for LeaveOnTerm and SkipLeaveOnInt in client mode

* drop "bla" and add clarifying comment for the test

* split up tests to support enterprise/non-enterprise tests

* drop raft multiplier and derive values during build phase

* sanitize runtime config reflectively and add test

* detect invalid config fields

* fix tests with invalid config fields

* use different values for wan sanitiziation test

* drop recursor in favor of recursors

* allow dns_config.udp_answer_limit to be zero

* make sure tests run on machines with multiple ips

* Fix failing tests in a few more places by providing a bind address in the test

* Gets rid of skipped TestAgent_CheckPerformanceSettings and adds case for builder.

* Add porter to server_test.go to make tests there less flaky

* go fmt
2017-09-25 11:40:42 -07:00
James Phillips 02a3f3f27b
Shows the segment name in the keyring API and command output. 2017-09-07 12:17:39 -07:00
James Phillips cc6797dd75
Remaps servers to "<all>" only when listing multiple segments. 2017-09-05 13:50:38 -07:00
James Phillips c629773b40
Makes the all segments query explict, and the default for `consul members`. 2017-09-05 12:22:20 -07:00
James Phillips 0b44abd9db
Simplifies members command to not fetch segments. 2017-09-05 11:46:44 -07:00
Kyle Havlovitz 1a36ca524f
Remove duplicate error message 2017-09-01 10:18:43 -07:00
Kyle Havlovitz 5cc4b32a5d
Organize segments for a cleaner split between enterprise and OSS 2017-08-31 17:39:46 -07:00
Kyle Havlovitz b77a0aa932
Fix some inconsistencies with segment logic and comments 2017-08-30 17:43:46 -07:00
Kyle Havlovitz d9fc2b3d75
Update coord display in ui to account for segments 2017-08-30 11:58:29 -07:00
Kyle Havlovitz 1c04f1537a
Add agent.segment interpolation to prepared queries 2017-08-30 11:58:29 -07:00
Kyle Havlovitz 107d7f6c5a
Add rpc_listener option to segment config 2017-08-30 11:58:29 -07:00
James Phillips 6a6eadd8c7
Adds open source side of network segments (feature is Enterprise-only). 2017-08-30 11:58:29 -07:00
Frank Schroeder 62c77d70f0 build: make tests independent of build tags
When the metadata server is scanning the agents for potential servers
it is parsing the version number which the agent provided when it
joined. This version number has to conform to a certain format, i.e.
'n.n.n'. Without this version number properly set some tests fail with
error messages that disguise the root cause.

The default version number is currently set to 'unknown' in
version/version.go which does not parse and triggers the tests to fail.
The work around is to use a build tag 'consul' which will use the
version number set in version_base.go instead which has the correct
format and is set to the current release version.

In addition, some parts of the code also require the version number to
be of a certain value. Setting it to '0.0.0' for example makes some
tests pass and others fail since they don't pass the semantic check.

When using go build/install/test one has to remember to use '-tags
consul' or tests will fail with non-obvious error messages.

Using build tags makes the build process more complex and error prone
since it prevents the use of the plain go toolchain and - at least in
its current form - introduces subtle build and test issues. We should
try to eliminate build tags for anything else but platform specific
code.

This patch removes all references to specific version numbers in the
code and tests and sets the default version to '9.9.9' which is
syntactically correct and passes the semantic check. This solves the
issue of running go build/install/test without tags for the OSS build.
2017-08-30 13:40:18 +02:00
wuxin 792a535c87 fix command/kv_import.go help text (#3387) 2017-08-10 09:17:37 +02:00
Frank Schröder 32d4eecc1a agent: honor deprecated flags for retry-join-{ec2,azure,gce} (#3384) 2017-08-09 16:18:30 -07:00
Frank Schroeder 1d0bbfed9c
agent: move agent/consul/structs to agent/structs 2017-08-09 14:32:12 +02:00
Kyle Havlovitz 975ded2714
Add support for labels/filters from go-metrics 2017-08-08 01:45:10 -07:00
Frank Schroeder 68e8f3d0f7 agent: use github.com/hashicorp/go-discover
Replace the provider specific node discovery code
with go-discover to support AWS, Azure and GCE.

Fixes #3282
2017-08-01 11:41:43 +02:00
Preetha Appan 7b99f7ca08 Fix comments, and remove redundant TestConfig init from a couple of unit tests 2017-07-28 10:40:43 -05:00
Preetha Appan 28016190e0 Moved handling advertise address to readConfig and out of the agent's constructor, plus unit test fixes 2017-07-27 22:06:31 -05:00
Preetha Appan 398c1e450c Move go-socketaddr template parsing into config package to make it happen before creating a new agent. Also removed redundant parsetemplate calls from agent.go. 2017-07-27 16:17:35 -05:00
James Phillips 9b70009ab8 command/lock: Add -child-exitcode, return 2 on child error (#3329)
* Exit 2 if -child-exit-code and the child returned with an error.
* There is no platform independent way to check the exact return code of
* the child, so on error always return 2.
* Closes #947
* Closes #1503
2017-07-26 22:09:19 -07:00
Kyle Havlovitz 5c54fd6a61
Add UpgradeVersionTag to autopilot get/set commands 2017-07-18 14:01:04 -07:00
James Phillips 788dd255a1 Adds new config to make script checks opt-in, updates documentation. (#3284) 2017-07-17 11:20:35 -07:00
James Phillips 3c5a36357c
Sort tags so output is deterministic. 2017-07-14 17:00:08 -07:00
Seth Vargo a2ba7071e9 Add catalog CLI functions (#3204) 2017-07-14 12:45:08 -07:00
Frank Schroeder 162e3e6298 command: make TestExecCommandRun_CrossDC more resilient
Wait after WAN join that both members see each other.
2017-07-07 09:22:34 +02:00
James Phillips f081e45a89
Removes unneeded shutdown channel in config reading tests. 2017-06-25 10:39:51 -07:00
James Phillips 4b85d33ef1 Fixes watch tracking during reloads and fixes address issue. (#3189)
This patch fixes watch registration through the config file and a broken log line when the watch registration fails. It also plumbs all the watch loading through a common function and tweaks the
unit test to create the watch before the reload.
2017-06-24 12:52:41 -07:00
James Phillips 2184136284 Changes host-based node IDs from opt-out to opt-in. (#3187) 2017-06-24 09:36:53 -07:00
Jared Wasinger 06c49f8345 Warn when attempting to bootstrap an even number of nodes (#3158)
* Warn when attempting to bootstrap an even number of nodes.  Addresses #1282
* add more detailed warning for two server case
2017-06-21 15:36:55 -07:00
Frank Schroeder f8e52c897e agent: fix 'consul leave' shutdown race (#2880)
When the agent is triggered to shutdown via an external 'consul leave'
command delivered via the HTTP API then the client expects to receive a
response when the agent is down. This creates a race on when to shutdown
the agent itself like the RPC server, the checks and the state and the
external endpoints like DNS and HTTP.

This patch splits the shutdown process into two parts:

 * shutdown the agent
 * shutdown the endpoints (http and dns)

They can be executed multiple times, concurrently and in any order but
should be executed first agent, then endpoints to provide consistent
behavior across all use cases. Both calls have to be executed for a
proper shutdown.

This could be partially hidden in a single function but would introduce
some magic that happens behind the scenes which one has to know of but
isn't obvious.

Fixes #2880
2017-06-21 05:52:51 +02:00
James Phillips c5f7144c62
Moves flag slice helper into configutil. 2017-06-20 12:52:35 -07:00
James Phillips 465f24298e Moves config util helpers into their own package. (#3165) 2017-06-20 10:49:37 -07:00
Kyle Havlovitz 5e45aec642 Add an option to disable keyring file (#3145)
Also disables keyring file in dev mode.
2017-06-15 15:24:04 -07:00
Frank Schroeder cd837b0b18 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 c21d0f2284 test: move discover tests 2017-06-10 18:52:45 +02:00
Frank Schroeder 0d9471d659 use 'c' as command receiver for simple commands 2017-06-10 18:52:45 +02:00
Frank Schroeder a56d0cc95f agent: move watch plans into agent 2017-06-10 18:52:45 +02:00
preetapan f34730e3ee Fixed regression with dns server start condition (#3137) 2017-06-09 15:50:06 -07:00
Seth Vargo f4b36e8d90
Simplify 2017-06-09 14:55:04 -04:00
Seth Vargo 55161869a7
Update comment 2017-06-09 14:51:34 -04:00
Seth Vargo b20902b7e2
Parse values given to ?passing in the API
This PR fixes GH-2212 in the most backwards-compatible way I can think
of. If the user does not pass a value for `?passing`, it's assumed to be
true, which mirrors the current behavior. However, if the user passes
any value for passing, that value is parsed as a bool using strconv.

It's important to note that this is technically a breaking change.
Previously using `?passing=false` would return only passing nodes. While
this behavior is obviously incorrect, it was the previous behavior. We
should call this out very clearly in the CHANGELOG.
2017-06-09 14:36:00 -04:00
James Phillips a5cc8434ce
Opens up timing bound on flaky test. 2017-06-08 21:37:52 -07:00
James Phillips a7c910be7c
Fixes HTTP header compare by including standard headers. 2017-06-08 14:10:46 -07:00
Frank Schroeder 17051c6870 agent: fix time.Duration parsing
The duration can be passed as a string, a float64 or a time.Duration
and this patch handles this properly.
2017-06-08 22:42:49 +02:00
Frank Schroeder d284d061c9
agent: log events and exit code to the log file
This patch logs the signals, events, errors and the exit
code to the log file instead of printing it on the console.
This should provide a more complete picture for debugging.
2017-06-08 10:07:55 +02:00
Frank Schroeder d98f0f7bab
log: use prefix [ERR] instead of [ERROR] 2017-06-08 09:50:47 +02:00
James Phillips e32b42a222
Updates static assets to latest. 2017-06-07 21:16:59 -07:00
James Phillips fd7c3c5cfa Merge pull request #3121 from hashicorp/increase-graceful-timeout
agent: increase graceful shutdown timeout
2017-06-07 10:42:19 -07:00
Frank Schroeder 247e44e787
agent: increase graceful shutdown timeout
When triggering a leave through an INT/TERM signal the hard-coded
timeout of 5 seconds is too short to complete the leave successfully.
Therefore, the agent always times out.

This value should probably configurable.
2017-06-07 13:12:34 +02:00
Frank Schroeder fc2ed18423
agent: log differnt shutdown stages
Log the different code paths during shutdown.
2017-06-07 13:11:04 +02:00
Frank Schröder e206ab5cb6 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
Frank Schroeder 0133ab135a test: refactor TestDecodeConfig test
This patch refactors the multiple tests for
DecodeConfig into a single table-driven test
that tests most fields individually.
2017-06-04 23:55:12 +02:00
Frank Schroeder 35f2377702 test: Fix TestAgent_Reload
This test was still referring to cmd.agent which has been removed.
2017-06-04 22:45:40 +02:00
James Phillips 037f72813b Merge pull request #3105 from hashicorp/test-stability
Tweaks things for better test stability.
2017-06-03 10:09:12 -07:00
Frank Schroeder 92b2192b75 agent: fix graceful http server shutdown 2017-06-03 19:08:50 +02:00
Frank Schroeder 9779f7ef02 agent: cleanup run method 2017-06-03 19:08:50 +02:00
Frank Schroeder b3e94082b0 agent: move registerWatches out of the run method 2017-06-03 19:08:50 +02:00
Frank Schroeder 5c08953449 agent: move telemetry out of the run method 2017-06-03 19:08:50 +02:00
Frank Schroeder 7c8b2be86d agent: move update check out of the run method 2017-06-03 19:08:50 +02:00
Frank Schroeder 055347f7cd agent: simplify signal handling 2017-06-03 19:08:50 +02:00
Frank Schroeder 6262d85dab agent: move config reloading into the agent 2017-06-03 19:08:50 +02:00
Frank Schroeder 02ce45e5bb agent: move parseMetaPair to config and export 2017-06-03 19:08:50 +02:00
Frank Schroeder 34c981ba55 agent: remove agent from command
Decouple command and agent a bit more.
2017-06-03 19:08:50 +02:00
Frank Schroeder 63d336e11c agent: move retry join into agent 2017-06-03 19:08:50 +02:00
Frank Schroeder 488beeb208 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 26677b4117
Cleans up an unrelated vet error. 2017-06-02 21:07:15 -07:00
James Phillips 3795f17b3b
Adds back the port shuffle on agent start retries. 2017-06-02 20:53:20 -07:00
Frank Schroeder d314a539da Do not recurse when the service address is a local cname
Fixes #2795
2017-06-01 18:20:31 +02:00
Frank Schroeder 7f18fe1a5b agent: LastContact cannot be negative (#3067)
The X-Consul-LastContact header cannot be negative.

Fixes #3067
2017-06-01 18:20:12 +02:00
Frank Schroeder dbe8009968
test: replace one more BoolFalse with agent.Bool() 2017-05-31 11:41:17 +02:00
Frank Schroeder 00117ed09b
test: we will not use dev mode for testing for now 2017-05-31 11:34:00 +02:00
Frank Schroeder d14182c2de
test: stagger retry attempts of TestAgent.Start 2017-05-31 11:33:25 +02:00
Frank Schroeder 5224699341
test: make TestAgent setup reusable
Pick the random ports only once and try starting with them
a number of times so that the configuration can be re-used.
This is because the ports are written into the data files
and a subsequent agent reading the files needs to have the
same ports.

For the same reason we do not remove the data directory on
every attempt since this makes it impossible to re-read the
data files.
2017-05-31 11:32:31 +02:00
Frank Schroeder b06c969deb
agent: use agent logger for consul client and deps 2017-05-31 11:05:02 +02:00
Frank Schroeder 2588f22be7
test: start secondary agents also via TestAgent 2017-05-31 10:56:19 +02:00
Frank Schroeder 4e6e9cb05a
agent: set tcpKeepAliveListener when there is no error 2017-05-31 10:24:32 +02:00
Frank Schroeder cfe101ce49
test: use test name as log prefix 2017-05-31 09:54:09 +02:00
Frank Schroeder c587561572
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 b220133785
agent: set proto to http since we are logging it now 2017-05-31 09:41:16 +02:00
Frank Schroeder 361b69bb30
test: Use Bool() instead of &BoolTrue/False since 2017-05-31 09:21:01 +02:00
Frank Schroeder bb8a21c385
Address review comments 2017-05-31 01:05:21 +02:00
Frank Schroeder 78cd7a9087
agent: start HTTPS only if there is a cert and key 2017-05-31 00:29:29 +02:00
Frank Schroeder 45a9c2be8b
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 35757e6c09
test: increase sleep time for test 2017-05-31 00:29:28 +02:00
Frank Schroeder 42ade30551
test: allow tests to control anti-entropy syncs 2017-05-31 00:29:28 +02:00
Frank Schroeder 5735b31ebc
test: run mock dns recursors on random ports 2017-05-31 00:29:28 +02:00
Frank Schroeder d07f2a2542
test: skip tests that use cmd.Run until signal handling is fixed 2017-05-31 00:29:28 +02:00
Frank Schroeder 83d9fb77b7
test: add test for starting/stopping lots of agents 2017-05-31 00:29:28 +02:00
Frank Schroeder dc1548af06
test: use UniqueID prefix for check tests to unify log output 2017-05-31 00:29:28 +02:00
Frank Schroeder 828f40054a
test: improve TestAgent
* don't use retry to try restarting the agent
  this caused some issues when the startup would fail in
  a separate go routine

* clear out the data directory on every retry since the ports
  are stored in the raft data files

* set a unique id for every agent to allow for tracking of
  concurrent output
2017-05-31 00:29:28 +02:00
Frank Schroeder 2b627b95dd
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 a433d13b20
test: call t.Fatal() from main go routine 2017-05-31 00:29:27 +02:00
Frank Schroeder 9d4529972e
dns: do not log socket close during shutdown 2017-05-31 00:29:27 +02:00
Frank Schroeder ae5270a1e1
agent: print more useful shutdown message 2017-05-31 00:29:27 +02:00
Frank Schroeder f53b90c16b
test: start sync after agent start 2017-05-31 00:29:27 +02:00
Frank Schroeder bb3b099d60
test: add test name to output 2017-05-31 00:29:27 +02:00
Frank Schroeder 9fbac59f78
test: perform blocking query on agent 2017-05-31 00:29:27 +02:00
Frank Schroeder 36a2312639
test: parallelize dns test 2017-05-31 00:29:26 +02:00
Frank Schroeder a2b29bea9f
test: fix failing test 2017-05-31 00:29:26 +02:00
Frank Schroeder d0cb508382
test: remove output to stdout 2017-05-31 00:29:26 +02:00
Frank Schroeder 846fe5d630
test: use cli.NewMockUi instead of new(cli.MockUi)
Use the constructor function to prevent a nil panic
if there was no write to the output buffers.
2017-05-31 00:29:26 +02:00
Frank Schroeder ad153f0e76
test: fix data race with endpoints 2017-05-31 00:29:26 +02:00
Frank Schroeder 449eceec11
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 6a40fe026e
agent: shutdown dns servers on error 2017-05-31 00:29:26 +02:00
Frank Schroeder 60a47addc7
test: Shutdown half-started agent before retrying 2017-05-31 00:29:25 +02:00
Frank Schroeder d1ee368da9
test: fix data race in MockNotify
42 -> 32 data races
2017-05-31 00:29:25 +02:00
Frank Schroeder dba20d02eb
test: run command tests in parallel 2017-05-31 00:29:25 +02:00
Frank Schroeder 48bff52614
test: address pull request comments 2017-05-31 00:29:25 +02:00
Frank Schroeder b9ae289e34
test: remove ACL options from default test config 2017-05-31 00:29:25 +02:00
Frank Schroeder e8651261f9
test: allocate ports in blocks of 10 2017-05-31 00:29:24 +02:00
Frank Schroeder 26474ce9c2
test: refactor command tests to use TestAgent 2017-05-31 00:29:24 +02:00
Frank Schroeder 98ac791577
test: retry a bit more often 2017-05-31 00:29:24 +02:00
Frank Schroeder 6e7cf8c07e
agent: rename *Config vars to 'cfg' 2017-05-31 00:29:24 +02:00
Frank Schroeder 193eec414f
agent: rename *Command vars to 'cmd'
'c' is ambigious and it conflicts with 'config'.
2017-05-31 00:29:24 +02:00
Frank Schroeder 5cdfd3789f
test: rename *Config vars to 'cfg'
'c' is ambigous since Command also uses this
and we want to use 'config' as a package name.
2017-05-31 00:29:24 +02:00