Commit Graph

681 Commits

Author SHA1 Message Date
Ryan Uber 8c1c230ce3 agent: use const for default maintenance reason strings 2015-01-21 14:53:52 -08:00
Ryan Uber 5cd8800b60 agent: fix test 2015-01-21 14:12:18 -08:00
Ryan Uber a51ab988a3 command: more maint command tests 2015-01-21 13:49:10 -08:00
Ryan Uber a96cfc9cc3 command: test maint command 2015-01-21 13:37:32 -08:00
Ryan Uber 718cd94b50 agent: prevent duplicate error messages for maintenance api 2015-01-21 13:28:26 -08:00
Ryan Uber 8081403ad9 command: maint command works 2015-01-21 13:11:23 -08:00
Ryan Uber 515ef304e0 command: starting maint command 2015-01-21 13:00:14 -08:00
Ryan Uber d65f4035b9 agent: support passing ?reason= for custom notes field values on maintenance checks 2015-01-21 12:21:57 -08:00
Ryan Uber 40cfd527cb agent: fix maintenance check ID 2015-01-21 11:03:42 -08:00
Ryan Uber b71ffb1fa3 agent: change node maintenance endpoint 2015-01-21 10:57:44 -08:00
Ryan Uber a498433078 agent: use strconv.ParseBool for parsing maintenance enable flag 2015-01-21 09:53:31 -08:00
Ryan Uber ced676ffc2 agent: comments for new anti-entropy functionality 2015-01-20 21:48:46 -08:00
Ryan Uber 72e750fb00 agent: simplify anti-entropy of services with multiple checks, add tests 2015-01-20 21:48:46 -08:00
Ryan Uber 001d2e246d agent: only send service with check sync if it is out of sync 2015-01-20 21:48:46 -08:00
Ryan Uber 3b2e9d1b90 agent: refactor syncChecks 2015-01-20 21:48:46 -08:00
Ryan Uber 684474af1d agent: support adding multiple checks during service registration from the API 2015-01-20 21:48:45 -08:00
Ryan Uber 27de0adf3b agent: support multiple checks per service 2015-01-20 21:48:42 -08:00
Ryan Uber 9fe1b68f26 agent: use squash mapstructure tag to properly decode embedded structs 2015-01-20 21:10:58 -08:00
Ryan Uber c669a17fa6 agent: use interface for file permissions 2015-01-20 18:53:18 -08:00
Ryan Uber 1e0cd2e499 agent: test permissions are set on rpc socket 2015-01-20 16:57:00 -08:00
Ryan Uber 88af31507f agent: fix tests 2015-01-20 16:50:21 -08:00
Ryan Uber aa58218dfd agent: re-add support for user name in socket perms 2015-01-20 16:21:23 -08:00
Ryan Uber 77c6b86b1e agent: test Unix domain socket permission settings 2015-01-20 14:32:15 -08:00
Ryan Uber 73a111b35d agent: adjusting tests for new behavior of sockets 2015-01-20 14:13:36 -08:00
Ryan Uber c01277725a agent: beginning socket user/group/mode support as discussed in #612 2015-01-20 13:44:27 -08:00
Armon Dadgar a9819e71a8 Fixing merge conflict 2015-01-20 13:01:13 -08:00
Armon Dadgar 2502398481 command/lock: Fixing mixed spaces and tabs 2015-01-20 12:58:29 -08:00
Armon Dadgar c6dbb7e76c command/lock: Adding simple test 2015-01-19 15:47:17 -10:00
Armon Dadgar b52c14d1b2 command/lock: Calculate name, use provided token 2015-01-19 15:38:00 -10:00
Armon Dadgar cdfaaac3ac command/lock: Ensure a conflict between lock and semaphore with shared prefix 2015-01-19 15:26:17 -10:00
Armon Dadgar 1aa8b0fc23 command/lock: First pass at lock 2015-01-19 14:37:48 -10:00
Ryan Uber 9ee9c5acd5 agent: test agent rpc unix socket create failure 2015-01-19 09:56:59 -08:00
Emil Hessman 73ad8fcb84 command: address vet report in test
Fixes the following vet report:

