Commit Graph

26499 Commits

Author SHA1 Message Date
Tim Gross
c3ac9c19a0 event stream: add events for CSI volumes and plugins (#24724)
Adds new topics to the event stream for CSI volumes and CSI plugins. We'll emit
event when either is created or deleted, and when CSI volumes are claimed.
2024-12-19 15:26:29 -05:00
Tim Gross
9cf0ad9447 event stream: add events for dynamic host volumes (#24721)
Add a new topic to the event stream for host volumes. We'll emit events when a
dynamic host volume is registered or deregistered, and whenever a node
fingerprints with a changed volume.

Ref: https://hashicorp.atlassian.net/browse/NET-11549
2024-12-19 14:55:38 -05:00
Aimee Ukasick
1065769f1e Docs: fix typo in lower_bound (#24731)
reported via Slack
2024-12-19 13:31:37 -06:00
Aimee Ukasick
1c12fc59a6 Docs: change stop_after to stop_on_client_after (#24727)
* change stop_after to stop_on_client_after

CE-800  GH https://github.com/hashicorp/nomad/issues/24702

* Move disconnect entry to correct alphabetical place in nav
2024-12-19 13:13:57 -06:00
Aimee Ukasick
8dc4a94b35 Add link to published tutorial (#24712)
CE-801
2024-12-19 12:52:05 -06:00
Charlie Voiselle
30ab8897d2 deps: Switch from mitchellh/cli to hashicorp/cli (#19321)
Co-authored-by: James Rasell <jrasell@hashicorp.com>
2024-12-19 15:41:11 +00:00
Tim Gross
7d8653270a Dynamic Host Volumes (merge pull request #24479)
Closes: #15489
Ref: https://hashicorp.atlassian.net/browse/NET-11259
2024-12-19 09:46:11 -05:00
Piotr Kazmierczak
ad1e597796 stateful deployments: validate there are no sticky per_alloc volume requests (#24714)
This changeset adds an additional validation that prevents users from setting
per_alloc and sticky flags on volume requests.

Ref: #24479
2024-12-19 09:25:55 -05:00
Tim Gross
fea846189f dynamic host volumes: account for other claims in capability check (#24684)
When we feasibility check a dynamic host volume against a volume request, we
check the attachment mode and access mode. This only ensures that the
capabilities match, but doesn't enforce the semantics of the capabilities
against other claims that may be made on the allocation.

Add support for checking the requested capability against other allocations that
the volume claimed.

Ref: https://github.com/hashicorp/nomad/pull/24479
2024-12-19 09:25:55 -05:00
Daniel Bennett
af967184a6 dynamic host volumes: tweak plugin fingerprint (#24711)
Instead of a plugin `version` subcommand that responds with a string
(established in #24497), respond to a `fingerprint` command with a data
structure that we may extend in the future (such as plugin capabilities,
like size constraint support?). In the immediate term, it's still just the
version: `{"version": "0.0.1"}`

In addition to leaving the door open for future expansion, I think it will
also avoid false positives detecting executables that just happen to
respond to a `version` command.

This also reverses the ordering of the fingerprint string parts
from `plugins.host_volume.version.mkdir` (which aligned with CNI)
to `plugins.host_volume.mkdir.version` (makes more sense to me)
2024-12-19 09:25:55 -05:00
Piotr Kazmierczak
8cbb74786c stateful deployments: find feasible node for sticky host volumes (#24558)
This changeset implements node feasibility checks for sticky host volumes.
2024-12-19 09:25:55 -05:00
Tim Gross
2adf6d5208 dynamic host volumes: remove multi-node access modes (#24705)
CSI volumes support multi-node access patterns on the same volume ID, but
dynamic host volumes by nature do not. The underlying volume may actually be
multi-node (ex. NFS), but Nomad is ignorant of this. Remove the CSI-specific
multi-node access modes and instead include the single-node access modes
intended that are currently in the alpha edition of the CSI spec but which are
better suited for DHV.

This PR has been extracted from #24684 to keep reviews manageable.

Ref: https://github.com/hashicorp/nomad/pull/24479
Ref: https://github.com/hashicorp/nomad/pull/24684
2024-12-19 09:25:54 -05:00
Piotr Kazmierczak
967addec48 stateful deployments: add corrections to API structs and methods (#24700)
This changeset includes changes accidentally left out from 24641.
2024-12-19 09:25:54 -05:00
Tim Gross
fd05e461dd dynamic host volumes: add -type flag to volume init (#24667)
Adds a `-type` flag to the `volume init` command that generates an example
volume specification with only those fields relevant to dynamic host
volumes. This changeset also moves the string literals into uses of `go:embed`

Ref: https://github.com/hashicorp/nomad/pull/24479
2024-12-19 09:25:54 -05:00
Piotr Kazmierczak
258b159d53 stateful deployments: add Sticky property to task group volumes (#24641) 2024-12-19 09:25:54 -05:00
Tim Gross
3143019d85 dynamic host volumes: capabilities check during scheduling (#24617)
Static host volumes have a simple readonly toggle, but dynamic host volumes have
a more complex set of capabilities similar to CSI volumes. Update the
feasibility checker to account for these capabilities and volume readiness.

Also fixes a minor bug in the state store where a soft-delete (not yet
implemented) could cause a volume to be marked ready again. This is needed to
support testing the readiness checking in the scheduler.

Ref: https://github.com/hashicorp/nomad/pull/24479
2024-12-19 09:25:54 -05:00
Daniel Bennett
e76f5e0b4c dynamic host volumes: volume fingerprinting (#24613)
and expand the demo a bit
2024-12-19 09:25:54 -05:00
Tim Gross
76641c8081 dynamic host volumes: refactor HTTP routes for volumes list dispatch (#24612)
The List Volumes API was originally written for CSI but assumed we'd have future
volume types, dispatched on a query parameter. Dynamic host volumes uses this,
but the resulting code has host volumes concerns comingled in the CSI volumes
endpoint. Refactor this so that we have a top-level `GET /v1/volumes` route that's
shared between CSI and DHV, and have it dispatch to the appropriate handler in
the type-specific endpoints.

Ref: https://github.com/hashicorp/nomad/pull/24479
2024-12-19 09:25:54 -05:00
Daniel Bennett
5826e92671 dynamic host volumes: delete by single volume ID (#24606)
string instead of []string
2024-12-19 09:25:54 -05:00
Tim Gross
67ed31db41 dynamic host volumes: add implicit constraints on plugin fingerprint (#24605)
Node fingerprints include attributes for the host volume plugins, including the
built-in plugins. Add an implicit constraint on this fingerprint during volume
placement to ensure we only place volumes on hosts with the right plugins.

Ref: https://github.com/hashicorp/nomad/pull/24479
2024-12-19 09:25:54 -05:00
Daniel Bennett
05f1cda594 dynamic host volumes: client state (#24595)
store dynamic host volume creations in client state,
so they can be "restored" on agent restart. restore works
by repeating the same Create operation as initial creation,
and expecting the plugin to be idempotent.

this is (potentially) especially important after host restarts,
which may have dropped mount points or such.
2024-12-19 09:25:54 -05:00
Tim Gross
787fbbe671 sentinel: remove default scope for Sentinel apply command (#24601)
When we add a Sentinel scope for dynamic host volumes, having a default `-scope`
value for `sentinel apply` risks accidentally adding policies for volumes to the
job scope. This would immediately prevent any job from being submitted. Forcing
the administrator to pass a `-scope` will prevent accidental misuse.

Ref: https://github.com/hashicorp/nomad-enterprise/pull/2087
Ref: https://github.com/hashicorp/nomad/pull/24479
2024-12-19 09:25:54 -05:00
Tim Gross
d700538921 dynamic host volumes: Sentinel improvements for CLI (#24592)
The create/register volume RPCs support a policy override flag for
soft-mandatory Sentinel policies, but the CLI and Go API were missing support
for it.

Also add support for Sentinel warnings to the Go API and CLI.

Ref: https://github.com/hashicorp/nomad/pull/24479
2024-12-19 09:25:54 -05:00
Daniel Bennett
46a39560bb dynamic host volumes: fingerprint client plugins (#24589) 2024-12-19 09:25:54 -05:00
Tim Gross
df258ac02a dynamic host volumes: set namespace from volume spec when monitoring (#24586)
In #24528 we added monitoring to the CLI for dynamic host volume creation. But
when the volume's namespace is set by the volume specification instead of the
`-namespace` flag, the API client doesn't have the right namespace and gets a
404 when setting up the monitoring. The specification always overrides the
`-namespace` flag, so use that when available for all subsequent API calls.

Ref: https://github.com/hashicorp/nomad/pull/24479
2024-12-19 09:25:54 -05:00
Piotr Kazmierczak
f0b89fc484 dynamic host volumes: make example-host-volume plugin run on macOS (#24563)
This adapts the shell script for darwin, making it easier to test.
2024-12-19 09:25:54 -05:00
Tim Gross
e3864a5f4a dynamic host volumes: autocomplete for CLI (#24533)
Adds dynamic host volumes to argument autocomplete for the `volume status` and
`volume delete` commands. Adds flag autocompletion for those commands plus
`volume create`.

Ref: https://github.com/hashicorp/nomad/pull/24479
2024-12-19 09:25:54 -05:00
Tim Gross
d1352b285d dynamic host volumes: Enterprise stubs and refactor API (#24545)
Most Nomad upsert RPCs accept a single object with the notable exception of
CSI. But in CSI we don't actually expose this to users except through the Go
API. It deeply complicates how we present errors to users, especially once
Sentinel policy enforcement enters the mix.

Refactor the `HostVolume.Create` and `HostVolume.Register` RPCs to take a single
volume instead of a slice of volumes.

Add a stub function for Enterprise policy enforcement. This requires splitting
out placement from the `createVolume` function so that we can ensure we've
completed placement before trying to enforce policy.

Ref: https://github.com/hashicorp/nomad/pull/24479
2024-12-19 09:25:54 -05:00
Tim Gross
926925ba16 dynamic host volumes: search endpoint (#24531)
Add support for dynamic host volumes to the search endpoint. Like many other
objects with UUID identifiers, we're not supporting fuzzy search here, just
prefix search on the fuzzy search endpoint.

Because the search endpoint only returns IDs, we need to seperate CSI volumes
and host volumes for it to be useful. The new context is called `"host_volumes"`
to disambiguate it from `"volumes"`. In future versions of Nomad we should
consider deprecating the `"volumes"` context in lieu of a `"csi_volumes"`
context.

Ref: https://github.com/hashicorp/nomad/pull/24479
2024-12-19 09:25:54 -05:00
Tim Gross
298460dcd9 dynamic host volumes: monitor readiness from CLI (#24528)
When creating a dynamic host volumes, set up an optional monitor that waits for
the node to fingerprint the volume as healthy.

Ref: https://github.com/hashicorp/nomad/pull/24479
2024-12-19 09:25:54 -05:00
Daniel Bennett
2b04d47ac2 dynamic host volumes: test client RPC and plugins (#24535)
also ensure that volume ID is uuid-shaped so user-provided input
like `id = "../../../"` which is used as part of the target directory
can not find its way very far into the volume submission process
2024-12-19 09:25:54 -05:00
Tim Gross
0a08ddb083 dynamic host volumes: update volume from node fingerprint (#24521)
When dynamic host volumes are created, they're written to the state store in a
"pending" state. Once the client fingerprints the volume it's eligible for
scheduling, so we mark the state as ready at that point.

Because the fingerprint could potentially be returned before the RPC handler has
a chance to write to the state store, this changeset adds test coverage to
verify that upserts of pending volumes check the node for a
previously-fingerprinted volume as well.

Ref: https://github.com/hashicorp/nomad/pull/24479
2024-12-19 09:25:54 -05:00
Tim Gross
bbf49a9050 dynamic host volumes: node selection via constraints (#24518)
When making a request to create a dynamic host volumes, users can pass a node
pool and constraints instead of a specific node ID.

This changeset implements a node scheduling logic by instantiating a filter by
node pool and constraint checker borrowed from the scheduler package. Because
host volumes with the same name can't land on the same host, we don't need to
support `distinct_hosts`/`distinct_property`; this would be challenging anyways
without building out a much larger node iteration mechanism to keep track of
usage across multiple hosts.

Ref: https://github.com/hashicorp/nomad/pull/24479
2024-12-19 09:25:54 -05:00
Daniel Bennett
c2dd97dee7 HostVolumePlugin interface and two implementations (#24497)
* mkdir: HostVolumePluginMkdir: just creates a directory
* example-host-volume: HostVolumePluginExternal:
  plugin script that does mkfs and mount loopback

Co-authored-by: Tim Gross <tgross@hashicorp.com>
2024-12-19 09:25:54 -05:00
Tim Gross
10a5f4861f dynamic host volumes: create/register RPC validation
Add several validation steps in the create/register RPCs for dynamic host
volumes. We first check that submitted volumes are self-consistent (ex. max
capacity is more than min capacity), then that any updates we've made are
valid. And we validate against state: preventing claimed volumes from being
updated and preventing placement requests for nodes that don't exist.

Ref: https://github.com/hashicorp/nomad/issues/15489
2024-12-19 09:25:54 -05:00
Tim Gross
0f92134a7f dynamic host volumes: fix unblocking bug in state store
The `HostVolumeByID` state store method didn't add a watch channel to the
watchset, which meant that it would never unblock. The tests missed this because
they were racy, so move the updates for unblocking tests into a `time.After`
call to ensure the queries are blocked before the update happens.
2024-12-19 09:25:54 -05:00
Tim Gross
c3735127ae allow FlattenMultierror to accept standard error 2024-12-19 09:25:54 -05:00
Tim Gross
7c85176059 dynamic host volumes: basic CLI CRUD operations (#24382)
This changeset implements a first pass at the CLI for Dynamic Host Volumes.

Ref: https://hashicorp.atlassian.net/browse/NET-11549
2024-12-19 09:25:54 -05:00
Tim Gross
a65358da7b dynamic host volumes: HTTP API endpoint (#24380)
This changeset implements the HTTP API endpoints for Dynamic Host Volumes.

The `GET /v1/volumes` endpoint is shared between CSI and DHV with a query
parameter for the type. In the interest of getting some working handlers
available for use in development (and minimizing the size of the diff to
review), this changeset doesn't do any sort of refactoring of how the existing
List Volumes CSI endpoint works. That will come in a later PR, as will the
corresponding `api` package updates we need to support the CLI.

Ref: https://hashicorp.atlassian.net/browse/NET-11549
2024-12-19 09:25:54 -05:00
Tim Gross
6a3803c31e dynamic host volumes: RPC handlers (#24373)
This changeset implements the RPC handlers for Dynamic Host Volumes, including
the plumbing needed to forward requests to clients. The client-side
implementation is stubbed and will be done under a separate PR.

Ref: https://hashicorp.atlassian.net/browse/NET-11549
2024-12-19 09:25:54 -05:00
Tim Gross
75c142ff40 dynamic host volumes: initial state store implementation (#24353)
This changeset implements the state store schema for Dynamic Host Volumes, and
methods used to query the state for RPCs.

Ref: https://hashicorp.atlassian.net/browse/NET-11549
2024-12-19 09:25:53 -05:00
Tim Gross
d8c901570b dynamic host volumes: ACL policies (#24356)
This changeset implements the ACLs required for dynamic host volumes RPCs:
* `host-volume-write` is a coarse-grained policy that implies all operations.
* `host-volume-register` is the highest fine-grained privilege because it
  potentially bypasses quotas.
* `host-volume-create` is implicitly granted by `host-volume-register`
* `host-volume-delete` is implicitly granted only by `host-volume-write`
* `host-volume-read` is implicitly granted by `policy = "read"`,

These are namespaced operations, so the testing here is predominantly around
parsing and granting of implicit capabilities rather than the well-tested
`AllowNamespaceOperation` method.

This changeset does not include any changes to the `host_volumes` policy which
we'll need for claiming volumes on job submit. That'll be covered in a later PR.

Ref: https://hashicorp.atlassian.net/browse/NET-11549
2024-12-19 09:25:53 -05:00
James Rasell
8bb7c1315d e2e: fix failing tests due to region name change. (#24713) 2024-12-19 14:21:17 +00:00
Daniel Peinhopf
04e930b756 Show HCL variable input on job submission. (#24622)
* Show HCL variable input on job submission.

* Add changelog entry

(authored by @sevensolutions)
2024-12-18 13:56:47 -05:00
James Rasell
fe821b4c1c github: Fix lock threads syntax and permissions (#24708)
The parameters used for the reusable action were incorrect since
the 5.0.1 update. The permissions were also incorrect as the
workflow needs to write to issues and PRs.
2024-12-18 15:29:58 +00:00
James Rasell
e3ac00f30e github: notify Slack when CI fails on merge to main/release (#24690)
This change creates a reusable workflow for notifying Slack on CI
failures. The message will include useful links and information
about the failure, so product engineers can investigate and fix
any problems.

The new workflow is used by selected workflows which trigger on
merges to main or release/* branches. The notification is only
sent on failure and when the event was a push (PR merge) meaning
the number of notifications should be minimal.

The aim is to help identify and draw attention to failure across
our release branches, in particular when automated processes
happen.
2024-12-18 08:07:44 +00:00
Tim Gross
30e57c39b0 discovery: correctly handle IPv6 addresses from go-discover (#24649)
Nomad sets a default port when resolving server addresses that don't have
one. When we get a "bare" IPv6 address without a port, we end up with an
unexpected error "too many colons in address" when we try to split the address
and host, because the standard library function expects IPv6 addresses to be
wrapped in brackets as recommended by RFC5952. User-configured addresses avoid
this problem by accepting IP address and port as separate configuration values,
but go-discover emits "bare" IPv6 addresses without a port in IPv6 environments.

Fix this by adding brackets to IPv6 addresses when we get the "too many colons"
error from the stdlib. This will still give erroneous results if the address
includes the port but is missing brackets, but there's no way to unambiguously
parse that address.

Ref: https://www.rfc-editor.org/rfc/rfc5952
Fixes: https://github.com/hashicorp/nomad/issues/24608
2024-12-17 15:49:40 -05:00
Deniz Onur Duzgun
a4ac2025f4 sec: suppress osv alert in CRT (#24701)
* sec: suppress GO-2022-0635 osv alert in CRT

* hclfmt
2024-12-17 14:56:52 -05:00
Phil Renaud
7746f290e6 Reset childjobs watcher when kicking it off from a new parent job route (#24668) 2024-12-17 10:49:37 -05:00
Phil Renaud
932c3ebfb0 [ui] Adds meta k/v tables to Task Group and Task pages (#24594)
* Experimenting with a generic meta job-part component

* Taskstate.task gets me every time

* continue-on-error false test

* continue-on-error back in, but explicit success check after exam

* Testfixes for new meta structure on tasks and groups

* Clean up test and dev code
2024-12-17 10:46:03 -05:00