Commit Graph

47 Commits

Author SHA1 Message Date
Seth Hoenig
f0dff3fada agent: revert use of http connlimit
https://github.com/hashicorp/nomad/pull/9608 introduced the use of the
built-in HTTP 429 response handler provided by go-connlimit. There is
concern though around plausible DOS attacks that need to be addressed,
so this PR reverts that functionality.

It keeps a fix in the tests around the use of an HTTPS enabled client
for when the server is listening on HTTPS. Previously, the tests would
fail deterministically with io.EOF because that's how the TLS server
terminates invalid connections.

Now, the result is much less deterministic. The state of the client
connection and the server socket depends on when the connection is
closed and how far along the handshake was.
2020-12-14 14:40:14 -06:00
Seth Hoenig
26acbf750c client: fix plumbing of testing object into helper 2020-12-10 11:04:38 -06:00
Seth Hoenig
5508e5d8cb client: fix https test cases in client rate limits 2020-12-10 09:20:28 -06:00
Dennis Schön
582d3b7092 use os.ErrDeadlineExceeded in tests 2020-12-07 10:40:28 -05:00
Michael Schurter
0695801256 unify boolean parameter parsing 2020-10-14 12:23:25 -07:00
Michael Schurter
a55f46e9ba api: add field filters to /v1/{allocations,nodes}
Fixes #9017

The ?resources=true query parameter includes resources in the object
stub listings. Specifically:

- For `/v1/nodes?resources=true` both the `NodeResources` and
  `ReservedResources` field are included.
- For `/v1/allocations?resources=true` the `AllocatedResources` field is
  included.

