Commit graph

52 commits

Author SHA1 Message Date
Piotr Kazmierczak db9316c4d3
acl: sso auth methods cli commands (#15322)
This PR implements CLI commands to interact with SSO auth methods.

This PR is part of the SSO work captured under ☂️ ticket #13120.
2022-11-28 10:51:45 +01:00
Michael Schurter 2965dc6a1a
artifact: fix numerous go-getter security issues
Fix numerous go-getter security issues:

- Add timeouts to http, git, and hg operations to prevent DoS
- Add size limit to http to prevent resource exhaustion
- Disable following symlinks in both artifacts and `job run`
- Stop performing initial HEAD request to avoid file corruption on
  retries and DoS opportunities.

**Approach**

Since Nomad has no ability to differentiate a DoS-via-large-artifact vs
a legitimate workload, all of the new limits are configurable at the
client agent level.

The max size of HTTP downloads is also exposed as a node attribute so
that if some workloads have large artifacts they can specify a high
limit in their jobspecs.

In the future all of this plumbing could be extended to enable/disable
specific getters or artifact downloading entirely on a per-node basis.
2022-05-24 16:29:39 -04:00
Michael Schurter 5db3a671db
cli: add -json flag to support job commands (#12591)
* cli: add -json flag to support job commands

While the CLI has always supported running JSON jobs, its support has
been via HCLv2's JSON parsing. I have no idea what format it expects the
job to be in, but it's absolutely not in the same format as the API
expects.

So I ignored that and added a new -json flag to explicitly support *API*
style JSON jobspecs.

The jobspecs can even have the wrapping {"Job": {...}} envelope or not!

* docs: fix example for `nomad job validate`

We haven't been able to validate inside driver config stanzas ever since
the move to task driver plugins. 😭
2022-04-21 13:20:36 -07:00
Florian Apolloner ef88795af3
Added a -hcl2-strict flag to allow for lenient hcl variable parsing. (#11284)
Co-authored-by: James Rasell <jrasell@hashicorp.com>
2021-11-04 16:33:09 +01:00
James Rasell 257d63eec9
jobspec2: ensure consistent error handling between var-file & var. 2021-09-09 11:18:11 +02:00
James Rasell b6813f1221
chore: fix incorrect docstring formatting. 2021-08-30 11:08:12 +02:00
Mahmood Ali 3d8fa799c7 actually pass env-vars to hcl2 parsing 2020-12-11 13:32:54 -05:00
Mahmood Ali 9a3da14a57
actually honor var files (#9592)
Apparently, we missed passing VarFile argument, so var files were
ignored.

Fixes #9588
2020-12-09 14:12:48 -05:00
Mahmood Ali f61d284fe6 Custom message when job file is HCL2 incompatible
Use a custom message when the job file is a valid HCL1 but no longer
valid under HCL 2 syntax.
2020-11-10 14:56:20 -05:00
Mahmood Ali 1ae3e8a8eb Start using the new jobspec2 API 2020-11-09 15:01:31 -05:00
Mahmood Ali d3a17b5c82 address review feedback 2020-10-22 11:49:37 -04:00
Mahmood Ali 84ec0b38e8 cli: use HCLv2 parser
Also, fallback to using HCLv1.
2020-10-21 15:46:57 -04:00
Mahmood Ali 76be9b4afb 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
Lars Lehtonen e85509c466 command: error handling before file close (#6681) 2019-11-13 08:18:20 -05:00
Preetha Appan 10e7d6df6d
Remove compat code associated with many previous versions of nomad
This removes compat code for namespaces (0.7), Drain(0.8) and other
older features from releases older than Nomad 0.7
2019-06-25 19:05:25 -05:00
Nick Ethier 71fd07d4d0
command: fix misspelling in comment 2018-04-18 12:19:53 -04:00
Nick Ethier 182e3bec1b
command: improve help text when invalid arguments are given 2018-04-18 12:02:11 -04:00
Alex Dadgar aa85b61fc8 Deprecated commands 2018-03-21 20:27:32 -07:00
Preetha Appan ffa0b7b1ed
Show reschedule eligibility time in alloc-status when followup evalid is available 2018-03-14 16:10:32 -05:00
Josh Soref f28efbbc79 spelling: sanitize 2018-03-11 18:52:59 +00:00
Josh Soref 7b74c9b36f spelling: queryable 2018-03-11 18:40:07 +00:00
James Rasell 06bf8e932a
Update CLI to use ISO_8601 time format.
This change updates the formatTime CLI helper function to return
an ISO_8601 time format which will make CLI time usage more
consistent and easier. Previosuly the time format was in US style
format which was somewhat confusing to non US users.

Closes #3806
2018-01-30 08:57:07 +00:00
Alex Dadgar 189ff0dc22 Fix upgrade path of modify time 2017-12-11 15:58:24 -08:00
Preetha Appan 88b7c36357 Fix flaky test TestPrettyTimeDiff 2017-11-16 09:48:14 -06:00
Preetha Appan 03ac677dc8 Handle edge case when allocation create/modify time difference is less than a second ago. 2017-11-14 16:40:34 -06:00
Preetha Appan 75673b88c0 New pretty printer that imitates the short form from time.Duration.String() with approximated values for days and beyond. Used in cli output for allocation create/modify times 2017-11-01 15:16:38 -05:00
Preetha Appan e91d26d6ba Adds modify time to job/alloc status CLI output, and pretty prints 2017-11-01 15:13:48 -05:00
Alex Dadgar 52fa3396e7 use helper 2017-08-29 10:04:02 -07:00
Alex Dadgar cf7a3fdf51 Autocomplete global flags 2017-08-23 23:29:29 +00:00
Alex Dadgar eef3b15005 Ensure backwards compatibility between 0.6.X CLI and 0.5.X
This PR goes through the CLI commands and ensures that a 0.6.X cli
gracefully handles interacting with a 0.5.X Nomad Agent.

Fixes https://github.com/hashicorp/nomad/issues/2918
2017-07-28 10:20:47 -07:00
Michael Schurter 6b2cb6bb23 Don't display UNIX epoch dates
Submitted times are UNIX epoch for jobs created before 0.6 which is
confusing in the CLI. Display nothing instead (formatted as "<none>").
2017-07-20 15:43:00 -07:00
Ben Barnard 372303f4c6 Return AgentSelf struct from Agent.Self() instead of map
api.AgentSelf mirrors command.agent.agentSelf, and makes it easier to
work with the results of a call to Agent.Self()
2017-03-08 15:59:10 +01:00
Alex Dadgar 5be806a3df Fix vet script and fix vet problems
This PR fixes our vet script and fixes all the missed vet changes.

It also fixes pointers being printed in `nomad stop <job>` and `nomad
node-status <node>`.
2017-02-27 16:00:19 -08:00
Diptanu Choudhury 7567209857 Making the job spec return api.Job 2017-02-16 13:52:39 -08:00
Michal Wieczorek db685b164f Close job temp file 2016-09-05 23:40:53 +02:00
Kenjiro Nakayama c25baab028 Rename Helper to JobGetter 2016-08-17 11:06:08 +09:00
Kenjiro Nakayama 7fb866ae4c Use go-getter to get jobfile by URL 2016-08-17 11:06:08 +09:00
Cameron Davison e0d757b7b0
move formatUnixNanoTime into a utility function 2016-08-08 21:24:38 -05:00
Alex Dadgar 605dd5cef9 unblock the readers to add liveness when using -n 2016-07-25 11:16:01 -07:00
Alex Dadgar d37651995f implement -n for tail 2016-07-13 13:26:09 -06:00
Alex Dadgar 122d035457 Give relative time 2016-06-15 15:28:35 -07:00
Alex Dadgar bf14fd355f plan displays launch time of periodic jobs 2016-06-15 13:34:45 -07:00
Alex Dadgar f006aeeb20 helper 2016-06-10 11:02:15 -07:00
Alex Dadgar 60153ed845 Add -self flag to node-drain 2016-04-11 15:20:49 -07:00
Diptanu Choudhury 7276bd5e84 Merge pull request #907 from hashicorp/f-task-resources
Showing Task Resources in alloc status
2016-03-11 15:14:49 -08:00
Diptanu Choudhury b07c23fd5e Showing Task Resources in alloc status 2016-03-11 14:28:51 -08:00
Diptanu Choudhury 4589798ade Simplified the logic of limit 2016-03-10 19:02:39 -08:00
Diptanu Choudhury a7906020dd Updated the time stamp style 2016-02-01 17:41:47 -08:00
Diptanu Choudhury f4e891b0c1 Formatting time to RFC822 2016-01-27 14:56:17 -08:00
Alex Dadgar 837ca9ab86 limit length of string, taking into account its length 2016-01-27 10:42:10 -08:00