Commit Graph

49 Commits

Author SHA1 Message Date
Mahmood Ali
67880310a1 backend: support WS authentication handshake in alloc/exec
The javascript Websocket API doesn't support setting custom headers
(e.g. `X-Nomad-Token`).  This change adds support for having an
authentication handshake message: clients can set `ws_handshake` URL
query parameter to true and send a single handshake message with auth
token first before any other mssage.

This is a backward compatible change: it does not affect nomad CLI path, as it
doesn't set `ws_handshake` parameter.
2020-04-03 11:18:54 -04:00
Mahmood Ali
7a38784244 acl: check ACL against object namespace
Fix a bug where a millicious user can access or manipulate an alloc in a
namespace they don't have access to.  The allocation endpoints perform
ACL checks against the request namespace, not the allocation namespace,
and performs the allocation lookup independently from namespaces.

Here, we check that the requested can access the alloc namespace
regardless of the declared request namespace.

Ideally, we'd enforce that the declared request namespace matches
the actual allocation namespace.  Unfortunately, we haven't documented
alloc endpoints as namespaced functions; we suspect starting to enforce
this will be very disruptive and inappropriate for a nomad point
release.  As such, we maintain current behavior that doesn't require
passing the proper namespace in request.  A future major release may
start enforcing checking declared namespace.
2019-10-08 12:59:22 -04:00
Chris Baker
77619b6b63 api: return X-Nomad-Index header on allocation stop 2019-06-21 16:20:06 +00:00
Chris Baker
7bc951237b alloc lifecycle: 404 when attempting to stop non-existent allocation 2019-06-20 21:27:22 +00:00
Danielle Lancashire
023d0dff31 allocs: Add nomad alloc signal command
This command will be used to send a signal to either a single task within an
allocation, or all of the tasks if <task-name> is omitted. If the sent signal
terminates the allocation, it will be treated as if the allocation has crashed,
rather than as if it was operator-terminated.

Signal validation is currently handled by the driver itself and nomad
does not attempt to restrict or validate them.
2019-04-25 12:43:32 +02:00
Danielle Lancashire
bb142af5d6 allocs: Add nomad alloc stop
This adds a `nomad alloc stop` command that can be used to stop and
force migrate an allocation to a different node.

This is built on top of the AllocUpdateDesiredTransitionRequest and
explicitly limits the scope of access to that transition to expose it
under the alloc-lifecycle ACL.

The API returns the follow up eval that can be used as part of
monitoring in the CLI or parsed and used in an external tool.
2019-04-23 12:50:23 +02:00
Danielle Lancashire
419d70c5f9 allocs: Add nomad alloc restart
This adds a `nomad alloc restart` command and api that allows a job operator
with the alloc-lifecycle acl to perform an in-place restart of a Nomad
allocation, or a given subtask.
2019-04-11 14:25:49 +02:00
Mahmood Ali
f9295631c4 Set clean config for mock driver
The default job here contains some exec task config (for setting
command and args) that aren't used for mock driver.  Now, the alloc
runner seems stricter about validating fields and errors on unexpected
fields.

