Commit Graph

864 Commits

Author SHA1 Message Date
James Rasell
0726e4cc3e driver/docker: Fix container CPU stats collection (#24768)
The recent change to collection via a "one-shot" Docker API call
did not update the stream boolean argument. This results in the
PreCPUStats values being zero and therefore breaking the CPU
calculations which rely on this data. The base fix is to update
the passed boolean parameter to match the desired non-streaming
behaviour. The non-streaming API call correctly returns the
PreCPUStats data which can be seen in the added unit test.

The most recent change also modified the behaviour of the
collectStats go routine, so that any error encountered results in
the routine exiting. In the event this was a transient error, the
container will continue to run, however, no stats will be collected
until the task is stopped and replaced. This PR reverts the
behaviour, so that an error encountered during a stats collection
run results in the error being logged but the collection process
continuing with a backoff used.
2025-01-07 07:42:31 +00:00
Vincent Ducamps
6469b59a0a docker: Fix a bug where images with port number and no tags weren't parsed correctly 2025-01-03 11:38:43 +01:00
Michael Smithhisler
11ae64acb0 drivers: defer executor cleanup func to fix executor leak (#24495) 2024-12-02 12:25:32 -05:00
Michael Smithhisler
4e2d9675e7 executor: fail early on reattach if listener is not executor (#24538) 2024-12-02 09:56:00 -05:00
Piotr Kazmierczak
3a18f22c18 goflags: go:build linux for tests that won't compile on other platforms (#24559)
I'm a heavy LSP user and I frequently goto:next_error. This confuses my
editor on macOS.
2024-11-28 15:05:00 +01:00
Juana De La Cuesta
a9e7166b6b [gh-24339] Move from streaming stats to polling for docker (#24525)
* fix: dont stream the docker stats, read them one by one

* func: add a NewSafeTicker to the herlper functions

* style: remove commented code
2024-11-21 17:36:53 +01:00
Seth Hoenig
dd396a3900 windows: revert process listing logic to that of v1.6.10 (#24494)
* windows: revert process listing logic to that of v1.6.10

In Nomad 1.7 much of the process management code was refactored, including
a rewrite of how the process tree of an executor was determined on Windows
machines. Unfortunately that rewrite has been cursed with performance issues
and bugs. Instead, revert to the logic used in v1.6.10.

* changelog
2024-11-20 11:20:20 -06:00
Piotr Kazmierczak
5dfb38d806 drivers: fix capabilities on non-linux systems (#24450)
Recently we moved from github.com/syndtr/gocapability to
github.com/moby/sys/capability due to the former package no longer being
maintainer. The new package's capability function works differently: the
known/supported functionality is split now, and the .ListSupported() call will
always return an empty list on non-linux systems. This means Nomad agents won't
start on darwin or windows.
2024-11-13 15:58:25 +01:00
Kir Kolyshkin
d09c8ddf21 deps: switch to moby/sys/capability (#24093)
github.com/moby/sys/capability is a fork of the (no longer maintained)
github.com/syndtr/gocapability package.

For changes since the fork took place, see
https://github.com/moby/sys/blob/main/capability/CHANGELOG.md

Note that the "workaround for RHEL6" is removed for a number of reasons.
Feel free to choose the one you like the most, either is sufficient:

1. /proc/sys/kernel/cap_last_cap is available since RHEL 6.7
   (kernel 2.6.32-573.el6), released 9 years ago (2015-07-22).

2. It incorrectly returns CAP_BLOCK_SUSPEND (36), which was only added
   in kernel v3.5 and was never backported to RHEL6 kernels. The
   correct value for RHEL6 would be CAP_MAC_ADMIN (33).

3. As far as upstream kernels go, /proc/sys/kernel/cap_last_cap was
   added in kernel v3.2, and a correct value depends on the kernel
   version. It could be CAP_WAKE_ALARM (35), added to kernel v3.0, or
   CAP_SYSLOG (34), added to kernel v2.6.38, or possibly a lesser value
   for even older kernels.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-11-11 14:07:31 -05:00
Seth Hoenig
a0ff07393b drivers: provide empty implementations of cgroup helpers for non-root nomad (#24392) 2024-11-07 12:24:37 -06:00
Seth Hoenig
b58abf48c1 drivers: move executor process out of v1 task cgroup after process starts (#24340)
* drivers: move executor process out of v1 task cgroup after process starts

This PR changes the behavior of the raw exec task driver on old cgroups v1
systems such that the executor process is no longer a member of the cgroups
created for the task. Now, the executor process is placed into those
cgroups and starts the task child process (just as before), but now then
exits those cgroups and exists in the nomad parent cgroup. This change
makes the behavior sort of similar to cgroups v2 systems, where we never
have the executor enter the task cgroup to begin with (because we can
directly clone(3) the task process into it).

Fixes #23951

* executor: handle non-linux case

* cgroups: add test case for no executor process in task cgroup (v1)

* add changelog

* drivers: also move executor out of cpuset cgroup
2024-11-07 07:31:38 -06:00
Michael Smithhisler
0f97574eae test: fix rawexec driver unix test imports (#24352) 2024-11-01 12:10:03 -04:00
Michael Smithhisler
658c429d75 Drivers: add work_dir config to exec/raw_exec/java drivers (#24249)
---------

Co-authored-by: wurosh <uros.m.perisic@gmail.com>
Co-authored-by: Michael Schurter <mschurter@hashicorp.com>
Co-authored-by: Tim Gross <tgross@hashicorp.com>
2024-11-01 11:04:40 -04:00
Juanadelacuesta
80e398bbf7 test: add tests for validateBounds 2024-10-31 14:54:27 +01:00
Juanadelacuesta
8752bb0a65 func: move the user lookup into the validation, it's used everywhere the function is called 2024-10-31 10:34:26 +01:00
Juana De La Cuesta
f1439f54f7 Update drivers/shared/validators/validators.go
Co-authored-by: James Rasell <jrasell@users.noreply.github.com>
2024-10-31 09:32:51 +01:00
Juanadelacuesta
3f884bb3fa fix: remove the setConfig and modify the test driver to include idValidator to avoid panics 2024-10-30 17:38:54 +01:00
Juanadelacuesta
f954a1a5e8 fix: remove the setConfig and modify the test driver to include idValidator to avoid panics 2024-10-30 16:16:42 +01:00
Juanadelacuesta
a86e951f03 style: rename DeniedHostGidsStr to reflect refactor 2024-10-30 15:22:50 +01:00
Juanadelacuesta
a90eda628d func: implement mock validator to avoid changes on the rawexec tests 2024-10-30 15:07:47 +01:00
Juanadelacuesta
088417163b fix: add set config to populate idValidator on tests 2024-10-30 13:40:19 +01:00
Juanadelacuesta
445b19ce3e docs: update func docs 2024-10-30 12:35:06 +01:00
Juanadelacuesta
f707a02f4d fix: update test to force recreation of idvalidator 2024-10-30 12:28:59 +01:00
Juanadelacuesta
bba0407250 style: remove unused code and duplicated test 2024-10-30 11:43:04 +01:00
Juanadelacuesta
3fa2717195 style: remove unused code 2024-10-30 11:36:25 +01:00
Juanadelacuesta
a491ceff5f fix: put back MSL license header 2024-10-30 11:25:27 +01:00
Juanadelacuesta
e1a0c7cb43 fix: move exclusive unix test back from driver tests 2024-10-30 11:22:41 +01:00
Juanadelacuesta
9a6d2648c8 style: improve debug logging 2024-10-30 11:21:51 +01:00
Juanadelacuesta
2b9bb7a289 license: change missing file to BUSL 2024-10-30 10:24:35 +01:00
Juanadelacuesta
1751b618e4 func: Add conditional to validation init, to allow for easy testing 2024-10-29 16:45:33 +01:00
Juanadelacuesta
a9a452341c license: update headers to BUSL 2024-10-29 15:54:09 +01:00
Juanadelacuesta
0227788e22 fix: update tests configuration 2024-10-29 15:24:12 +01:00
Juanadelacuesta
0cd1b5ff13 func: move the validation to a dependency and use id sets 2024-10-28 18:59:51 +01:00
Juanadelacuesta
65be613be9 fix: rename test to avoid conflict 2024-10-28 12:17:57 +01:00
Juanadelacuesta
d77dc7dfa4 style: format 2024-10-28 11:46:51 +01:00
Juanadelacuesta
ed04b1bf64 style: remove print 2024-10-28 11:35:03 +01:00
Mike Nomitch
fd7e81dbce Fixing accidental move of helper fn to unix only validators file 2024-10-28 11:15:41 +01:00
Mike Nomitch
c4f2a41da6 Splitting validators unix functions into own file 2024-10-28 11:15:41 +01:00
Mike Nomitch
ff5ab3776c Tweaking user lookup code 2024-10-28 11:15:41 +01:00
Mike Nomitch
e1c226e633 Restructuring IDRange 2024-10-28 11:15:41 +01:00
Mike Nomitch
0fbf592131 moving user out of validators 2024-10-28 11:15:41 +01:00
Mike Nomitch
916af5a948 Moving idrange struct location 2024-10-28 11:15:41 +01:00
Mike Nomitch
9565dde138 Only parsing id ranges once 2024-10-28 11:15:41 +01:00
Mike Nomitch
d0049b1e63 Fixed error in denied_uids spec 2024-10-28 11:15:41 +01:00
Mike Nomitch
6b6a1b5bc4 Fixed windows build error 2024-10-28 11:15:41 +01:00
Mike Nomitch
cf36509474 Removing unnecessary int conversion 2024-10-28 11:15:40 +01:00
Mike Nomitch
9cc3992ca6 Adds ability to restrict uid and gids in exec and raw_exec 2024-10-28 11:15:37 +01:00
Seth Hoenig
b539b54c9e docker: close hijacked write connection when exec ends (#24244) 2024-10-17 11:41:29 -05:00
Seth Hoenig
b18851617f docker: close response connection once stdin is exhausted (#24202) 2024-10-17 11:07:23 -05:00
Piotr Kazmierczak
1ac14f4869 docker: always use API version negotiation when initializing clients (#24237)
During a refactoring of the docker driver in #23966 we introduced a bug: API
version negotiation option was not passed to every new client call.
2024-10-17 15:23:14 +02:00