Commit Graph

47 Commits

Author SHA1 Message Date
hc-github-team-nomad-core c3546e80a1
backport of commit f64ade2304583ba338c4da3c6c11de722ea4b497 (#18852)
Co-authored-by: James Rasell <jrasell@users.noreply.github.com>
2023-10-24 17:15:35 +01:00
hc-github-team-nomad-core 2ed92e0c6c
Backport of feature: Add new field render_templates on restart block into release/1.6.x (#18094)
This pull request was automerged via backport-assistant
2023-07-28 13:54:00 -05:00
Seth Hoenig 4abb3e03ca
cli: upload var file(s) content on job submission (#17128)
This PR makes it so that the content of any -var-file files is uploaded
to Nomad on job run.
2023-05-11 08:04:33 -05:00
Seth Hoenig ba728f8f97
api: enable support for setting original job source (#16763)
* api: enable support for setting original source alongside job

This PR adds support for setting job source material along with
the registration of a job.

This includes a new HTTP endpoint and a new RPC endpoint for
making queries for the original source of a job. The
HTTP endpoint is /v1/job/<id>/submission?version=<version> and
the RPC method is Job.GetJobSubmission.

The job source (if submitted, and doing so is always optional), is
stored in the job_submission memdb table, separately from the
actual job. This way we do not incur overhead of reading the large
string field throughout normal job operations.

The server config now includes job_max_source_size for configuring
the maximum size the job source may be, before the server simply
drops the source material. This should help prevent Bad Things from
happening when huge jobs are submitted. If the value is set to 0,
all job source material will be dropped.

* api: avoid writing var content to disk for parsing

* api: move submission validation into RPC layer

* api: return an error if updating a job submission without namespace or job id

* api: be exact about the job index we associate a submission with (modify)

* api: reword api docs scheduling

* api: prune all but the last 6 job submissions

* api: protect against nil job submission in job validation

* api: set max job source size in test server

* api: fixups from pr
2023-04-11 08:45:08 -05:00
hashicorp-copywrite[bot] 005636afa0 [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
Lance Haig d9e585b965
Update ioutil library references to os and io respectively for command (#16329)
No user facing changes so I assume no change log is required
2023-03-08 09:20:04 -06:00
Seth Hoenig 92dfa41286
command: fixup tests concerning multi job stop (#15606)
* command: fixup job multi-stop test

This PR refactors the StopCommand test that runs 10 jobs and then
passes them all to one invokation of 'job stop'.

* test: swap use of assert for must

* test: cleanup job files we create

* command: fixup job stop failure tests

Now that JobStop works on concurrent jobs, the error messages are
different.

* cleanup: use multiple post scripts
2022-12-21 16:21:48 -06:00
Tim Gross cc9b480996
testing: setting env var incompatible with parallel tests (#14405)
Neither the `os.Setenv` nor `t.Setenv` helper are safe to use in parallel tests
because environment variables are process-global. The stdlib panics if you try
to do this. Remove the `ci.Parallel()` call from all tests where we're setting
environment variables.
2022-08-30 14:49:03 -04:00
Seth Hoenig 4c1a0d4907 cleanup: first pass at fixing command package warnings
This PR is the first of several for cleaning up warnings, and refactoring
bits of code in the command package. First pass is over acl_ files and
gets some helpers in place.
2022-08-17 15:33:37 -05:00
Piotr Kazmierczak b63944b5c1
cleanup: replace TypeToPtr helper methods with pointer.Of (#14151)
Bumping compile time requirement to go 1.18 allows us to simplify our pointer helper methods.
2022-08-17 18:26:34 +02: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
Seth Hoenig 2631659551 ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05: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
Mahmood Ali fa4df28fcd
tests: ensure that tests restore env-var values (#11309)
Fix a test corruption issue, where a test accidentally unsets
the `NOMAD_LICENSE` environment variable, that's relied on by some
tests.

As a habit, tests should always restore the environment variable value
on test completion. Golang 1.17 introduced
[`t.Setenv`](https://pkg.go.dev/testing#T.Setenv) to address this issue.
However, as 1.0.x and 1.1.x branches target golang 1.15 and 1.16, I
opted to use a helper function to ease backports.
2021-10-13 17:26:56 -04:00
Mahmood Ali 8dedef31d6 tests: update test with a real invalid hcl2 2021-02-01 11:12:22 -05: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 1ae924973e hclv1: tweak HCLv1 tests
This ensures that gatway ReadOnly key is tested.  Also, update the hclv1
test-fixtures to be hclv1 compliant.
2020-10-21 14:05:46 -04:00
James Rasell 2ed78b8a7e
cli: move tests to use NewMockUi func. 2020-10-05 16:07:41 +02: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 98d3e47b32 command: fix TestHelpers_LineLimitReader_TimeLimit() goroutine (#6678) 2019-11-12 08:35:11 -05:00
Alex Dadgar 235a61cdd3 fix flaky pretty time test 2018-04-03 18:15:12 -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
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 23e08f17a6 Declare time.Now once to prevent flakiness 2017-11-14 20:32:02 -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
Alex Dadgar d7fee07ebc Parallel 2017-07-20 21:24:21 -07:00
Alex Dadgar c106df9215 Switch to in-process agent 2017-07-20 21:07:32 -07:00
Alex Dadgar b5995c6cd7 Vendor + test fixes 2017-02-22 15:55:33 -08:00
Alex Dadgar 5785b4518e Refactor test and fix them 2017-02-16 14:00:41 -08:00
Alex Dadgar 70e716c8bb Flatmap 2017-02-16 13:52:39 -08:00
Alex Dadgar 51dd3e6e12 Use RC to see if cause of failure 2017-02-16 13:52:39 -08:00
Diptanu Choudhury d0d7c92bab Added tests 2017-02-16 13:52:39 -08:00
Alex Dadgar 0e6b84145c Fix interval breaking two tests 2017-02-14 17:06:30 -08:00
Kenjiro Nakayama 30f274b17e Add StructJob test with jobfile from HTTP Server 2016-08-17 11:06:08 +09: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
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 60153ed845 Add -self flag to node-drain 2016-04-11 15:20:49 -07:00
Ryan Uber 079b3c753a command: placeholder for <none> in kv output 2015-09-27 14:04:53 -07:00
Ryan Uber 1299fabf1f command: helpers for columns 2015-09-15 16:44:38 -07:00