Commit Graph

1148 Commits

Author SHA1 Message Date
Alex Dadgar
5aa6e18807 Use batching 2017-05-01 14:50:34 -07:00
Alex Dadgar
9def7e1a14 Don't deepcopy job when retrieving copy of Alloc
This PR removes deepcopying of the job attached to the allocation in the
alloc runner. This operation is called very often so removing reflect
from the code path and the potentially large number of mallocs need to
create a job reduced memory and cpu pressure.
2017-05-01 14:50:34 -07:00
Alex Dadgar
6a9af5a216 Agent test 2017-04-20 11:14:06 -07:00
Alex Dadgar
99e9f2aaaa Agent revert 2017-04-20 11:14:06 -07:00
Michael Schurter
58430bf062 Fix consul test build on Windows 2017-04-19 16:14:11 -07:00
Michael Schurter
b9ea2765ec Thanks go vet! 2017-04-19 13:05:41 -07:00
Michael Schurter
4cf34edb29 Skip checks with TLSSkipVerify if it's unsupported
Fixes #2218
2017-04-19 12:45:34 -07:00
Michael Schurter
7c67166510 Add TLSSkipVerify support to api and parser 2017-04-19 12:45:34 -07:00
Michael Schurter
64057d48fe Use go-version instead of manual version parsing 2017-04-19 12:42:48 -07:00
Michael Schurter
6d9e61bb51 Use spiffy new Go 1.8 subtest feature 2017-04-19 12:42:48 -07:00
Michael Schurter
5948daf4f7 Forgot an important word 2017-04-19 12:42:48 -07:00
Michael Schurter
346838381b Only register HTTPS agent check when Consul>=0.7.2
Support for TLSSkipVerify in other checks coming soon!
2017-04-19 12:42:48 -07:00
Michael Schurter
f0bec63174 Explain weird timer logic 2017-04-19 12:42:48 -07:00
Michael Schurter
de3d78365e Metricsify new Consul client 2017-04-19 12:42:48 -07:00
Michael Schurter
d3f3af8bf9 Always fail script checks when deadline exceeded 2017-04-19 12:42:48 -07:00
Michael Schurter
465cc5157b Test script check exit codes 2017-04-19 12:42:47 -07:00
Michael Schurter
6a56b0efc6 Follow _testing.go convention for testing tools 2017-04-19 12:42:47 -07:00
Michael Schurter
927b265854 Rework to account for ports not being in IDs
Previous implementation assumed all struct fields were included in
service and check IDs. Service IDs never include port labels and check
IDs *optionally* include port labels, so lots of things had to change.

Added a really big test to exercise this.
2017-04-19 12:42:47 -07:00
Michael Schurter
7de3adaf87 Remove commits return value
...and still protect against leaking agent entries in Consul on
shutdown.
2017-04-19 12:42:47 -07:00
Michael Schurter
5d75efc397 Explain PortLabel handling in RegisterAgent 2017-04-19 12:42:47 -07:00
Michael Schurter
48269c36b0 Plumb alloc id + task name into script check logs 2017-04-19 12:42:47 -07:00
Michael Schurter
80617a9c1a Stop being lazy and just type out struct{}{} 2017-04-19 12:42:47 -07:00
Michael Schurter
7ac9215fb7 Use nifty testtask sleep command for xplat compat 2017-04-19 12:42:47 -07:00
Michael Schurter
4002d87a6b Add comments, clarify names, fix PR comments 2017-04-19 12:42:47 -07:00
Michael Schurter
b4c7d92936 Explain cleanup defer in test 2017-04-19 12:42:47 -07:00
Michael Schurter
a3fc76b63a Fix comment to reflect reality 2017-04-19 12:42:47 -07:00
Michael Schurter
63a8307255 Move ScriptExecutor to driver 2017-04-19 12:42:47 -07:00
Michael Schurter
b4e40efa15 Fix shutdown when consul is down 2017-04-19 12:42:47 -07:00
Michael Schurter
80882f3e0e Switch ServiceClient to synchronizing state
Previously it applied a stream of operations. Reconciling state is less
complex and error prone at the cost of slightly higher CPU/memory usage.
2017-04-19 12:42:47 -07:00
Michael Schurter
b6937912d8 Add UpdateTask method instead of Remove/Add 2017-04-19 12:42:47 -07:00
Michael Schurter
7930d35925 Remove some lies 2017-04-19 12:42:47 -07:00
Michael Schurter
e13b149628 Remove unused syncInterval 2017-04-19 12:42:47 -07:00
Michael Schurter
10cb924b2c Refactor Consul Syncer into new ServiceClient
Fixes #2478 #2474 #1995 #2294

The new client only handles agent and task service advertisement. Server
discovery is mostly unchanged.

The Nomad client agent now handles all Consul operations instead of the
executor handling task related operations. When upgrading from an
earlier version of Nomad existing executors will be told to deregister
from Consul so that the Nomad agent can re-register the task's services
and checks.

Drivers - other than qemu - now support an Exec method for executing
abritrary commands in a task's environment. This is used to implement
script checks.

