Commit Graph

14219 Commits

Author SHA1 Message Date
Michael Schurter
55cbbded6c logmon: fix reattach configuration
There were multiple bugs here:

1. Reattach unmarshalling always returned an error because you can't
   unmarshal into a nil pointer.
2. The hook data wasn't being saved because it was put on the request
   struct, not the response struct.
3. The plugin configuration should only have reattach *or* a command
   set. Not both.
4. Setting Done=true meant the hook was never re-run on agent restart so
   reattaching was never attempted.
2019-02-21 15:32:18 -08:00
Michael Schurter
4119767be8 fingerprint: improve initial fingerpint message
The initial fingerprint message is actually fairly useful, so I bumped
it to Debug and fixed the output formatting.
2019-02-21 15:32:18 -08:00
Michael Schurter
c9fe5d26b3 plugins: squelch context Canceled error logs
As far as I can tell this is the most straightforward and resilient way
to skip error logging on context cancellation with grpc streams. You
cannot compare the error against context.Canceled directly as it is of
type `*status.statusError`. The next best solution I found was:

```go
resp, err := stream.Recv()
if code, ok := err.(interface{ Code() code.Code }); ok {
	if code.Code == code.Canceled {
		return
	}
}
```

However I think checking ctx.Err() directly makes the code much easier
to read and is resilient against grpc API changes.
2019-02-21 15:32:18 -08:00
Michael Schurter
234f644b35 Merge pull request #5322 from hashicorp/b-artifact-retries
Fix regression by restarting on artifact download errors
2019-02-21 15:28:51 -08:00
Omar Khawaja
cc328c73bf reformat lxc guide (#5339)
* reformat lxc guide

* reformat lxc guide
2019-02-21 17:40:22 -05:00
Michael Schurter
2bc31722e8 Merge pull request #5348 from hashicorp/docs-env-json
docs: clarify use of toJSON for passwords
2019-02-21 14:36:28 -08:00
Mahmood Ali
55ee03a2ad Merge pull request #5341 from hashicorp/ci-windows-docker
Run Docker tests in Windows AppVeyor CI
2019-02-21 13:17:33 -05:00
Michael Schurter
26cb9b3713 docs: clarify use of toJSON for passwords
Fixes #5347
2019-02-21 09:47:18 -08:00
Danielle Tomlinson
92a3cecd04 Merge pull request #5332 from hashicorp/dani/docker_logger_container_leak
docker: Avoid leaking containers during Reattach
2019-02-20 22:53:06 +01:00
Michael Schurter
6257f0d507 Merge pull request #5336 from hashicorp/test-ar-destroy
tests: port TestAllocRunner_Destroy from 0.8
2019-02-20 13:07:51 -08:00
Michael Schurter
159266ccec tests: port TestAllocRunner_Destroy from 0.8
Also add destroy(ar) helper to fix a bunch of shutdown races in AR
tests.
2019-02-20 12:35:09 -08:00
Danielle Tomlinson
df57099e6f docker: Avoid leaking containers during Reattach
Currently if a docker_logger cannot be reattached to, we will leak the
container that was being used. This is problematic if e.g using static
ports as it means you can never recover your task, or if a service is
expensive to run and will then be running without supervision.
2019-02-20 17:47:06 +01:00
Michael Schurter
1acd4ca744 client: don't redownload completed artifacts on retries
Track the download status of each artifact independently so that if only
one of many artifacts fails to download, completed artifacts aren't
downloaded again.
2019-02-20 08:45:12 -08:00
Danielle Tomlinson
2b54e2e0a9 Merge pull request #5335 from hashicorp/dani/docker-logger-spawn
Increase resiliency of docker driver logging
2019-02-20 17:16:05 +01:00
Michael Schurter
bc96455b13 Update drivers/docker/docklog/docker_logger.go
Co-Authored-By: dantoml <dani@tomlinson.io>
2019-02-20 17:12:56 +01:00
Danielle Tomlinson
274a3485b2 docker: Respawn docker logger during recovery
Sometimes the nomad docker_logger may be killed by a service manager
when restarting the client for upgrades or reliability reasons.

Currently if this happens, we leak the users container and try to
reschedule over it.

This commit adds a new step to the recovery process that will spawn a
new docker logger process that will fetch logs from _the current
timestamp_. This is to avoid restarting users tasks because our logging
sidecar has failed.
2019-02-20 17:12:56 +01:00
Michael Schurter
c51a54cfee client: artifact errors are retry-able
0.9.0beta2 contains a regression where artifact download errors would
not cause a task restart and instead immediately fail the task.

This restores the pre-0.9 behavior of retrying all artifact errors and
adds missing tests.
2019-02-20 07:21:27 -08:00
Michael Schurter
83979252cd tests: add new task runner test helper
Adds a new helper and removes a duplicated test.
2019-02-20 07:21:27 -08:00
Danielle Tomlinson
a1d28c978a Merge pull request #5342 from hashicorp/dani/powercolors
Fix colored terminal output on Windows
2019-02-20 15:13:58 +01:00
Mahmood Ali
d6250ec0d6 tests: IsTravis() -> IsCI()
Replace IsTravis() references that is intended for more CI environments
rather than for Travis environment specifically.
2019-02-20 08:21:03 -05:00
Mahmood Ali
e7fbdf4032 ci: Run Docker tests on AppVeyor Windows 2019-02-20 08:21:03 -05:00
Danielle Tomlinson
ed9818a570 ui: Support colored output on Windows
This commit uses the go-colorable library to enable support for coloured
UI output on Windows. This acts as a compatibility layer that takes
standard unix-y terminal codes and translates them into the requisite
windows calls as required.
2019-02-20 14:01:35 +01:00
Danielle Tomlinson
638be7b7b0 vendor: Update to latest go-colorable 2019-02-20 13:56:15 +01:00
Mahmood Ali
8104e2c141 driver/docker: Skip failing Windows tests
Skip currently Docker tests that fail on Windows for further
investigation.
2019-02-20 07:48:02 -05:00
Mahmood Ali
2af30fb441 tests: expect Docker on AppVeyor
Prepare to run docker on AppVeyor Windows environment
2019-02-20 07:41:47 -05:00
Mahmood Ali
153337347c Merge pull request #5321 from hashicorp/b-portmap-regression
drivers: restore port_map old json support
2019-02-19 20:58:37 -05:00
Mahmood Ali
eb5355e093 driver/docker: use BlockAttrs for storage_opts
storage_opts is a new field in 0.9 cycle and doesn't have backward
compatibility constraints.
2019-02-19 20:35:28 -05:00
Mahmood Ali
bd90b8db77 CVE-2019-5736: Update libcontainer depedencies (#5334)
* CVE-2019-5736: Update libcontainer depedencies

Libcontainer is vulnerable to a runc container breakout, that was
reported as CVE-2019-5736[1].  Upgrading vendored libcontainer with the fix.

The runc changes are captured in 369b920277 .

[1] https://seclists.org/oss-sec/2019/q1/119
2019-02-19 20:21:18 -05:00
Omar Khawaja
e128f5b4da adding dropdown nav to external plugins section (#5338) 2019-02-19 17:00:03 -05:00
Michael Schurter
aaa6db6090 Merge pull request #5329 from hashicorp/b-health-deadline
client: fix setting alloc unhealthy at deadline
2019-02-19 08:40:53 -08:00
Michael Schurter
7b8ec414a3 client: fix setting alloc unhealthy at deadline
During the 0.9 client refactor the code to fail a deployment when the
deadline was reached was broken. This restores and tests that behavior.
2019-02-19 07:44:14 -08:00
Danielle Tomlinson
2db90bfccc dlogger: Increase resilience to docker api failure
This commit adds some extra resiliency to the docker logger in the case
of API failure from the docker daemon, by restarting the stream from the
current point in time if the stream returns and the container is still
running.
2019-02-19 15:17:54 +01:00
Charlie Voiselle
427ab71b47 Warn that data_dir can't be in the jail (#4618) 2019-02-18 20:40:45 -05:00
Mahmood Ali
196d0374b7 Fix device.attr typo (#5331)
Fix https://github.com/hashicorp/nomad/issues/5315
2019-02-16 13:07:02 -05:00
Mahmood Ali
afb0c5ac45 drivers: restore port_map old json support
This ensures that `port_map` along with other block like attribute
declarations (e.g. ulimit, labels, etc) can handle various hcl and json
syntax that was supported in 0.8.

In 0.8.7, the following declarations are effectively equivalent:

```
// hcl block
port_map {
  http = 80
  https = 443
}

// hcl assignment
port_map = {
  http  = 80
  https = 443
}

// json single element array of map (default in API response)
{"port_map": [{"http": 80, "https": 443}]}

// json array of individual maps (supported accidentally iiuc)
{"port_map: [{"http": 80}, {"https": 443}]}
```

We achieve compatbility by using `NewAttr("...", "list(map(string))",
false)` to be serialized to a `map[string]string` wrapper, instead of using
`BlockAttrs` declaration.  The wrapper merges the list of maps
automatically, to ease driver development.

This approach is closer to how v0.8.7 implemented the fields [1][2], and
despite its verbosity, seems to perserve 0.8.7 behavior in hcl2.

This is only required for built-in types that have backward
compatibility constraints.  External drivers should use `BlockAttrs`
instead, as they see fit.

[1] https://github.com/hashicorp/nomad/blob/v0.8.7/client/driver/docker.go#L216
[2] https://github.com/hashicorp/nomad/blob/v0.8.7/client/driver/docker.go#L698-L700
2019-02-16 11:37:33 -05:00
Preetha
de52d87dc9 Merge pull request #5324 from hashicorp/f-nomad-init
expand job init example with spread and affinity
2019-02-14 14:58:10 -06:00
Preetha Appan
9fc94b33a1 fix indentation 2019-02-14 12:49:26 -06:00
Preetha Appan
7d92831217 Fix whitespace 2019-02-14 12:49:26 -06:00
Chris Baker
236101f193 Update job_init.go
minor
2019-02-14 12:49:26 -06:00
Preetha Appan
7beb4ccd9c expand job init example with spread and affinity 2019-02-14 12:49:26 -06:00
Michael Schurter
3d41a54ac3 Merge pull request #5319 from hashicorp/test-port-08
Fix Consul Service PreKill Hook
2019-02-14 10:18:41 -08:00
Danielle Tomlinson
0df5cb6b40 Merge pull request #5326 from hashicorp/dani/json-submission
api: Fix compatibility with pre 0.9 API jobs
2019-02-14 18:56:13 +01:00
Mahmood Ali
7f56423c66 Update drivers/docker/config_test.go
Co-Authored-By: dantoml <dani@tomlinson.io>
2019-02-14 18:55:10 +01:00
Danielle Tomlinson
756e733dbc Merge pull request #5327 from hashicorp/dani/windows-term
drivers/docker: SIGTERM to stop containers
2019-02-14 18:05:28 +01:00
Danielle Tomlinson
79d5a246f8 Add regression test for parsing null mounts 2019-02-14 18:03:35 +01:00
Mahmood Ali
eb8b19ec82 test: improve readability of duration
Co-Authored-By: schmichael <michael.schurter@gmail.com>
2019-02-14 08:12:06 -08:00
Mahmood Ali
a96cc97389 test: improve failure message
Co-Authored-By: schmichael <michael.schurter@gmail.com>
2019-02-14 08:11:37 -08:00
Danielle Tomlinson
e2244cd0d4 drivers/docker: SIGTERM to stop containers
Windows Docker daemon does not support SIGINT, SIGTERM is the semantic
equivalent that allows for graceful shutdown before being followed up by
a SIGKILL.
2019-02-14 15:38:54 +00:00
Danielle Tomlinson
a8ddf64e94 vendor: Update to latest hcl2
* Includes fixes for handling null blocks https://github.com/hashicorp/hcl2/pull/87
* Updates go-cty as a newer version is required by hcl2
2019-02-14 13:34:46 +01:00
Michael Schurter
fa9537f6e9 tests: port TestTaskRunner_Download_List from 0.8 2019-02-12 15:48:04 -08:00