Commit Graph

260 Commits

Author SHA1 Message Date
Luiz Aoqui b8dd60f79c
update LAST_RELEASE comment to match new release branches structure (#12773) 2022-04-25 11:57:55 -04:00
Seth Hoenig 6ea9da8d03 build: add missing help descriptions to makefile 2022-04-21 14:58:58 -05:00
Seth Hoenig 47040391bb ci: ensure package coverage of test-core 2022-04-14 19:04:06 -05:00
Luiz Aoqui 13233a4dd3
ci: make version script match ENT to avoid unnecessary merge conflicts (#12482) 2022-04-06 12:56:52 -04:00
claire labry 6f7f7277d5
[Main] Onboard to CRT (#12276) 2022-04-06 11:47:02 -04:00
Seth Hoenig 4b895a436a ci: set count to bypass caching 2022-03-25 13:43:33 -05:00
Seth Hoenig e85fbaf0ac ci: cleanup verbose mode and enable for gha
test_checks.sh was removed in 2019 and now just breaks if VERBOSE is
set when running tests via make targets

in GHA, use verbose mode to display what tests are running
2022-03-24 15:15:05 -05:00
Seth Hoenig 57bd480062 ci: turn on testing in github actions 2022-03-18 11:12:24 -05:00
Seth Hoenig 4d86f5d94d ci: limit gotestsum to circle ci
Part 2 of breaking up https://github.com/hashicorp/nomad/pull/12255

This PR makes it so gotestsum is invoked only in CircleCI. Also the
HCLogger(t) is plumbed more correctly in TestServer and TestAgent so
that they respect NOMAD_TEST_LOG_LEVEL.

The reason for these is we'll want to disable logging in GHA,
where spamming the disk with logs really drags performance.
2022-03-18 09:15:01 -05:00
Tim Gross 77fac26d5e
CI: increase test run timeout (#12143) 2022-02-28 11:30:59 -05:00
Seth Hoenig 7519f3e2f5 build: use single-path GOPATH set in makefile
When GOBIN is not set, BIN must be set to the single-path workaround
value of GOPATH, because Circle.
2022-02-17 09:26:13 -06:00
Seth Hoenig 98758d4287 build: respect GOBIN when using make targets
This PR updates GNUMakefile to respect $GOBIN if it is set in the
environment or via an $GOENV file. Previously we hard-coded the output
to $GOPATH/bin, which is not necessarily the desired behavior.
2022-02-16 12:05:55 -06:00
Seth Hoenig 84abc16ec6 build: allow golangci-lint to use more than 1 core
Since switching to `golangci-lint` we have set the `-j 1` flag, which
restricts the tool to using 1 CPU thread.

This PR removes the flag so `make check` takes less time on good
computers.
2022-02-14 16:56:58 -06:00
Luiz Aoqui e83ef0a008
prepare for next release 2022-02-10 14:56:11 -05:00
Tim Gross 7a0d151fab prepare for next release 2022-02-01 11:13:22 -05:00
Seth Hoenig 2f0cfb5740 build: upgrade and speedup circleci configuration
This PR upgrades our CI images and fixes some affected tests.

- upgrade go-machine-image to premade latest ubuntu LTS (ubuntu-2004:202111-02)

- eliminate go-machine-recent-image (no longer necessary)

- manage GOPATH in GNUMakefile (see https://discuss.circleci.com/t/gopath-is-set-to-multiple-directories/7174)

- fix tcp dial error check (message seems to be OS specific)

- spot check values measured instead of specifically 'RSS' (rss no longer reported in cgroups v2)

- use safe MkdirTemp for generating tmpfiles

NOT applied: (too flakey)

- eliminate setting GOMAXPROCS=1 (build tools were also affected by this setting)

- upgrade resource type for all imanges to large (2C -> 4C)
2022-01-24 08:28:14 -06:00
Luiz Aoqui 3f84b6256b
prepare for next release 2022-01-19 11:51:59 -05:00
Charlie Voiselle 98a240cd99
Make number of scheduler workers reloadable (#11593)
## Development Environment Changes
* Added stringer to build deps

## New HTTP APIs
* Added scheduler worker config API
* Added scheduler worker info API

## New Internals
* (Scheduler)Worker API refactor—Start(), Stop(), Pause(), Resume()
* Update shutdown to use context
* Add mutex for contended server data
    - `workerLock` for the `workers` slice
    - `workerConfigLock` for the `Server.Config.NumSchedulers` and
      `Server.Config.EnabledSchedulers` values

## Other
* Adding docs for scheduler worker api
* Add changelog message

Co-authored-by: Derek Strickland <1111455+DerekStrickland@users.noreply.github.com>
2022-01-06 11:56:13 -05:00
Tim Gross 5cfd55658f prepare for next release 2021-12-13 10:14:22 -05:00
Luiz Aoqui ddf17ea67c
prepare for next release 2021-11-24 14:42:09 -05:00
Luiz Aoqui ed613ea485
prepare for next release 2021-11-22 10:47:51 -05:00
Luiz Aoqui 7e1b2f1147
Merge release 1.2.0 branch (#11513) 2021-11-16 14:16:26 -05:00
Mahmood Ali 73351c35dd
ease building Linux binaries on macOS (#11329)
Meant for development purposes only, so one can compile binary on a
macos host then start a Docker container or scp the binary to a linux
host easily.

The resulting binary is statically linked and has very subtle
differences. e.g. static binaries use go native network stack that
honor /etc/hosts and /etc/resolve differently from the glibc
implementation. In development environment, I don't expect these to
materially change our experience.
2021-10-15 11:12:59 -04:00
Luiz Aoqui 234aac14a8
Merge release branch (#11317) 2021-10-14 13:06:04 -04:00
Dave May 190716b4c6
Remove vendor folder during make clean (#11315)
* Remove vendor folder during make clean
* Add vendor warning to make dev build command
2021-10-14 11:32:19 -04:00
Michael Schurter ff33225acb website: update to 1.1.5
Also update LAST_RELEASE in makefile to 1.1.5
2021-09-20 16:50:37 -07:00
James Rasell 04a15b5c16
Merge pull request #11105 from hashicorp/f-add-staticcheck-ci
ci: add staticcheck with ST1020 and update golangci-lint
2021-09-09 09:42:12 +02:00
Mahmood Ali 906528c197
Format Terraform files (#11099)
Also format terraform scripts with hclfmt, equivalent to terraform fmt.

I opted not to use terraform fmt, because I didn't want to introduce dev dependency on the terraform CLI.

Also, I've optimized the find command to ignore spurious directories (e.g. .git, node_modules) that seem to be populated with too many files! make hclfmt takes 0.3s on my mac down from 7 seconds!
2021-09-01 15:15:06 -04:00
James Rasell 994bd11a2e
ci: update golangci-lint to v1.42.0 2021-08-31 11:13:31 +02:00
Luiz Aoqui 5b50b385e8
make: embed the Nomad UI data by default (#11018) 2021-08-09 16:53:44 -04:00
Mahmood Ali 327ad78ea5 prepare for next dev cycle 2021-07-29 12:32:09 -04:00
Seth Hoenig d7d4b2d8b4 build: no longer use vendor directory
This PR removes the vendor directory from the Nomad repository.
Contributers will no longer need to deal with our `make sync`
step when working on Nomad, which was suprising when making changes
to the api. It also causes huge diffs in PRs that nobody looks at.
2021-07-14 11:13:30 -05:00
Mahmood Ali 94913d2ad6
Adopt go-changelog in Nomad (#10825)
Adopts [`go-changelog`](https://github.com/hashicorp/go-changelog) for managing Nomad's changelog. `go-changelog` is becoming the HashiCorp defacto standard tool for managing changelog, e.g. [Consul](https://github.com/hashicorp/consul/pull/8387), [Vault](https://github.com/hashicorp/vault/pull/10363), [Waypoint](https://github.com/hashicorp/waypoint/pull/1179). [Consul](https://github.com/hashicorp/consul/pull/8387) seems to be the first product to adopt it, and its PR has the most context - though I've updated `.changelog/README.md` with the relevant info here.

## Changes to developers workflow

When opening PRs, developers should add a changelog entry in `.changelog/<PR#>.txt`. Check [`.changelog/README.md`](https://github.com/hashicorp/nomad/blob/docs-adopt-gochangelog/.changelog/README.md#developer-guide). 

For the WIP release, entries can be amended even after the PR merged, and new files may be added post-hoc (e.g. during transition period, missed accidentally, community PRs, etc).

### Transitioning

Pending PRs can start including the changelog entry files immediately.

For 1.1.3/1.0.9 cycle, the release coordinator should create the entries for any PR that gets merged without a changelog entry file. They should also move any 1.1.3 entry in CHANGELOG.md to a changelog entry file, as this PR done for GH-10818.

## Changes to release process

Before cutting a release, release coordinator should update the changelog by inserting the output of `make changelog` to CHANGELOG.md with appropriate headers. See [`.changelog/README.md`](https://github.com/hashicorp/nomad/blob/docs-adopt-gochangelog/.changelog/README.md#how-to-generate-changelog-entries-for-release) for more details.


## Details

go-changelog is a basic templating engine for maintaining changelog in HashiCorp environment.

It expects the changelog entries as files indexed by their PR number. The CLI generates the changelog section for a release by comparing two git references (e.g. `HEAD` and the latest release, e.g. `v1.1.2`), and still requires manual process for updating CHANGELOG.md and final formatting.

The approach has many nice advantages:
* Avoids changelog related merge conflicts: Each PR touches different file!
* Copes with amendments and post-PR updates: Just add or update a changelog entry file using the original PR numbers.
* Addresses the release backporting scenario: Cherry-picking PRs will cherry-pick the relevant changelog entry automatically!
* Only relies on data available through `git` - no reliance on GitHub metadata or require GitHub credentials

The approach has few downsides though:
* CHANGELOG.md going stale during development and must be updated manually before cutting the release
  * Repository watchers can no longer glance at the CHANGELOG.md to see upcoming changes
  * We can periodically update the file, but `go-changelog` tool does not aid with that
* `go-changelog` tool does not offer good error reporting. If an entry is has an invalid tag (e.g. uses `release-note:bugfix` instead of `release-note:bug`), the entry will be dropped silently
  * We should update go-changelog to warn against unexpected entry tags
  * TODO: Meanwhile, PR reviewers and release coordinators should watch out

## Potential follow ups

We should follow up with CI checks to ensure PR changes include a warning. I've opted not to include that now. We still make many non-changelog-worth PRs for website/docs, for large features that get merged in multiple small PRs. I did not want to include a check that fails often.

Also, we should follow up to have `go-changelog` emit better warnings on unexpected tag.
2021-07-06 10:46:53 -04:00
Mahmood Ali b2f9234b30
Merge pull request #10296 from hashicorp/c-script-tweaks-20210402
makefile cleanup
2021-04-07 16:54:43 -04:00
Seth Hoenig 7a6a7e4da1 build: install buf during bootstrap
Previously installing buf was left out of `make bootstrap` because it
had conflicts with the `tools/go.mod` file and dependencies used by
other tools. With Go 1.16 we eliminated that `go.mod` file, and can
now just install `buf` with `go install` like everything else.
2021-04-06 09:42:44 -06:00
Yoan Blanc ac0d5d8bd3
chore: bump golangci-lint from v1.24 to v1.39
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2021-04-03 09:50:23 +02:00
Mahmood Ali 7237785972 Tweak cross compilation Make
Only use cross compile if not compiling in target architecture.

Also, use the latest gcc for cross compilation.
2021-04-02 16:29:57 -04:00
Mahmood Ali 24fe595de4 dev: ignore msgpack codegen code in dev by default
This change disables using msgpack generated serializers in dev by
default.

In released binaries, we use code-generated msgpack serializers to
improve performance.  However, in development, code generated
serializers are a pain. If a developer forgets to re-generate code, the
code generated gets out of sync with the go structs, and result into
subtle bugs where some values appear not to persist as expected.

The CI and release scripts will continue to use the msgpack
code-generation. Devs who want to test locally can set
`GO_TAGS=codegen_generated` as well.
2021-04-01 16:27:18 -04:00
Mahmood Ali fb6d49cc88 use `go install` for tools
Golang 1.16 added better support for installing tools, without updating
go.mod files: https://blog.golang.org/go116-module-changes#TOC_4. .
2021-03-09 14:26:44 -05:00
Mahmood Ali 5a1df47e38 update buf compare tag to latest release 2021-01-31 20:23:22 -05:00
Mahmood Ali ab92d495fc lint: Upgrade buf to 0.36.0, latest so far 2021-01-31 20:09:15 -05:00
Drew Bailey 0fd70d2cb1
tmp remove darwin arm build (#9786) 2021-01-12 15:52:30 -05:00
Kris Hicks 325eeae542
makefile: Set CC explicitly in go build (#9784)
This is required because Go does not pull CC from the make variable. This uses
whatever Go's default CC unless CC is overridden, as it is for the ARM targets.

This also makes it easier to build Nomad on a native ARM device, via:

```
make CC= pkg/linux_arm/nomad
```
2021-01-12 12:09:40 -08:00
Kris Hicks f1b50bcbe7
makefile: Re-scope VERBOSE=true, update build warnings (#9675)
* Set 'only' ALL_TARGETS rather than append

This is functionally no different than before, but it's more correct.

* Re-scope VERBOSE=true

Previously this was only set when the OS was Linux; this was added in
805ade7d3.

* Warn about unsupported OS rather than error

Also:

* Only print the warning when trying to build Nomad
* Print correct list of supported OSes
2020-12-18 09:54:14 -08:00
Kris Hicks 0bdea4435f
makefile: DRY out pkg targets (#9643)
This removes small differences between the targets, like the statement
about what's being built.

The CGO/Windows related comments were deleted as being not relevant. 
See https://github.com/hashicorp/nomad/pull/9643 for context.
2020-12-16 08:01:50 -08:00
Seth Hoenig 83aa566a0c build: add build target for darwin/arm64
Add a build target for Apple Silicon (m1) macs.

Note that Go must have been built with c4f497da6f for
Nomad to work on darwin/arm64 (i.e. wait for go1.16).

Closes #9408
2020-12-15 10:57:50 -06:00
Kris Hicks ad97e1f243
Bump buf check breaking tag to 1.0.0 (#9629) 2020-12-14 09:07:51 -08:00
Steffen c93e6a00d2
on s390x, only compile compile release for s390x (#9601) 2020-12-14 08:27:19 -05:00
Mahmood Ali 8ca33b24f0
Merge pull request #9414 from hashicorp/b-tweak-buf-linter
Parameterize buf compatibility check
2020-11-25 12:19:10 -05:00
Nick Ethier 3483f540b6 api: don't break public API 2020-11-23 10:36:10 -06:00
Mahmood Ali 14fe89003b lint protobuf files 2020-11-20 11:00:24 -05:00
Mahmood Ali ecbae03cf3 Parameterize buf compatibility target
Parameterize it so we can arbitrary target other versions, if we
are doing some manual checking, specially in the beginning when we may
want to validate compatibilities for skip release upgrades.

Also, introduce `checkbuf` target so we can run buf linter without the
rest.

use beta
2020-11-20 11:00:11 -05:00
Kris Hicks 511c2e9db2
proto: Switch to using buf (#9308)
This replaces all usage of `protoc` with `buf`. See `tools/buf/README.md` for more.
2020-11-17 07:01:48 -08:00
Kris Hicks 9d03cf4c5f
protos: Update .proto files not to use Go package name (#9301)
Previously, it was required that you `go get github.com/hashicorp/nomad` to be
able to build protos, as the protoc invocation added an include directive that
pointed to `$GOPATH/src`, which is how dependent protos were discovered. As
Nomad now uses Go modules, it won't necessarily be cloned to `$GOPATH`.
(Additionally, if you _had_ go-gotten Nomad at some point, protoc compilation
would have possibly used the _wrong_ protos, as those wouldn't necessarily be
the most up-to-date ones.)

This change modifies the proto files and the `protoc` invocation to handle
discovering dependent protos via protoc plugin modifier statements that are
specific to the protoc plugin being used.

In this change, `make proto` was run to recompile the protos, which results in
changes only to the gzipped `FileDescriptorProto`.
2020-11-10 08:42:35 -08:00
Seth Hoenig 7a3d8b31da deps: pin a8m/tree to specific hash 2020-10-26 13:44:35 -05:00
Ben Buzbee a5b5681248 Use GOPATH/src explicitly in proto build target
-I ../../.. is meant to navigate from `GOPATH/src/github.com/hashicorp/nomad` to `GOPATH/src`

This is fine but it assumes a few things about how the dev has setup nomad, which is also fine if that is the expected dev environment, however the `../../..` is not as explicit as "GOPATH/src" and it would also enable a few more scenarios so it seems strictly better to me.

Random example: nomad is a subrepo of ours, but with this change we can symlink from GOPATH/src/github.com/hashicorp/nomad and `make proto` will work.
2020-10-15 21:05:27 +00:00
Tim Gross 5dd77d1dc8
ci: make split between e2e and integration tests explicit (#9091)
Currently we compile (but don't run) the e2e tests as part of `test-other`,
which is skipped for branches named `e2e-*`. Move this check into the
`test-e2e` job. Split out the vault compatibility integration check as its own
makefile target for clarity.
2020-10-14 14:53:21 -04:00
Tim Gross 65282a7cf1
E2E: vault secrets (#9081)
* rename vault API compatibility test for clarity
* exercise vault secrets lease renewal
2020-10-14 08:43:28 -04:00
Mahmood Ali fdeafaa9c2 Add a linter for raftutil message type mapping 2020-08-31 08:46:28 -04:00
Tim Gross dde66bd8f8
lint: check for go.mod or go.sum drift (#8765) 2020-08-27 16:21:07 -04:00
Drew Bailey d87c7d3917
use specific sha (#8329)
* use specific sha

* use submodule version
2020-07-01 10:32:45 -04:00
Drew Bailey 463f1986b1
add hclog vet to check step (#8328)
* add hclog vet to check step

* ...
2020-07-01 10:08:37 -04:00
Seth Hoenig 2803ddadab deps: remove tidy from dev makefile target
With Go modules, `go mod tidy` supplants `vendorfmt`. Unfortunately,
`tidy` will try to reach out to the network and download modules, and
there is no way to disable that behavior (e.g. the -mod=vendor) option
does not apply. This means we cannot use the `tidy` target in nomad
enterprise, which will be unable to reach private repositories like
consul-enterprise.

This isn't a big deal, since `vendorfmt` served the purpose of rewriting
the output of `govendor`, wheras `tidy` is a part of the `sync` target
that is required to be run when modifying dependencies anyway.
2020-06-18 08:49:12 -05:00
Mahmood Ali 6ce56a9561 Ensure we are using the latest go-bindata tools
go-bindata released tags are very old, few years old, so ensure we use
the latest master as of now.
2020-06-04 18:49:12 -04:00
Mahmood Ali 82c87cf97b
Vendor gopsutil with go mod fix (#8108)
Point to gopsutil fork with shirou/gopsutil#889 changes. I used hashicorp/gopsutil rather than pointing to https://github.com/Lomanic/gopsutil/tree/issue832 directly just in case..
2020-06-03 16:09:27 -04:00
Seth Hoenig 435c0d9fc8 deps: Switch to Go modules for dependency management
This PR switches the Nomad repository from using govendor to Go modules
for managing dependencies. Aspects of the Nomad workflow remain pretty
much the same. The usual Makefile targets should continue to work as
they always did. The API submodule simply defers to the parent Nomad
version on the repository, keeping the semantics of API versioning that
currently exists.
2020-06-02 14:30:36 -05:00
Seth Hoenig 889e7ddd0c build: use hashicorp hclfmt
We have been using fatih/hclfmt which is long abandoned. Instead, switch
to HashiCorp's own hclfmt implementation. There are some trivial changes in
behavior around whitespace.
2020-05-24 18:31:57 -05:00
Mahmood Ali 4dc72b6a20 makefile to support windows 2020-05-15 12:19:59 -04:00
Drew Bailey 6f6513ffd3
pin golangci-lint dep to 1.24.0 2020-05-13 10:43:39 -04:00
Mahmood Ali 18dba6fdad Harmonize go-msgpack/codec/codecgen
Use v1.1.5 of go-msgpack/codec/codecgen, so go-msgpack codecgen matches
the library version.

We branched off earlier to pick up
f51b518921
, but apparently that's not needed as we could customize the package via
`-c` argument.
2020-04-28 17:12:31 -04:00
Seth Hoenig f2ef576510 demo: create a demo service for grpc healthchecks
Examples for HTTP based task-group service healthchecks are
covered by the `countdash` demo, but gRPC checks currently
have no runnable examples.

This PR adds a trivial gRPC enabled application that provides
a Service implementing the standard gRPC healthcheck interface.
2020-04-24 10:59:50 -06:00
Tim Gross bad9a82df8
ci: add a linting check for HCL files (#7791)
Running `make dev` runs `hclfmt`, but this isn't checked as part of
CI. That makes it possible to merge un-formatted HCL and Nomad
jobspecs that later will make for dirty git staging areas when
developers pull master.

This changeset adds HCL linting to the `make check` target.
2020-04-23 14:32:44 -04:00
Tim Gross e7e9c83aa3
website: fix path for spellchecking and correct errors (#7790) 2020-04-23 10:38:08 -04:00
Mahmood Ali 030e40ac5c
Merge pull request #7652 from hashicorp/v-gomod-msgpaack
dev: Use go mod for managing hashicorp/go-msgpack
2020-04-08 14:42:39 -04:00
Mahmood Ali 00ea28b0cd go mod for go-bindata
Use go mod for github.com/hashicorp/go-bindata/go-bindata and
github.com/elazarl/go-bindata-assetfs/go-bindata-assetfs but use
`@master` to pull the latest master.  These packages don't have release
tags so `@master` worksaround it.
2020-04-08 14:30:37 -04:00
Tim Gross 457b83a967
build: remove working dir from stack traces (#7653)
Adding `-trimpath` to builds removes the local working directory from
the goroutine stack traces, which makes our builds more reproducible
and doesn't leak information about our local development workstations
or CI environment.
2020-04-07 13:32:07 -04:00
Mahmood Ali 89be4e23c3 dev: Use go mod for managing hashicorp/go-msgpack 2020-04-07 10:52:04 -04:00
Mahmood Ali 5378b557e9 Use latest go-bindata and go-bindata-assetfs
These dep tools aren't tagged properly so shouldn't be installed with go
mod
2020-03-31 20:28:25 -04:00
Mahmood Ali 68462d3553 dev: use go mod to install dev dependencies
This allows using https download and go mod cache proxies, over using
git and downloading entire dependencies git history, hopefully,
resulting into a faster installation process.
2020-03-30 21:32:45 -04:00
Michael Schurter 83890f019d
Merge pull request #7254 from jboero/patch-1
Completed a ppc64le build for testing.
2020-03-19 11:07:20 -07:00
JohnnyB 5e58b434ec
Added s390x and ppc64le
IBM testing.
2020-03-12 13:48:29 +00:00
Mahmood Ali b6f3effc5b ci: add a check for non-vendored packages
This check fails the lint-go CI job if nomad references a package that
is not vendored.
2020-03-09 15:25:00 -04:00
JohnnyB fe46bbd31d
Silly copy pasta tabs vs spaces... 🤦 2020-03-03 13:16:45 +00:00
JohnnyB 9a27fab8b2
Completed a ppc64le build for testing.
Ran into this missing target on ppc64le.  Consul had no issue.
2020-03-03 12:25:21 +00:00
Jeff Escalante b34c5aa187
circle config adjustments 2020-02-06 18:58:07 -05:00
Mahmood Ali fbd1c270f7 make: emit explanation for /api isolation
Emit a slightly helpful message when /api depends on nomad internal
packages.
2020-02-03 12:22:10 -05:00
Lang Martin 4f6a8263ef GNUmakefile: report failed path on hclfmt error 2020-01-10 13:17:14 -05:00
Seth Hoenig 37c7e60cd5 spellcheck: add misspell to linter dependencies
You'd think since golangci-lint embeds misspell we could use that,
but it fails to run if it finds no Go source files, which is the
case in our website/ directory that we want to check.
2019-12-05 19:27:14 -06:00
Danielle Lancashire 0071a06c8b chore: Switch from gometalinter to golangci-lint
gometalinter has been deprecated, with golangci-lint as its spiritual
and recommended successor. Here we switch to using it with an equivalent
configuration, albeit with newer versions of some linters.

To maintain compatibility with existing settings, we have a couple of
things disabled here, specifically:

- tests
        We have a lot of unused code in our tests that choke deadcode.
        We should attempt to clean these up soon so that we can lint our
        testcode.
- govet.check-shadowing = false
        This breaks on redefining `err` which we do all over the nomad
        codebase.
2019-12-05 18:58:13 -06:00
Mahmood Ali 9e211ce16f tests appear as github.com/hashicorp/nomad/api.test 2019-11-12 11:33:20 -05:00
Mahmood Ali e1eb1f6bab api: avoid depending on nomad in test files 2019-11-12 09:32:13 -05:00
Mahmood Ali 4e4a9b252c
Merge pull request #6290 from hashicorp/r-generated-code-refactor
dev: avoid codecgen code in downstream projects
2019-10-15 08:22:31 -04:00
Danielle Lancashire 935c86b404
make: Add make task for formatting HCL 2019-10-11 13:59:22 +02:00
Mahmood Ali 29c8fe1ba1
fix typo
Co-Authored-By: Danielle <dani@hashicorp.com>
2019-09-06 10:05:02 -04:00
Mahmood Ali 01f42053e4 dev: avoid codecgen code in downstream projects
This is an attempt to ease dependency management for external driver
plugins, by avoiding requiring them to compile ugorji/go generated
files.  Plugin developers reported some pain with the brittleness of
ugorji/go dependency in particular, specially when using go mod, the
default go mod manager in golang 1.13.

Context
--------

Nomad uses msgpack to persist and serialize internal structs, using
ugorji/go library.  As an optimization, we use ugorji/go code generation
to speedup process and aovid the relection-based slow path.

We commit these generated files in repository when we cut and tag the
release to ease reproducability and debugging old releases.  Thus,
downstream projects that depend on release tag, indirectly depends on
ugorji/go generated code.

Sadly, the generated code is brittle and specific to the version of
ugorji/go being used.  When go mod picks another version of ugorji/go
then nomad (go mod by default uses release according to semver),
downstream projects face compilation errors.

Interestingly, downstream projects don't commonly serialize nomad
internal structs.  Drivers and device plugins use grpc instead of
msgpack for the most part.  In the few cases where they use msgpag (e.g.
decoding task config), they do without codegen path as they run on
driver specific structs not the nomad internal structs.  Also, the
ugorji/go serialization through reflection is generally backward
compatible (mod some ugorji/go regression bugs that get introduced every
now and then :( ).

Proposal
---------

The proposal here is to keep committing ugorji/go codec generated files
for releases but to use a go tag for them.

All nomad development through the makefile, including releasing, CI and
dev flow, has the tag enabled.

Downstream plugin projects, by default, will skip these files and life
proceed as normal for them.

The downside is that nomad developers who use generated code but avoid
using make must start passing additional go tag argument.  Though this
is not a blessed configuration.
2019-09-06 09:22:00 -04:00
Mahmood Ali 41102260ed ignore nested pkgs in GOTEST_PKGS_EXCLUDE
This fixes a bug where some packages tests run twice in CI, because they
are subpackages of ones with dedicated jobs.  For example, notice
`client/allocrunner` tests ran in `test-client`[1] and `test-other`[2] despite
them being in the same workflow[3].

[1] https://circleci.com/gh/hashicorp/nomad/5262
[2] https://circleci.com/gh/hashicorp/nomad/5261
[3] https://circleci.com/workflow-run/ee7a9167-8fc7-49a5-897c-6c967e966014
2019-09-03 11:04:27 -04:00
Mahmood Ali dfa432eb06 lint: ignore protobuf generated code 2019-09-03 10:59:11 -04:00
Danielle Lancashire bc198d9328
chore: Remove unused travis scripts 2019-08-30 13:51:05 +02:00
Mahmood Ali e17d7338fc use circleci/golang images directly
We currently use an container image for `test-devices` job only; while
all other jobs use machine executor.

This allows us to switch golang and protoc verions easily without
manually managing Docker images (which requires building them manually
on a dev machines, etc).  All that while, we install dependencies on
every build in all other jobs..

`test-devices` now is one of the fastest jobs and isn't a constraint or
a bottleneck, so increasing its overhead by few seconds doesn't hurt the
overall developer iteration.

If we split tests effectively later, we can revisit.
2019-08-23 21:59:49 -04:00
Mahmood Ali c832853436 use a new image with proper protoc dependency
Fixes `test-devices` job
2019-08-23 21:33:07 -04:00