The ?task_states=false query parameter removes TaskStates from
/v1/allocations responses. (By default TaskStates are included.)
2020-10-14 10:35:22 -07:00
Mahmood Ali
d7f14d12c1 Upgrade to golang 1.15 (#8858)
Upgrade to golang 1.15

Starting with golang 1.5, setting Ctty value result in `Setctty set but Ctty not valid in child` error, as part of https://github.com/golang/go/issues/29458 .
This commit lifts the fix in https://github.com/creack/pty/pull/97 .
2020-09-09 15:59:29 -04:00
James Rasell
87d51e6898 api: return custom error if API attempts to decode empty body. 2020-05-19 15:46:31 +02:00
Mahmood Ali
41bec868a8 http: adjust log level for request failure
Failed requests due to API client errors are to be marked as DEBUG.

The Error log level should be reserved to signal problems with the
cluster and are actionable for nomad system operators.  Logs due to
misbehaving API clients don't represent a system level problem and seem
spurius to nomad maintainers at best.  These log messages can also be
attack vectors for deniel of service attacks by filling servers disk
space with spurious log messages.
2020-04-22 16:19:59 -04:00
Yoan Blanc
c3928fe360 fixup! vendor: explicit use of hashicorp/go-msgpack
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-03-31 09:48:07 -04:00
Yoan Blanc
887f23a351 vendor: explicit use of hashicorp/go-msgpack
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-03-31 09:45:21 -04:00
Michael Schurter
f3cf1064d1 test: improve error messages when failing 2020-02-07 15:50:53 -08:00
Michael Schurter
4ed435da05 test: workaround limits race 2020-02-07 15:50:53 -08:00
Michael Schurter
b48a21cc77 test: wait longer than timeout
The 1s timeout raced with the 1s deadline it was trying to detect.
2020-02-07 15:50:53 -08:00
Michael Schurter
e3e1f5cb53 core: add limits to unauthorized connections
Introduce limits to prevent unauthorized users from exhausting all
ephemeral ports on agents:

 * `{https,rpc}_handshake_timeout`
 * `{http,rpc}_max_conns_per_client`

The handshake timeout closes connections that have not completed the TLS
handshake by the deadline (5s by default). For RPC connections this
timeout also separately applies to first byte being read so RPC
connections with TLS enabled have `rpc_handshake_time * 2` as their
deadline.

The connection limit per client prevents a single remote TCP peer from
exhausting all ephemeral ports. The default is 100, but can be lowered
to a minimum of 26. Since streaming RPC connections create a new TCP
connection (until MultiplexV2 is used), 20 connections are reserved for
Raft and non-streaming RPCs to prevent connection exhaustion due to
streaming RPCs.

All limits are configurable and may be disabled by setting them to `0`.

This also includes a fix that closes connections that attempt to create
TLS RPC connections recursively. While only users with valid mTLS
certificates could perform such an operation, it was added as a
safeguard to prevent programming errors before they could cause resource
exhaustion.
2020-01-30 10:38:25 -08:00
Drew Bailey
a3f73b3e06 leave acl checking to rpc endpoints
fix test expectation

test wrapNonJSON
2020-01-09 15:15:08 -05:00
Drew Bailey
c24a631def Merge pull request #6670 from hashicorp/api/fallthrough-test
test rootfallthrough handler
2019-11-13 10:51:31 -05:00
Lars Lehtonen
75476e350d command/agent: Prune Dead Code (#6682)
* remove unused MockPeriodicJob() from tests
* remove unused getIndex() from tests
* remove unused checkIndex() from tests
* remove unused assertIndex() from tests
* remove unused Agent.findLoopbackDevice()
2019-11-13 08:20:01 -05:00
Drew Bailey
e187a7f3f9 fix so assertions are test case driven 2019-11-12 14:28:21 -05:00
Drew Bailey
e84eed84d4 test /ui/ path 2019-11-11 12:12:42 -05:00
Drew Bailey
6ad44f7ea6 test rootfallthrough handler 2019-11-11 12:08:44 -05:00
Michael Schurter
ae61f7308d Fix HTTP code for permission denied errors
Fixes #3697

The existing code and test case only covered the leader behavior. When
querying against non-leaders the error has an "rpc error: " prefix.

To provide consistency in HTTP error response I also strip the "rpc
error: " prefix for 403 responses as they offer no beneficial additional
information (and in theory disclose a tiny bit of data to unauthorized
users, but it would be a pretty weird bit of data to use in a malicious
way).
2018-01-09 15:25:53 -08:00
Chelsea Komlo
fa9fd4422c Nomad agent reload TLS configuration on SIGHUP (#3479)
* Allow server TLS configuration to be reloaded via SIGHUP

* dynamic tls reloading for nomad agents

* code cleanup and refactoring

* ensure keyloader is initialized, add comments

* allow downgrading from TLS

* initalize keyloader if necessary

* integration test for tls reload

* fix up test to assert success on reloaded TLS configuration

* failure in loading a new TLS config should remain at current

Reload only the config if agent is already using TLS

* reload agent configuration before specific server/client

lock keyloader before loading/caching a new certificate

* introduce a get-or-set method for keyloader

* fixups from code review

* fix up linting errors

* fixups from code review

* add lock for config updates; improve copy of tls config

* GetCertificate only reloads certificates dynamically for the server

* config updates/copies should be on agent

* improve http integration test

* simplify agent reloading storing a local copy of config

* reuse the same keyloader when reloading

* Test that server and client get reloaded but keep keyloader

* Keyloader exposes GetClientCertificate as well for outgoing connections

* Fix spelling

* correct changelog style
2017-11-14 17:53:23 -08:00
Alex Dadgar
e1b1465081 Standardize retrieving a free port into a helper package 2017-10-23 16:48:20 -07:00
Alex Dadgar
f1965d6305 Handle invalid token as well 2017-10-12 15:39:05 -07:00
Alex Dadgar
21c2ba33e5 403 instead of 500 for permission denied 2017-10-12 14:10:20 -07:00
Armon Dadgar
b253ad5cfb agent: thread through token for ACL endpoint tests 2017-09-04 13:05:53 -07:00
Armon Dadgar
79420d78cf agent: Adding X-Nomad-Token header parsing 2017-09-04 13:05:53 -07:00
Armon Dadgar
ab5ce9b1a7 nomad: ACL endpoints check support enabled and redirect to authority 2017-09-04 13:05:53 -07:00
Alex Dadgar
99a1162a88 fix http test 2017-08-16 11:01:12 -07:00
Alex Dadgar
a73e945067 More parallel 2017-07-20 09:36:34 -07:00
Alex Dadgar
873587381d New test agent 2017-07-19 22:14:36 -07:00
Michael Schurter
d1d34bf019 Remove extra Travis logging 2017-05-04 17:35:54 -07:00
Michael Schurter
e07235e883 Adding logging for Travis 2017-05-03 15:18:48 -07:00
Michael Schurter
c1d0de5bd2 Don't reuse transport/client 2017-05-03 13:26:55 -07:00
Michael Schurter
26609bc832 Extensively test verify_https_client behavior
verify_https_client support added in #2587
2017-05-02 16:48:16 -07:00
Adam Stankiewicz
4d465091dd Remove unnecessary parameter from NewHTTPServer 2017-04-10 16:24:49 +02:00
Alex Dadgar
723f8f0343 Benchmark 2016-12-09 14:44:50 -08:00
Alex Dadgar
819eaca09e Use codegen for json marshalling: 20% faster, 12% less bytes allocated, 85% less allocations 2016-05-18 09:45:46 -07:00
Sean Chittenden
47146b9b87 Fix the unit tests for TestPrettyPrintOff
A different failing test masked that this wasn't even being run.

Pointy Hat: sean- for testing first on Travis in a branch vs verifying locally
2016-05-11 15:48:43 -07:00
Sean Chittenden
1e8d6eb283 Fix unit tests for TestPrettyPrintBare 2016-05-11 15:20:57 -07:00
Sean Chittenden
534156d9eb Update tests for pretty printing that includes a newline.
Add a test verifying that pretty printing can be disabled, too.
2016-05-11 10:55:01 -07:00
Diptanu Choudhury
6c32119ee7 Allow users to configure arbitrary headers in config 2016-01-22 11:00:43 -08:00
Armon Dadgar
c9d17611bf nomad: rename region1 to global. Fixes #41 2015-09-13 18:18:40 -07:00
Armon Dadgar
352142cdba http/job: adding update endpoint 2015-09-05 19:08:47 -07:00
Armon Dadgar
1a5c0f7826 http: framework jobs endpoints 2015-09-05 18:00:30 -07:00
Armon Dadgar
4783e8d89e http: basic framework 2015-09-05 17:06:05 -07:00