NOTE - An updated and more complete example can be found here.
Here's acl.json:
{| goroutine profile: total 1272 | |
| 1131 @ 0x42d6ec 0x42d7de 0x43ed74 0x43e999 0x473b79 0xa287a1 0xf2a44f 0xf2f72d 0xf78b28 0xf72c65 0xf71685 0x684dc4 0x686580 0x687af4 0x683c9d 0x45ce61 | |
| # 0x43e998 sync.runtime_Semacquire+0x38 /goroot/src/runtime/sema.go:56 | |
| # 0x473b78 sync.(*RWMutex).RLock+0x48 /goroot/src/sync/rwmutex.go:50 | |
| # 0xa287a0 github.com/hashicorp/consul/agent/local.(*State).Stats+0x50 /gopath/src/github.com/hashicorp/consul/agent/local/state.go:567 | |
| # 0xf2a44e github.com/hashicorp/consul/agent.(*Agent).Stats+0x21e /gopath/src/github.com/hashicorp/consul/agent/agent.go:2049 | |
| # 0xf2f72c github.com/hashicorp/consul/agent.(*HTTPServer).AgentSelf+0x3ac /gopath/src/github.com/hashicorp/consul/agent/agent_endpoint.go:75 | |
| # 0xf78b27 github.com/hashicorp/consul/agent.(*HTTPServer).AgentSelf-fm+0x47 /gopath/src/github.com/hashicorp/consul/agent/http.go:101 | |
| # 0xf72c64 github.com/hashicorp/consul/agent.(*HTTPServer).wrap.func1+0x664 /gopath/src/github.com/hashicorp/consul/agent/http.go:272 | |
| # 0xf71684 githu |
| #include <stdlib.h> | |
| #include <sys/resource.h> | |
| int main() { | |
| struct rlimit limit; | |
| limit.rlim_cur = 4096; | |
| limit.rlim_max = 4096; | |
| int ret; | |
| ret = prlimit(18048, RLIMIT_NOFILE, &limit, NULL); |
NOTE - An updated and more complete example can be found here.
Here's acl.json:
{| package main | |
| import ( | |
| "log" | |
| "github.com/hashicorp/consul/api" | |
| ) | |
| func main() { | |
| client, err := api.NewClient(api.DefaultConfig()) |
| panic: in txn 802578 node leaf channel closed in 0 | |
| goroutine 52 [running]: | |
| panic(0xee1140, 0xc454d24f40) | |
| /usr/local/go/src/runtime/panic.go:500 +0x1a1 | |
| github.com/hashicorp/consul/vendor/github.com/hashicorp/go-immutable-radix.(*Txn).writeNode(0xc4533a4320, 0xc44eede460, 0xc42038d401, 0x1) | |
| /root/go/src/github.com/hashicorp/consul/vendor/github.com/hashicorp/go-immutable-radix/iradix.go:164 +0x5cb | |
| github.com/hashicorp/consul/vendor/github.com/hashicorp/go-immutable-radix.(*Txn).delete(0xc4533a4320, 0xc44eede4b0, 0xc44eede460, 0xc454d24ecf, 0x0, 0x1, 0x1, 0x1) | |
| /root/go/src/github.com/hashicorp/consul/vendor/github.com/hashicorp/go-immutable-radix/iradix.go:302 +0x169 | |
| github.com/hashicorp/consul/vendor/github.com/hashicorp/go-immutable-radix.(*Txn).delete(0xc4533a4320, 0xc4533ddcc0, 0xc44eede4b0, 0xc454d24ecc, 0x3, 0x4, 0x1, 0x8) |
| diff --git a/command/agent/dns.go b/command/agent/dns.go | |
| index 7f373cd4..9fa78b66 100644 | |
| --- a/command/agent/dns.go | |
| +++ b/command/agent/dns.go | |
| @@ -270,6 +270,9 @@ func (d *DNSServer) handleQuery(resp dns.ResponseWriter, req *dns.Msg) { | |
| if err := resp.WriteMsg(m); err != nil { | |
| d.logger.Printf("[WARN] dns: failed to respond: %v", err) | |
| } | |
| + if m.MsgHdr.Rcode != 0 { | |
| + d.logger.Printf("[TRACE] dns: request for %v failed: rcode=%s", q, dns.RcodeToString[m.MsgHdr.Rcode]) |
| { | |
| "Config": { | |
| "DevMode": true, | |
| "Bootstrap": false, | |
| "BootstrapExpect": 0, | |
| "Server": true, | |
| "Datacenter": "dc1", | |
| "DataDir": "", | |
| "DNSRecursor": "", | |
| "DNSRecursors": [], |
| { | |
| "Name": "", | |
| "Template": { | |
| "Type": "name_prefix_match" | |
| }, | |
| "Service": { | |
| "Service": "${name.full}", | |
| "Failover": { | |
| "NearestN": 3 | |
| } |
Here's a basic watch script that will look through the output for serfHealth checks in
the critical state. The serfHealth check is a built-in check added by Consul that keeps
track of the health of a node. When this watch handler fires, it will get the JSON body of
the health endpoint passed
to it over stdin.
#!/bin/sh
for node in $(jq '.[] | select(.CheckID=="serfHealth" and .Status=="critical") | .Node' -); do
echo "$node is dead"
dig @127.0.0.1 -p8600 nope.node.consul
; <<>> DiG 9.8.3-P1 <<>> @127.0.0.1 -p8600 nope.node.consul
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 14084
;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; WARNING: recursion requested but not available