Commit Graph

1690 Commits

Author SHA1 Message Date
Frank Schroeder 3a02ce9ebc commands: move snapshot inspect command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder c8992cbe28 commands: move snapshot command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 4d6a0b94dd commands: move rtt command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 566359234a commands: move reload command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 4947ba7f3d commands: move operator autopilot set command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder f719d78441 commands: move operator autopilot get command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder bd1b189990 commands: move operator autopilot command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder c50e43a4ea commands: move operator list remove-peer command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 2a824f0575 commands: move operator raft list-peers command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder f10f07b448 commands: move operator raft command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder cc103391b2 commands: move operator command to separate pkg 2017-10-18 00:08:45 +02:00
Preetha Appan 1eec0e757c Move monitor command to its own package 2017-10-18 00:08:45 +02:00
Preetha Appan f389fe7757 Fix import order 2017-10-18 00:08:45 +02:00
Preetha Appan 5b6f0504ae Move members command to its own package 2017-10-18 00:08:45 +02:00
Preetha Appan ba546b0c1d Move maint command to its own package 2017-10-18 00:08:45 +02:00
Preetha Appan ff4d070bdf Move lock command to its own package 2017-10-18 00:08:45 +02:00
Preetha Appan 85bc32f8a0 Fix leave and validate commands to build help string in constructor 2017-10-18 00:08:45 +02:00
Preetha Appan 71887d1709 Fix KV CLI subcommands to build help string in constructor 2017-10-18 00:08:45 +02:00
Preetha Appan b1d5f99a58 Fix Keyring and keygen commands to build help string in constructor 2017-10-18 00:08:45 +02:00
Preetha Appan 85a834d008 Fix join command to build help string in constructor 2017-10-18 00:08:45 +02:00
Preetha Appan a049dccd20 Fix up info and forceleave to build help string in constructor 2017-10-18 00:08:45 +02:00
Preetha Appan 55a1724b9e s/initFlags/init/g 2017-10-18 00:08:45 +02:00
Preetha Appan 7689e1e5cd Fix exec and event commands to build help string in constructor 2017-10-18 00:08:45 +02:00
Preetha Appan a2519fb76f Fix up catalog list services to build help string in constructor 2017-10-18 00:08:45 +02:00
Preetha Appan 2ed2c63a26 Fix up list datacenters to build help string in constructor 2017-10-18 00:08:45 +02:00
Preetha Appan 9d52f6ea92 Fix tests by calling initFlags for each test case to reset state. 2017-10-18 00:08:45 +02:00
Preetha Appan 4e31514df8 Better name for usage string and moving constant definition down 2017-10-18 00:08:45 +02:00
Preetha Appan a3863c73d6 Construct the help string in constructor using helper function. 2017-10-18 00:08:45 +02:00
Frank Schroeder 0ec520582d commands: move catalog list services to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 117305eb4f commands: move catalog list nodes command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder bd73c4cecf commands: move catalog list datacenters command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 675e727224 commands: move catalog command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 9a9e5ef82d commands: move leave command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 076361a37d commands: move force-leave command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 631502009d commands: move keyring command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 9e19207918 commands: move kv put command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 3377f46085 commands: move kv get command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder e1785a0e8f commands: move kv import command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder cce364445e commands: move export entry struct to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 585b5b8d4e commands: move kv export command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 5e3371eee1 commands: move kv delete command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 200199a875 commands: move kv command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder aca803ca8d commands: move keygen command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder b1c5ee39a5 commands: move info command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 8a5836368e commands: move rExec helper to bottom 2017-10-18 00:08:45 +02:00
Frank Schroeder 0ada23f92f commands: move exec command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder 85bfd8f339 commands: move event command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder d870c6289b commands: move join command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder e0551b80a6 commands: move validate command to separate pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder cef6a80ae6 commands: move flag handling into flags pkg 2017-10-18 00:08:45 +02:00
Frank Schroeder a49711b8bf 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 85e4aea9d1 Replace time.Now().Sub(x) with time.Since(x) 2017-10-17 20:38:24 +02:00
James Phillips 575d70aaa7
Cleans up some drift between the OSS and Enterprise trees. 2017-10-11 15:53:07 -07:00
Frank Schroeder 7bee8e644d
command: show full help text on usage 2017-10-05 18:17:54 +02:00
Frank Schroeder bb13277ca1 command: do not merge flags in-place 2017-10-05 18:08:35 +02:00
Frank Schroeder e769cd22f6 command: simplify duplicate code 2017-10-05 18:08:35 +02:00
Frank Schroeder a364555121 command: drop hidden flags from base command 2017-10-05 18:08:35 +02:00
Frank Schroeder bc78fa576a command: drop unused hidden flags for 'validate' 2017-10-05 18:08:35 +02:00
Frank Schroeder 497d2702bf
command: drop legacy 'operator raft' tests 2017-10-05 17:56:16 +02:00
Frank Schroeder 4d604c5138 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 3a7fb35fb0 command: don't show confusing error on usage output 2017-10-05 17:29:45 +02:00
Frank Schroeder ce0d03c46a command: drop deprecated 'configtest' command
'configtest' has been replaced with 'validate'
2017-10-05 17:22:34 +02:00
Kyle Havlovitz adf29675f3 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 198ed6076d 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 c728564994
Update metric names and add a legacy config flag 2017-10-04 16:43:27 -07:00
Kyle Havlovitz 787787f904
Split BaseCommand http config into a separate function 2017-09-29 12:26:14 -07:00
Kyle Havlovitz 8b31eef467
Add base command option for hiding generated help for normal args 2017-09-28 18:43:28 -07:00
James Phillips be92c6862d
Returns errors properly from the consul operator raft list-peers command. 2017-09-28 15:37:59 -07:00
Frank Schröder e84c2b2edd 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 3c4a108769 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 73951d8319 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 45646ac3f4 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 a286ad7533 Enforce json or hcl extension to Consul config files, updated unit tests 2017-09-25 17:17:12 -05:00
Frank Schröder 12216583a1 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 00605c0214
Shows the segment name in the keyring API and command output. 2017-09-07 12:17:39 -07:00
James Phillips d12b172a5d
Remaps servers to "<all>" only when listing multiple segments. 2017-09-05 13:50:38 -07:00
James Phillips 1a117ba0a8
Makes the all segments query explict, and the default for `consul members`. 2017-09-05 12:22:20 -07:00
James Phillips 74d635e9c6
Simplifies members command to not fetch segments. 2017-09-05 11:46:44 -07:00
Kyle Havlovitz f8261330f0
Remove duplicate error message 2017-09-01 10:18:43 -07:00
Kyle Havlovitz 62102a537e
Organize segments for a cleaner split between enterprise and OSS 2017-08-31 17:39:46 -07:00
Kyle Havlovitz 7e565d7338
Fix some inconsistencies with segment logic and comments 2017-08-30 17:43:46 -07:00
Kyle Havlovitz 21513b0393
Update coord display in ui to account for segments 2017-08-30 11:58:29 -07:00
Kyle Havlovitz d129767657
Add agent.segment interpolation to prepared queries 2017-08-30 11:58:29 -07:00
Kyle Havlovitz 2ada0439d4
Add rpc_listener option to segment config 2017-08-30 11:58:29 -07:00
James Phillips b1a15e0c3d
Adds open source side of network segments (feature is Enterprise-only). 2017-08-30 11:58:29 -07:00
Frank Schroeder 831d84c940 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 d6729243eb fix command/kv_import.go help text (#3387) 2017-08-10 09:17:37 +02:00
Frank Schröder 4b642fed2f agent: honor deprecated flags for retry-join-{ec2,azure,gce} (#3384) 2017-08-09 16:18:30 -07:00
Frank Schroeder 1acff3533e
agent: move agent/consul/structs to agent/structs 2017-08-09 14:32:12 +02:00
Kyle Havlovitz d5634fe2a8
Add support for labels/filters from go-metrics 2017-08-08 01:45:10 -07:00
Frank Schroeder 2fac427cd4 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 840749db7e Fix comments, and remove redundant TestConfig init from a couple of unit tests 2017-07-28 10:40:43 -05:00
Preetha Appan aa98aeb4b1 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 25acd1534a 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 08a8d9f2a7 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 9268849d11
Add UpgradeVersionTag to autopilot get/set commands 2017-07-18 14:01:04 -07:00
James Phillips 1791d99a10 Adds new config to make script checks opt-in, updates documentation. (#3284) 2017-07-17 11:20:35 -07:00
James Phillips 86918be323
Sort tags so output is deterministic. 2017-07-14 17:00:08 -07:00
Seth Vargo afd83a9705 Add catalog CLI functions (#3204) 2017-07-14 12:45:08 -07:00
Frank Schroeder 406dc2ead8 command: make TestExecCommandRun_CrossDC more resilient
Wait after WAN join that both members see each other.
2017-07-07 09:22:34 +02:00