Updating configs in tests so we can have an explicit task config
whenever driver is set explicitly.
2018-11-13 10:21:40 -05:00
Michael Schurter
4d1a1ac5bb tests: test logs endpoint against pending task
Although the really exciting change is making WaitForRunning return the
allocations that it started. This should cut down test boilerplate
significantly.
2018-10-16 16:56:55 -07:00
Alex Dadgar
40d095fd1a agent + consul 2018-09-13 10:43:40 -07:00
Alex Dadgar
09b90e4944 Actually disable the schedulers 2018-05-31 13:11:11 -07:00
Alex Dadgar
96b366cda2 Disable schedulers for TestHTTP_AllocSnapshot_Atomic 2018-05-31 12:05:44 -07:00
Preetha Appan
51a5b592c5 Fix failing test TestClientStatusRequest 2018-05-30 15:11:54 -05:00
Preetha Appan
6b192593a1 Fix failing test TestHTTP_AllocAllGC 2018-05-30 15:11:54 -05:00
Alex Dadgar
d10e155e0f Fix alloc watcher snapshot streaming 2018-03-27 11:14:53 -07:00
Josh Soref
e7fc3bd16b spelling: propagated 2018-03-11 18:39:26 +00:00
Alex Dadgar
4f332ff1c2 feedback and rebasing 2018-02-15 13:59:03 -08:00
Alex Dadgar
0fb2b5c3f3 HTTP agent 2018-02-15 13:59:03 -08:00
Alex Dadgar
a80ef65291 Code review feedback 2018-02-15 13:59:02 -08:00
Alex Dadgar
d15bb76538 Refactor 2018-02-15 13:59:00 -08:00
Michael Schurter
50b335f3f0 Add comment and normalize err check ordering
as per PR comments
2017-11-29 17:26:11 -08:00
Michael Schurter
e3256ec4ee Check for error file when receiving snapshots 2017-11-29 17:26:11 -08:00
Michael Schurter
a05862dbdf Destroy partially migrated alloc dirs
Test that snapshot errors don't return a valid tar currently fails.
2017-11-29 17:26:11 -08:00
Preetha Appan
bbeb658831 Populate DisplayMessage in various http endpoints that return allocations, plus unit tests. 2017-11-17 14:53:26 -06:00
Michael Schurter
f6f8c3dafd Test fixes from #3383 2017-10-13 15:45:35 -07:00
Alex Dadgar
b4ebc69dc7 Small fixes
This commit:

* Fixes the error checking in migration tests now that we are using the
canonical ErrPermissionDenied error
* Guard against NPE when looking up objects to generate the migration
token
* Handle an additional case in ShouldMigrate()
2017-10-11 17:13:50 -07:00
Chelsea Holland Komlo
1b6f6e598a fixups from code review
change creation of a migrate token to be for a previous allocation
2017-10-11 17:13:50 -07:00
Chelsea Holland Komlo
76b2c50dbc fix up build warnings 2017-10-11 17:11:57 -07:00
Chelsea Holland Komlo
5e0da10bcd adding migration token validation for gc endpoint 2017-10-11 17:11:57 -07:00
Chelsea Holland Komlo
919bd2072d adding valid case test for http endpoint 2017-10-11 17:09:20 -07:00
Chelsea Holland Komlo
38f8217ea0 add tests for functionality 2017-10-11 17:09:20 -07:00
Michael Schurter
a4026229ab /v1/client/allocation/./{stats,gc} ACL enforcement 2017-10-09 12:13:52 -07:00
Michael Schurter
e83cece0d6 /v1/client/gc ACL enforcement 2017-10-06 14:50:16 -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
Alex Dadgar
248c069652 Merge pull request #2128 from hashicorp/f-dispatch
Nomad Constructor Jobs and Dispatch
2017-01-06 05:22:49 +08:00
Diptanu Choudhury
e42ce28ae7 Added two tests 2016-12-20 14:27:38 -08:00
Alex Dadgar
e495eecece Rename structs 2016-12-14 14:28:43 -08:00
Alex Dadgar
9dc2f63240 agent tests 2016-12-01 16:27:22 -08:00
Diptanu Choudhury
dd3af85114 Adding a snapshot endpoint on the client (#1730) 2016-09-21 21:28:12 -07:00
Diptanu Choudhury
c18e431298 Fixed more tests 2016-07-25 17:31:40 -07:00
Diptanu Choudhury
03c6692f98 Fixed some bugs 2016-07-25 17:26:38 -07:00
Diptanu Choudhury
f1a534874d Fixed a test 2016-05-31 01:58:32 +02:00
Diptanu Choudhury
0782803543 Added a test for alloc stats api endpoint 2016-05-28 19:59:20 -07:00
Ivo Verberk
62951082e2 Improvements for short identifiers
* Fix tests
* Update documentation
2016-01-06 22:46:57 +01:00
Ivo Verberk
905742249e Refactoring continued
* Refactor other cli commands to new design
* Add PrefixList method to api package
* Add more tests
2015-12-24 20:53:37 +01:00
Armon Dadgar
c27a0725cc nomad: cleanup API descrepencies 2015-09-06 20:47:42 -07:00
Armon Dadgar
3770a8929a http: adding alloc lookup endpoint 2015-09-06 15:49:44 -07:00
Armon Dadgar
57a69685a2 http: adding allocs list endpoint 2015-09-06 15:37:21 -07:00