Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service advertising behavior differs on Windows vs. Linux #177

Closed
webcoyote opened this issue May 28, 2014 · 6 comments
Closed

Service advertising behavior differs on Windows vs. Linux #177

webcoyote opened this issue May 28, 2014 · 6 comments

Comments

@webcoyote
Copy link

The Windows and Linux versions of consul behave differently: the Windows version is >not< advertising a service in catalog/services though it is listed in agent/services, whereas it >is< advertising in both on Linux. This issue is 100% reproducible on my computers, not random behavior.

The key difference in the output is:

Linux: ~$ time curl localhost:8500/v1/catalog/services
{"consul":[],"test":["blah"]}

Windows: ~$ time curl localhost:8500/v1/catalog/services
{"consul":null}

Note also the long time it takes for Windows to respond to queries compared to Linux.

In command shell 1, run consul

mkdir -p ~/consul/test/consul.d
cd ~/consul/test
echo '{"service":{"name": "test","tags": ["blah"],"port": 9001,"check":{"name": "Test status","ttl": "15s"}}}' > ./consul.d/test.json
rm ./data -rf ; GOMAXPROCS=2 consul agent -bootstrap -server -data-dir=./data -bind=127.0.0.1 -config-dir=./consul.d -log-level=trace -node="$OSTYPE"

In command shell 2, run tests

time curl localhost:8500/v1/agent/services
time curl localhost:8500/v1/agent/checks
time curl localhost:8500/v1/catalog/services

Linux test output

~$ time curl localhost:8500/v1/agent/services
{"test":{"ID":"test","Service":"test","Tags":["blah"],"Port":9001}}

real  0m0.005s
user  0m0.000s
sys 0m0.000s
pat@vm88-UL:~$ time curl localhost:8500/v1/agent/checks
{"service:test":{"Node":"linux-gnu","CheckID":"service:test","Name":"Service 'test' check","Status":"unknown","Notes":"","Output":"","ServiceID":"test","ServiceName":"test"}}

real  0m0.004s
user  0m0.000s
sys 0m0.000s
pat@vm88-UL:~$ time curl localhost:8500/v1/catalog/services
{"consul":[],"test":["blah"]}

real  0m0.007s
user  0m0.000s
sys 0m0.004s
~$ 

Windows test output

~$ time curl localhost:8500/v1/agent/services
{"test":{"ID":"test","Service":"test","Tags":["blah"],"Port":9001}}

real    0m2.039s
user    0m0.015s
sys     0m0.000s
~$ time curl localhost:8500/v1/agent/checks
{"service:test":{"Node":"msys","CheckID":"service:test","Name":"Service 'test' check","Status":"unknown","Notes":"Initializing","ServiceID":"test","ServiceName":"test"}}

real    0m2.038s
user    0m0.016s
sys     0m0.000s
~$ time curl localhost:8500/v1/catalog/services
{"consul":null}

real    0m1.028s
user    0m0.015s
sys     0m0.000s
~$

Linux consul output

~/consul/test$ rm ./data -rf ; GOMAXPROCS=2 consul agent -bootstrap -server -data-dir=./data -bind=127.0.0.1 -config-dir=./consul.d -log-level=trace -node="$OSTYPE"
==> WARNING: Bootstrap mode enabled! Do not enable unless necessary
==> Starting Consul agent...
==> Starting Consul agent RPC...
==> Consul agent running!
       Node name: 'linux-gnu'
      Datacenter: 'dc1'
          Server: true (bootstrap: true)
     Client Addr: 127.0.0.1 (HTTP: 8500, DNS: 8600, RPC: 8400)
    Cluster Addr: 127.0.0.1 (LAN: 8301, WAN: 8302)

==> Log data will now stream in as it occurs:

    2014/05/28 10:24:36 [INFO] raft: Node at 127.0.0.1:8300 [Follower] entering Follower state
    2014/05/28 10:24:36 [INFO] serf: EventMemberJoin: linux-gnu 127.0.0.1
    2014/05/28 10:24:36 [INFO] serf: EventMemberJoin: linux-gnu.dc1 127.0.0.1
    2014/05/28 10:24:36 [INFO] consul: adding server for datacenter: dc1, addr: 127.0.0.1:8300
    2014/05/28 10:24:36 [DEBUG] dns: request for {_test.consul. 255 1} (95.541us)
    2014/05/28 10:24:36 [DEBUG] dns: request for {_test.consul. 255 1} (144.149us)
    2014/05/28 10:24:36 [ERR] agent: failed to sync remote state: rpc error: No cluster leader
    2014/05/28 10:24:37 [WARN] raft: Heartbeat timeout reached, starting election
    2014/05/28 10:24:37 [INFO] raft: Node at 127.0.0.1:8300 [Candidate] entering Candidate state
    2014/05/28 10:24:37 [DEBUG] raft: Votes needed: 1
    2014/05/28 10:24:37 [DEBUG] raft: Vote granted. Tally: 1
    2014/05/28 10:24:37 [INFO] raft: Election won. Tally: 1
    2014/05/28 10:24:37 [INFO] raft: Node at 127.0.0.1:8300 [Leader] entering Leader state
    2014/05/28 10:24:37 [INFO] consul: cluster leadership acquired
    2014/05/28 10:24:37 [INFO] consul: New leader elected: linux-gnu
    2014/05/28 10:24:37 [INFO] consul: member 'linux-gnu' joined, marking health alive
    2014/05/28 10:24:39 [INFO] agent: Synced service 'test'
    2014/05/28 10:24:39 [INFO] agent: Synced check 'service:test'
    2014/05/28 10:24:45 [DEBUG] http: Request /v1/agent/services (94.144us)
    2014/05/28 10:24:45 [DEBUG] http: Request /v1/agent/checks (39.39us)
    2014/05/28 10:24:46 [DEBUG] http: Request /v1/catalog/services (1.257678ms)
    2014/05/28 10:24:51 [WARN] Check 'service:test' missed TTL, is now critical
    2014/05/28 10:24:51 [DEBUG] agent: Service 'test' in sync
    2014/05/28 10:24:51 [INFO] agent: Synced check 'service:test'

