Commit Graph

51 Commits

Author SHA1 Message Date
Michael Schurter
3968509886 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
7af0c3c9e5 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
b52f42db9a 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
6b2c53f006 jobspec2: ensure consistent error handling between var-file & var. 2021-09-09 11:18:11 +02:00
James Rasell
3bffe443ac chore: fix incorrect docstring formatting. 2021-08-30 11:08:12 +02:00
Mahmood Ali
ae7e29ff49 actually pass env-vars to hcl2 parsing 2020-12-11 13:32:54 -05:00
Mahmood Ali
6bfbadc199 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
73df83fffd 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
5a784f43a3 Start using the new jobspec2 API 2020-11-09 15:01:31 -05:00
Mahmood Ali
93bbe181e0 address review feedback 2020-10-22 11:49:37 -04:00
Mahmood Ali
1d85c6a4eb cli: use HCLv2 parser
Also, fallback to using HCLv1.
2020-10-21 15:46:57 -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
Lars Lehtonen
bbefae5506 command: error handling before file close (#6681) 2019-11-13 08:18:20 -05:00
Preetha Appan
913427428a 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
5d39f68f89 command: fix misspelling in comment 2018-04-18 12:19:53 -04:00
Nick Ethier
45b0ce9177 command: improve help text when invalid arguments are given 2018-04-18 12:02:11 -04:00
Alex Dadgar
d39b13ed58 Deprecated commands 2018-03-21 20:27:32 -07:00
Preetha Appan
69c4a58c34 Show reschedule eligibility time in alloc-status when followup evalid is available 2018-03-14 16:10:32 -05:00
Josh Soref
e1eb3e4684 spelling: sanitize 2018-03-11 18:52:59 +00:00
Josh Soref
357546d2c3 spelling: queryable 2018-03-11 18:40:07 +00:00
James Rasell
0a13199471 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
ddee932500 Fix upgrade path of modify time 2017-12-11 15:58:24 -08:00
Preetha Appan
c0e79a164d Fix flaky test TestPrettyTimeDiff 2017-11-16 09:48:14 -06:00
Preetha Appan
bc833c9c8c 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
33475d169a 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
92fcff3989 Adds modify time to job/alloc status CLI output, and pretty prints 2017-11-01 15:13:48 -05:00
Alex Dadgar
b86e05b4a0 use helper 2017-08-29 10:04:02 -07:00
Alex Dadgar
73990d68e0 Autocomplete global flags 2017-08-23 23:29:29 +00:00
Alex Dadgar
aa05302ed8 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
2d608d0baf 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
350934f03b 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
07f7e19578 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
f551dcb83e Making the job spec return api.Job 2017-02-16 13:52:39 -08:00
Michal Wieczorek
3c020b1421 Close job temp file 2016-09-05 23:40:53 +02:00
Kenjiro Nakayama
bbc6a48596 Rename Helper to JobGetter 2016-08-17 11:06:08 +09:00
Kenjiro Nakayama
d00090ab8b Use go-getter to get jobfile by URL 2016-08-17 11:06:08 +09:00
Cameron Davison
0b7acd5825 move formatUnixNanoTime into a utility function 2016-08-08 21:24:38 -05:00
Alex Dadgar
ac1cfd1821 unblock the readers to add liveness when using -n 2016-07-25 11:16:01 -07:00
Alex Dadgar
991220b5c7 implement -n for tail 2016-07-13 13:26:09 -06:00
Alex Dadgar
c692478a39 Give relative time 2016-06-15 15:28:35 -07:00
Alex Dadgar
e8b69052aa plan displays launch time of periodic jobs 2016-06-15 13:34:45 -07:00
Alex Dadgar
185c896ac0 helper 2016-06-10 11:02:15 -07:00
Alex Dadgar
e6e3225c5c Add -self flag to node-drain 2016-04-11 15:20:49 -07:00
Diptanu Choudhury
0a36dfb2e0 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
879c6c665f Showing Task Resources in alloc status 2016-03-11 14:28:51 -08:00
Diptanu Choudhury
4f24be9224 Simplified the logic of limit 2016-03-10 19:02:39 -08:00
Diptanu Choudhury
9e7e214fac Updated the time stamp style 2016-02-01 17:41:47 -08:00
Diptanu Choudhury
68269b5f39 Formatting time to RFC822 2016-01-27 14:56:17 -08:00
Alex Dadgar
4836bd5656 limit length of string, taking into account its length 2016-01-27 10:42:10 -08:00
Ryan Uber
8a57dbacac command: placeholder for <none> in kv output 2015-09-27 14:04:53 -07:00