command/rpc_test.go:61: missing argument for Fatalf(%s): format reads arg 3, have only 2 args
2015-01-17 07:57:11 +01:00
Ryan Uber 059866cce6 command: fix up env var/cli arg precedence and tests 2015-01-16 17:45:13 -08:00
Ryan Uber 49127722ec Merge pull request #610 from dave-tucker/bug/609
Don't forget to Shutdown the DNS Server!
2015-01-16 16:46:37 -08:00
Dave Tucker f026b8781e Don't forget to Shutdown the DNS Server!
Fixes #609

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2015-01-17 00:30:53 +00:00
Ryan Uber f29ea9f637 agent: maintenance logging + unique service check IDs 2015-01-16 15:38:13 -08:00
Ryan Uber 6d284052fc agent: test node maintenance mode 2015-01-16 15:38:13 -08:00
Ryan Uber 8ea9eb87ea agent: node maintenance mode works 2015-01-16 15:38:13 -08:00
Ryan Uber 3b815cd0aa agent: maintenance mode api's are idempotent 2015-01-16 15:37:52 -08:00
Ryan Uber 8a4a8eb023 agent: maintenance mode is persistent 2015-01-16 15:37:52 -08:00
Ryan Uber 9ceb0f19d8 agent: test http endpoints for maintenance mode 2015-01-16 15:37:51 -08:00
Ryan Uber 7d4801db29 agent: test agent service maintenance mode 2015-01-16 15:37:51 -08:00
Ryan Uber 4f4eb204f6 agent: first pass at service maintenance mode 2015-01-16 15:37:51 -08:00
Ryan Uber 952fac6552 command: fix env var reader for HTTP addr 2015-01-16 14:01:20 -08:00
Ryan Uber 263614d596 agent: error if binding to existing socket file 2015-01-16 12:39:15 -08:00
Ryan Uber 328204f535 agent: test socket file overwrite 2015-01-16 10:37:13 -08:00
Ryan Uber 208b6c0677 command: style fixes for env addr reading 2015-01-16 10:19:04 -08:00
Ryan Uber 705801ccca agent: fixing up tests 2015-01-16 09:58:37 -08:00
Ryan Uber 61d2f71d14 agent: only ignore errors on IsNotExist() 2015-01-16 09:14:52 -08:00
Ryan Uber ad19c0afc2 agent: beginning refactor 2015-01-16 00:45:03 -08:00
Jeff Mitchell 9bd66c70e5 Ensure a socket is created for permissions adjustment tests and fix some
items pointed out in the code review

This code is copyright 2014 Akamai Technologies, Inc. <opensource@akamai.com>
2015-01-15 14:33:44 +00:00
Jeff Mitchell c3707d3ee5 Add a Unix socket RPC test. I modified some code in the testing library to not make assumptions about the listening socket; all RPC tests still pass. Still to do: Unix socket HTTP test.
This code is copyright 2014 Akamai Technologies, Inc. <opensource@akamai.com>
2015-01-14 19:31:21 +00:00
Jeff Mitchell f88536f192 Remove unnecessary ClientListenerAddr function. Rework config test functions to be cleaner. Start of runtime tests.
This code is copyright 2014 Akamai Technologies, Inc. <opensource@akamai.com>
2015-01-14 19:31:21 +00:00
Jeff Mitchell 4838beec4e Tests for populateUnixSocket. Still need to write tests for the other major function, and basic socket listening tests.
This code is copyright 2014 Akamai Technologies, Inc. <opensource@akamai.com>
2015-01-14 19:31:21 +00:00
Jeff Mitchell 400eadd671 RPC and HTTP interfaces fully generically-sockified so Unix is supported.
Client works for RPC; will honor CONSUL_RPC_ADDR. HTTP works via consul/api;
honors CONSUL_HTTP_ADDR.

The format of a Unix socket in configuration data is:
"unix://[/path/to/socket];[username or uid];[gid];[mode]"

Obviously, the user must have appropriate permissions to create the socket
file in the given path and assign the requested uid/gid. Also note that Go does
not support gid lookups from group name, so gid must be numeric. See
https://codereview.appspot.com/101310044

When connecting from the client, the format is just the first part of the
above line:
"unix://[/path/to/socket]"

This code is copyright 2014 Akamai Technologies, Inc. <opensource@akamai.com>
2015-01-14 19:31:21 +00:00
Armon Dadgar f3baa0a113 command/agent: Minor cleanups 2015-01-13 12:18:18 -08:00
Armon Dadgar d80588f780 Merge pull request #592 from nicholascapo/check-http
command/agent: Add simple HTTP check type
2015-01-13 12:11:50 -08:00
Armon Dadgar 1bfe8efbac Merge pull request #595 from ebroder/dns-only-passing
Add "only_passing" option to DNS config
2015-01-13 12:07:22 -08:00
Evan Broder a9ce71e304 Add more thorough testing for only_passing behavior 2015-01-13 14:59:24 +01:00
Nicholas Capo b631c74ac2 command/agent: Add tests for HTTP Check 2015-01-13 00:09:42 +00:00
Ryan Uber 793a7b74aa agent: make dns randomization test more reliable 2015-01-12 16:05:41 -08:00
Nicholas Capo e116c03f86 command/agent: HTTP Check: Create httpClient in Start()
For long (>10s) interval checks the http timeout is 10s, otherwise thetimeout is the interval. This means that a check *should* return
before the next check begins.
2015-01-13 00:01:15 +00:00
Nicholas Capo 27fe823fd2 command/agent: HTTP Check: Include response in check status 2015-01-12 22:35:28 +00:00
Nicholas Capo f26a79c325 command/agent: Stop HTTP checks when the check is removed 2015-01-12 22:34:39 +00:00
Nicholas Capo 1918f39020 command/agent: HTTP check: Any 2xx is OK, 429 is WARNING 2015-01-12 21:58:57 +00:00
Evan Broder b5e1de165b Add "only_passing" option to DNS config
This excludes nodes from DNS results if their healthchecks are in any
non-passing state, not just if they're critical.
2015-01-10 13:17:11 +01:00
Ryan Uber 44efa3cca4 agent: fix local_test.go 2015-01-09 16:44:12 -08:00
Ryan Uber 12cd27e588 agent: wrap deferred anti-entropy sync test in WaitForResult 2015-01-09 16:42:44 -08:00
Nicholas Capo f2649edcfc command/agent: Add simple HTTP check type
These checks make an `HTTP GET` request every Interval to the specified URL.
The status of the service depends on the HTTP Response Code.
`200` is passing, `503` is warning and anything else is failing.
2015-01-09 16:43:24 -06:00
Armon Dadgar 0b9f4d7153 agent: Testing the KV DELETE with cas 2015-01-08 17:31:32 -08:00
Armon Dadgar 7ec294597e agent: Support the ?cas parameter to KV DELETE 2015-01-08 17:08:58 -08:00
Armon Dadgar 04d89d8ce2 agent: Testing anti-entropy with service address 2015-01-08 12:02:04 -08:00
Armon Dadgar 3689b82cf4 agent: Adding test for DNS lookup with service address 2015-01-08 11:58:32 -08:00
Armon Dadgar 0164de5f44 agent: Fix de-duplication of SRV with service address 2015-01-08 10:47:41 -08:00
Armon Dadgar 957fa1f5ec consul: Fixing merge conflict 2015-01-08 10:42:19 -08:00
Armon Dadgar 7d9697dcf3 agent: Testing reverse lookup with custom TLD 2015-01-08 10:24:49 -08:00
dankennedy 3c43e0440f replaced consul domain with configured domain. Fixes #582 2015-01-08 10:16:05 +00:00
Ryan Uber 86bcef81b5 agent: test service and check unloading 2015-01-07 22:32:14 -08:00
Ryan Uber 770bb60af8 agent: consolidate service loading code, better logging 2015-01-07 22:01:43 -08:00
Ryan Uber 33bd157a61 agent: separate service and check loading/unloading concerns 2015-01-07 22:01:20 -08:00
Ryan Uber dea0070a39 agent: persist service/check data using hashed service/check IDs (fixes #573) 2015-01-07 19:11:21 -08:00
Ryan Uber 7ecd015fc0 command: check LastIndex is not zero while waiting for leader 2015-01-07 15:18:00 -08:00
Armon Dadgar b429c22bfb command/exec: Use TTL for local and foreign 2015-01-07 14:27:29 -08:00
Armon Dadgar 615b0d6b97 command/exec: Support foreign datacenters 2015-01-07 14:22:40 -08:00
Ryan Uber babce89299 Merge pull request #581 from hashicorp/f-consulapi
Bring in consulapi
2015-01-07 12:09:44 -08:00
Ryan Uber 5172b21ee8 api: initial import from armon/consul-api 2015-01-06 10:40:00 -08:00
Ryan Uber 26d6ae0386 Merge pull request #576 from hashicorp/f-verify-config
agent: reject config with invalid options
2015-01-05 14:51:28 -08:00
Daniel Malon 1889841acd use the service specific address in SRV response 2015-01-05 22:48:30 +00:00
Ryan Uber d9136d3411 agent: use mapstructure's Metadata.Unused to detect extraneous config 2015-01-05 14:41:19 -08:00
Ryan Uber 25fb18b1cf agent: reject config with invalid options 2015-01-05 12:30:03 -08:00
Armon Dadgar 1088a5c170 Merge pull request #558 from ceh/http-api-response-headers
add ability to specify response headers on the HTTP API
2015-01-05 11:36:08 -08:00
Daniel Malon e56b3861dc advertise specific address for a service
Enable setting a specific address in a service definition for advertise. If no specific address is given it will fallback to the node address and reassemble the old behaviour.
2015-01-02 21:10:05 +00:00
Thordur Bjornsson 59d4f20e62 Test both ?pretty both bare and with value. 2015-01-02 09:15:41 +01:00
Thordur Bjornsson 8beb1bb848 handle ?pretty similarly to ?stale, ?consistent etc. 2015-01-02 08:00:08 +01:00
Ryan Uber 92e9e138b9 agent: test pretty printed json 2015-01-01 14:27:10 -08:00
Emil Hessman db23a3f0e9 add ability to specify response headers on the HTTP API
Add an config object that allows adding HTTP header response fields to every
HTTP API response.

Each specified header is added to every response from all HTTP API endpoints.
Each individual endpoint may overwrite the specified header, which makes sure
that Consul headers such as 'X-Consul-Index' is enforced by the API.
2014-12-28 19:17:08 +01:00
Ryan Breen b97a35234d Clean up log line and reduce test time. 2014-12-18 09:00:51 -05:00
Ryan Breen d415219cd5 Test that staggered checks run within the defined interval. 2014-12-17 22:39:11 -05:00
Ryan Breen 3b77bb7682 Well, that sure is cleaner. 2014-12-17 22:24:41 -05:00
Ryan Breen 3cb88d0a4f Add a randomized start before running CheckMonitors. 2014-12-17 21:44:12 -05:00
lalyos 3823a931c6 Add default rpc address configuration option as CONSUL_RPC_ADDR env variable
Similar as in serf: https://github.com/hashicorp/serf/pull/210
2014-12-16 12:18:34 +01:00
Armon Dadgar 9b897d1134 consul: Ignore zero ttl on session 2014-12-12 19:17:04 -08:00
Armon Dadgar 8dbfe7c9a8 Merge pull request #524 from amalaviy/session_ttl
Consul Session TTLs
2014-12-12 14:42:25 -08:00
Atin Malaviya 5a76929ba4 Fixed clearSessionTimer, created invalidateSession, added invalid TTL test 2014-12-11 05:34:31 -05:00
Atin Malaviya 7ece29c3e0 Took out usage of snapshot SessionListTTL 2014-12-10 21:37:06 -05:00
Atin Malaviya e84b26fcf5 Remove hardcoded wait time in session TTL tests 2014-12-10 21:04:09 -05:00
Atin Malaviya 8369b77204 Clean up code based on feedback from armon 2014-12-10 20:49:06 -05:00
Atin Malaviya c992c18ef0 Added more tests. Also added return of 404 if the session id to renew is not found 2014-12-10 10:02:23 -05:00
Atin Malaviya b623af776b Consul Session TTLs
The design of the session TTLs is based on the Google Chubby approach
(http://research.google.com/archive/chubby-osdi06.pdf). The Session
struct has an additional TTL field now. This attaches an implicit
heartbeat based failure detector. Tracking of heartbeats is done by
the current leader and not persisted via the Raft log. The implication
of this is during a leader failover, we do not retain the last
heartbeat times.

Similar to Chubby, the TTL represents a lower-bound. Consul promises
not to terminate a session before the TTL has expired, but is allowed
to extend the expiration past it. This enables us to reset the TTL on
a leader failover. The TTL is also extended when the client does a
heartbeat. Like Chubby, this means a TTL is extended on creation,
heartbeat or failover.

Additionally, because we must account for time requests are in transit
and the relative rates of clocks on the clients and servers, Consul
will take the conservative approach of internally multiplying the TTL
by 2x. This helps to compensate for network latency and clock skew
without violating the contract.

Reference: https://docs.google.com/document/d/1Y5-pahLkUaA7Kz4SBU_mehKiyt9yaaUGcBTMZR7lToY/edit?usp=sharing
2014-12-07 12:38:22 -05:00
Ali Abbas 154c4e93e4 since dns.TXT is an external dependency, it is safer to add keys to the fields to avoid some potential ordering issues if changes in this field occur with upstream 2014-12-06 13:13:35 +01:00
Ali Abbas 0117529781 remove control flow on errExit by switching from bool to int 2014-12-06 12:50:38 +01:00
Chavez 7c1aad7b1d agent: agent test fixes 2014-12-05 10:36:44 -08:00
Veres Lajos 850d5bdc32 typofixes - https://github.com/vlajos/misspell_fixer 2014-12-04 23:25:06 +00:00
Armon Dadgar b10159a87b agent: Handle service ACLs when doing anti-entropy 2014-12-01 11:43:01 -08:00
Ryan Uber 42bad4af80 agent: fixup all check definitions from json config 2014-11-30 18:27:37 -08:00
Ryan Uber 9e52588cec agent: persist CheckType with health checks 2014-11-29 12:54:37 -08:00
Ryan Uber 4f14ba6326 agent: allow config reload to modify checks/services persistence
This change consolidates loading services and checks from both config
and persisted state into methods on the agent. As part of this, we
introduce optional persistence when calling RemoveCheck/RemoveService.

Fixes a bug where config reloads would kill persisted services/checks.
Also fixes an edge case:

1. A service or check is registered via the HTTP API
2. A new service or check definition with the same ID is added to config
3. Config is reloaded

The desired behavior (which this implements) is:

1. All services and checks deregistered in memory
2. All services and checks in config are registered first
3. All persisted checks are restored using the same logic as the agent
   start sequence, which prioritizes config over persisted, and removes
   any persistence files if new config counterparts are present.
2014-11-26 12:46:42 -08:00
Ali Abbas ecac719bb8 fix Sprintf formatting 2014-11-25 20:06:33 +01:00
Ali Abbas 73504a01e9 cleanup unreachable code 2014-11-25 19:54:30 +01:00
Ryan Uber fe119a1bd2 agent: prefer config over persisted services/checks (#497) 2014-11-24 19:40:53 -08:00
Armon Dadgar 746c52644b Merge pull request #497 from hashicorp/f-persist
Persist locally registered services and checks
2014-11-24 11:14:08 -08:00
Armon Dadgar 521414f09a agent: Adding TODO for future optimization 2014-11-24 11:09:04 -08:00
Ryan Uber 1f5af52e0b agent: pass error through when writing state files 2014-11-24 01:58:39 -08:00
Ryan Uber ce0d27caba agent: default restored checks to critical status 2014-11-24 01:15:18 -08:00
Ryan Uber e3c2075a9d agent: first pass at local service and check persistence 2014-11-24 01:10:27 -08:00
lalyos adc5d0a522 agent: implementing reverse dns lookup for ipv4 and ipv6 2014-11-23 09:16:37 +01:00
Armon Dadgar b58b35d659 Merge pull request #487 from amalaviy/ephemeral_keys
Ephemeral Nodes for via Session behavior settings.
2014-11-21 10:11:52 -08:00
Ryan Uber 3d4ea8142c agent: make event buffer test non-sequential 2014-11-20 21:56:50 -08:00
Ryan Uber 3f5e0d8ec0 agent: Test event order preservation for watches 2014-11-20 20:35:52 -08:00
Ryan Uber 5badc695b8 agent: Preserve ordering of event buffer. Fixes #479 2014-11-20 19:51:08 -08:00
Atin Malaviya 3aabda02b3 Clean up tests, use switch to default session.Behavior value if unspecified, unrecognized 2014-11-20 14:29:18 -05:00
Atin Malaviya aa0cecd04e Ephemeral Nodes for via Session behavior settings.
Added a "delete" behavior for session invalidation, in addition to
the default "release" behavior. On session invalidation, the sessions
Behavior field is checked and if it is set to "delete", all nodes owned
by the session are deleted. If it is "release", then just the locks
are released as default.
2014-11-20 11:34:45 -05:00
Ryan Uber accf2bbb59 agent: remove unused config variable 2014-11-19 23:18:12 -08:00
Ryan Uber 4cd89a9113 Rebase against upstream 2014-11-19 16:45:49 -08:00
Ryan Uber a675b5faae agent: fix gossip encryption detection 2014-11-19 16:37:40 -08:00
Ryan Uber c9118b53bf agent: fix loading keyring on agent start 2014-11-19 16:37:40 -08:00
Ryan Uber 196cbd27b2 agent: ignore -encrypt if provided when keyring exists 2014-11-19 16:37:40 -08:00
Ryan Uber 3b2ab70c4d consul: clean up comments, fix globalRPC tests 2014-11-19 16:37:40 -08:00
Ryan Uber 2661bbfa27 consul: more tests, remove unused KeyManager() method 2014-11-19 16:37:40 -08:00
Ryan Uber fcacee723b consul: simplify keyring operations 2014-11-19 16:36:19 -08:00
Ryan Uber 00fc7fa1dd command/keyring: adjust command help 2014-11-19 16:36:18 -08:00
Ryan Uber b3f251de9c command/keyring: clean up tests 2014-11-19 16:36:18 -08:00
Ryan Uber f24ac482e3 agent: fix test cases 2014-11-19 16:36:18 -08:00
Ryan Uber bb9617642a agent: make rpc tests more reliable 2014-11-19 16:36:01 -08:00
Ryan Uber d02afd42fb agent: -encrypt appends to keyring if one exists 2014-11-19 16:36:01 -08:00
Ryan Uber 295f876923 command/agent: fix up gossip encryption indicator 2014-11-19 16:35:37 -08:00
Ryan Uber c59107f08e command: remove -init argument from keyring, auto-persist keyrings when using agent -encrypt 2014-11-19 16:35:13 -08:00
Ryan Uber 7f85c708dc agent: squash some more common keyring semantics 2014-11-19 16:34:18 -08:00
Ryan Uber daebf39946 agent: guard against empty keyring files 2014-11-19 16:34:18 -08:00