Windows consul output

~/consul/test$ rm ./data -rf ; GOMAXPROCS=2 consul agent -bootstrap -server -data-dir=./data -bind=127.0.0.1 -config-dir=./consul.d -log-level=trace -node="$OSTYPE"
==> WARNING: Bootstrap mode enabled! Do not enable unless necessary
==> WARNING: Windows is not recommended as a Consul server. Do not use in production.
==> Starting Consul agent...
==> Starting Consul agent RPC...
==> Consul agent running!
       Node name: 'msys'
      Datacenter: 'dc1'
          Server: true (bootstrap: true)
     Client Addr: 127.0.0.1 (HTTP: 8500, DNS: 8600, RPC: 8400)
    Cluster Addr: 127.0.0.1 (LAN: 8301, WAN: 8302)

==> Log data will now stream in as it occurs:

    2014/05/28 10:22:43 [INFO] raft: Node at 127.0.0.1:8300 [Follower] entering Follower state
    2014/05/28 10:22:43 [INFO] serf: EventMemberJoin: msys 127.0.0.1
    2014/05/28 10:22:43 [INFO] serf: EventMemberJoin: msys 127.0.0.1
    2014/05/28 10:22:43 [INFO] consul: adding server for datacenter: dc1, addr: 127.0.0.1:8300
    2014/05/28 10:22:43 [DEBUG] dns: request for {_test.consul. 255 1} (0)
    2014/05/28 10:22:43 [DEBUG] dns: request for {_test.consul. 255 1} (0)
    2014/05/28 10:22:43 [ERR] agent: failed to sync remote state: rpc error: No cluster leader
    2014/05/28 10:22:43 [ERR] agent: failed to sync remote state: rpc error: No cluster leader
    2014/05/28 10:22:44 [WARN] raft: Heartbeat timeout reached, starting election
    2014/05/28 10:22:44 [INFO] raft: Node at 127.0.0.1:8300 [Candidate] entering Candidate state
    2014/05/28 10:22:44 [DEBUG] raft: Votes needed: 1
    2014/05/28 10:22:44 [DEBUG] raft: Vote granted. Tally: 1
    2014/05/28 10:22:44 [INFO] raft: Election won. Tally: 1
    2014/05/28 10:22:44 [INFO] raft: Node at 127.0.0.1:8300 [Leader] entering Leader state
    2014/05/28 10:22:44 [INFO] consul: cluster leadership acquired
    2014/05/28 10:22:44 [INFO] consul: New leader elected: msys
    2014/05/28 10:22:44 [INFO] consul: member 'msys' joined, marking health alive
    2014/05/28 10:22:51 [DEBUG] http: Request /v1/agent/services (0)
    2014/05/28 10:22:53 [DEBUG] http: Request /v1/agent/checks (0)
    2014/05/28 10:22:54 [DEBUG] http: Request /v1/catalog/services (500.1us)
    2014/05/28 10:22:58 [WARN] Check 'service:test' missed TTL, is now critical
@webcoyote
Copy link
Author

The problem may be related to this:

Linux

~$ curl -X PUT http://localhost:8500/v1/agent/service/register -d '{"name": "test2","port": 9002,"check"
:{"name": "Test2 status","ttl": "15s"}}'
==> no output

Windows

~$ curl -X PUT http://localhost:8500/v1/agent/service/register -d '{"name": "test2","port": 9002,"check"
:{"name": "Test2 status","ttl": "15s"}}'
==> Request decode failed: json: cannot unmarshal string into Go value of type time.Duration

@armon
Copy link
Member

armon commented May 28, 2014

Are you running the latest version for both? The decoding error was fixed in 0.2 I believe.

@webcoyote
Copy link
Author

I thought I was running latest but it turns out that the Windows binary built for v0.2.1 contains the wrong version:
https://dl.bintray.com/mitchellh/consul/0.2.1_windows_386.zip <<< actually v0.1.0
Edit: It turns out that 0.2.0_windows_386.zip is also actually version v0.1.0

@armon
Copy link
Member

armon commented May 28, 2014

Oh yikes! I will try to get a new binary uploaded today. I'll bug @mitchellh since he has a windows machine.

@webcoyote
Copy link
Author

I compiled consul from source and that version functions properly on Windows.

@armon
Copy link
Member

armon commented May 29, 2014

@webcoyote The download for 0.2.1 should be fixed now! Thanks for reporting!

@armon armon closed this as completed May 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants