Commit Graph

35 Commits

Author SHA1 Message Date
Luiz Aoqui
fffdbdff06 cli: job restart command (#16278)
Implement the new `nomad job restart` command that allows operators to
restart allocations tasks or reschedule then entire allocation.

Restarts can be batched to target multiple allocations in parallel.
Between each batch the command can stop and hold for a predefined time
or until the user confirms that the process should proceed.

This implements the "Stateless Restarts" alternative from the original
RFC
(https://gist.github.com/schmichael/e0b8b2ec1eb146301175fd87ddd46180).
The original concept is still worth implementing, as it allows this
functionality to be exposed over an API that can be consumed by the
Nomad UI and other clients. But the implementation turned out to be more
complex than we initially expected so we thought it would be better to
release a stateless CLI-based implementation first to gather feedback
and validate the restart behaviour.

Co-authored-by: Shishir Mahajan <smahajan@roblox.com>
2023-03-23 18:28:26 -04:00
Luiz Aoqui
4fdb5c477e cli: remove hard requirement on list-jobs (#16380)
Most job subcommands allow for job ID prefix match as a convenience
functionality so users don't have to type the full job ID.

But this introduces a hard ACL requirement that the token used to run
these commands have the `list-jobs` permission, even if the token has
enough permission to execute the basic command action and the user
passed an exact job ID.

This change softens this requirement by not failing the prefix match in
case the request results in a permission denied error and instead using
the information passed by the user directly.
2023-03-09 15:00:04 -05:00
Luiz Aoqui
0e824d363a cli: use shared logic for resolving job prefix (#16306)
Several `nomad job` subcommands had duplicate or slightly similar logic
for resolving a job ID from a CLI argument prefix, while others did not
have this functionality at all.

This commit pulls the shared logic to the command Meta and updates all
`nomad job` subcommands to use it.
2023-03-03 14:43:20 -05:00
Charlie Voiselle
d0f9008007 Add warnings to var put for non-alphanumeric keys. (#15933)
* Warn when Items key isn't directly accessible

Go template requires that map keys are alphanumeric for direct access
using the dotted reference syntax. This warns users when they create
keys that run afoul of this requirement.

- cli: use regex to detect invalid indentifiers in var keys
- test: fix slash in escape test case
- api: share warning formatting function between API and CLI
- ui: warn if var key has characters other than _, letter, or number

---------
Co-authored-by: Charlie Voiselle <464492+angrycub@users.noreply.github.com>
Co-authored-by: Luiz Aoqui <luiz@hashicorp.com>
2023-02-13 16:14:59 -05:00
James Rasell
95ba78418f cli: update namespace wildcard help to be non-specific.
A number of commands support namespace wildcard querying, so it
should be up to the sub-command to detail support, rather than
keeping this list up to date.
2022-03-23 12:56:48 +01:00
Derek Strickland
189806f643 Override TLS flags individually for meta commands (#11592)
* Override TLS flags individually for meta commands

* Update command/meta.go

Co-authored-by: Tim Gross <tgross@hashicorp.com>

Co-authored-by: Tim Gross <tgross@hashicorp.com>
2021-12-01 12:07:48 -05:00
Florian Apolloner
6cb36971c6 Added support for -force-color to the CLI. (#10975) 2021-10-06 10:02:42 -04:00
Florian Apolloner
f6c1e1dc3c Fixed usage of NOMAD_CLI_NO_COLOR env variable. (#11168) 2021-09-17 20:37:05 -04:00
James Rasell
0ba2086782 cli: fix minor format error within -ca-cert help text. 2021-08-03 16:05:06 +02:00
Tim Gross
89f4f51746 command: remove -namespace from help options when not applicable 2020-11-19 16:28:39 -05:00
Tim Gross
67061b8cd9 command: fix a typo in the help text for namespaces (#8975) 2020-09-28 12:23:25 -04:00
Mahmood Ali
42c1839a7b document namespace option in CLI docs 2020-07-01 15:31:41 -04:00
Mahmood Ali
85db7187fb cli: jobs allow querying jobs in all namespaces 2020-06-17 16:31:01 -04:00
Mahmood Ali
af2e2bc7ed cli: sequence cli.Ui operations
Fixes a bug where if a command flag parsing errors, the resulting error
and help usage messages get interleaved in unexpected and non-user
friendly way.

The reason is that we have flag parsing library effectively writes to
ui.Error in a goroutine.  This is problematic: first, we lose the sequencing between help
usage and error message; second, cli.Ui methods are not concurrent safe.

Here, we introduce a custom error writer that buffers result and calls
ui.Error() in the write method and in the same goroutine.

For context, we need to wrap ui.Error because it's line-oriented, while
flags library expects a io.Writer which is bytes oriented.
2019-12-16 10:08:17 -05:00
Peter McAtominey
533a2df8cc command: add -tls-server-name flag 2019-09-24 09:20:41 -07:00
Alex Dadgar
148a9504e7 color 2018-03-21 20:27:32 -07:00
Alex Dadgar
a9e3a41407 Enable more linters 2017-09-26 15:26:33 -07:00
Chelsea Holland Komlo
dfe23ca8eb update comment to use from other commands 2017-09-15 23:33:43 +00:00
Chelsea Holland Komlo
87295bbc05 fixups from code review 2017-09-15 23:33:43 +00:00
Chelsea Holland Komlo
899e0eba7f add acl token as meta flag
add API test for job ACL
2017-09-15 23:33:43 +00:00
Armon Dadgar
2a53d420e8 command: Adding acl token create 2017-09-14 21:55:25 -07:00
Alex Dadgar
ac1539d5d9 Sync namespace changes 2017-09-07 17:04:21 -07:00
Alex Dadgar
73990d68e0 Autocomplete global flags 2017-08-23 23:29:29 +00:00
Alex Dadgar
717bf7fe32 Change tty detection library 2017-08-23 14:35:50 -07:00
Alex Dadgar
2bb5a057ad Detect STDOUT isn't a TTY and disable color
This PR disables color output when the STDOUT is not a TTY. This makes
running commands under `watch` or other commands nicer.
2017-08-23 14:35:26 -07:00
Diptanu Choudhury
0e6e5b3e7b Enabling TLS on cli 2016-10-25 10:39:17 -07:00
Alex Dadgar
eb6055448e initial refactor and cleanup 2016-06-12 11:19:45 -07:00
Alex Dadgar
baff94f3ba docs 2016-06-07 11:33:55 -07:00
Alex Dadgar
92ea016fa0 Add region flag and environment variable 2016-06-07 11:16:04 -07:00
Alex Dadgar
b208da644a initial implementation of nomad plan 2016-05-17 13:33:48 -07:00
Ivo Verberk
9770a95608 Refactoring of full-id argument and id length constants
* full-id argument is now called verbose to be more future-proof
* constants for identifier length are a little more concise
2016-01-15 23:32:38 +01:00
Ivo Verberk
ab9409184a Shorten CLI identifiers
* Truncate all UUID identifiers to eight characters by default
* Refactor the node identifier to an auto-generated UUID
* Created and updated tests and mocks
2016-01-14 21:57:43 +01:00
Dave York
5f0cc2c328 fixes another typo
- Ui should be UI
2015-09-29 17:16:55 -04:00
Ryan Uber
7e26f938a2 command: use meta struct for common options 2015-09-14 13:24:03 -07:00
Armon Dadgar
7d29122130 Adding basic version command 2015-06-01 15:25:51 +02:00