Interfaces are used extensively to avoid interacting with Consul in
tests that don't assert any Consul related behavior.
2017-04-19 12:42:47 -07:00
Alex Dadgar
ea15f4b05e Diff code fixes 2017-04-16 16:54:40 -07:00
Alex Dadgar
376e177836 Status shows type of job 2017-04-15 17:08:05 -07:00
Alex Dadgar
5e1e7afc62 GC and some fixes 2017-04-15 17:08:05 -07:00
Alex Dadgar
950171f094 non-purge deregisters 2017-04-15 17:08:05 -07:00
Alex Dadgar
330800f683 Agent API + api package 2017-04-15 17:08:05 -07:00
Alex Dadgar
0c94d4822b Upsert Job Histories 2017-04-15 17:08:05 -07:00
Adam Stankiewicz
4d465091dd Remove unnecessary parameter from NewHTTPServer 2017-04-10 16:24:49 +02:00
Alex Dadgar
d212f6fe94 Track task start/finish time & improve logs errors
This PR adds tracking to when a task starts and finishes and the logs
API takes advantage of this and returns better errors when asking for
logs that do not exist.
2017-03-31 16:14:11 -07:00
Alex Dadgar
06135c50af Fix dispatch of periodic job
This PR fixes an issue in which when a periodic and parameterized job
was dispatched, an allocation would be immediately created.

Fixes https://github.com/hashicorp/nomad/issues/2470
2017-03-27 16:55:17 -07:00
Alex Dadgar
456da65303 Fix output alignment and remove no-change DC
Old Output:

```
+/- Job: "example"
    Datacenters {
  Datacenters: "dc1"
}
+/- Task Group: "cache" (1 create/destroy update)
  +/- RestartPolicy {
    +/- Attempts: "10" => "9"
        Delay:    "25000000000"
        Interval: "300000000000"
        Mode:     "delay"
  }
  +/- EphemeralDisk {
        Migrate: "false"
    +/- SizeMB:  "300" => "301"
        Sticky:  "false"
  }
  +/- Task: "redis" (forces create/destroy update)
    +   Meta[key]: "value"
    +/- Config {
          image:           "redis:3.2"
      +/- port_map[0][db]: "6379" => "6380"
    }
    +/- Resources {
          CPU:      "500"
          DiskMB:   "0"
          IOPS:     "0"
      +/- MemoryMB: "256" => "257"
    }
    +/- Service {
          Name:      "global-redis-check"
          PortLabel: "db"
      +/- Check {
            Command:       ""
            InitialStatus: ""
            Interval:      "10000000000"
            Name:          "alive"
            Path:          ""
            PortLabel:     ""
            Protocol:      ""
        +/- Timeout:       "2000000000" => "3000000000"
            Type:          "tcp"
      }
    }
```

New Output:

```
+/- Job: "example"
+/- Task Group: "cache" (1 create/destroy update)
  +/- RestartPolicy {
    +/- Attempts: "10" => "9"
        Delay:    "25000000000"
        Interval: "300000000000"
        Mode:     "delay"
      }
  +/- EphemeralDisk {
        Migrate: "false"
    +/- SizeMB:  "300" => "301"
        Sticky:  "false"
      }
  +/- Task: "redis" (forces create/destroy update)
    +   Meta[key]: "value"
    +/- Config {
          image:           "redis:3.2"
      +/- port_map[0][db]: "6379" => "6380"
        }
    +/- Resources {
          CPU:      "500"
          DiskMB:   "0"
          IOPS:     "0"
      +/- MemoryMB: "256" => "257"
        }
    +/- Service {
          Name:      "global-redis-check"
          PortLabel: "db"
      +/- Check {
            Command:       ""
            InitialStatus: ""
            Interval:      "10000000000"
            Name:          "alive"
            Path:          ""
            PortLabel:     ""
            Protocol:      ""
        +/- Timeout:       "2000000000" => "3000000000"
            Type:          "tcp"
          }
        }
```
2017-03-21 11:31:06 -07:00
Alex Dadgar
6ac999a5e5 Flush logs on err 2017-03-14 14:48:39 -07:00
Alex Dadgar
bfebe1afdc rename cpu_total_compute and docs 2017-03-14 14:15:49 -07:00
Alex Dadgar
36dc330737 Various fixes
This PR:
* Uses Go 1.8 executable lookup
* Stores any err message from stats init method
* Allows overriding of Cpu Compute for hosts where it can't be detected
2017-03-14 12:56:31 -07:00
Alex Dadgar
97a4e136a6 Merge pull request #2427 from hashicorp/f-gc-limit
Limit parallelism during garbage collection
2017-03-14 10:45:29 -07:00
Alex Dadgar
701537e9c5 Limit parallelism during garbage collection
This PR introduces a parallelism limit during garbage collection. This
is used to avoid large resource usage spikes if garbage collecting many
allocations at once.
2017-03-10 16:27:00 -08: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
be1b4c44f8 Merge pull request #2398 from TheBits/master
Remove 'disk space' from docs
2017-03-06 14:52:12 -08:00