airbnb/synapse

Missing discovery method when trying to create watcher

Closed this issue · 6 comments

Hello,

I am trying to get Synapse up and running, however, I have encountered the following error:

/usr/local/lib/ruby/gems/2.1.0/gems/synapse-0.10.0/lib/synapse/service_watcher.rb:24:in `create': Missing discovery method when trying to create watcher (ArgumentError)
    from /usr/local/lib/ruby/gems/2.1.0/gems/synapse-0.10.0/lib/synapse.rb:72:in `block in create_service_watchers'
    from /usr/local/lib/ruby/gems/2.1.0/gems/synapse-0.10.0/lib/synapse.rb:71:in `each'
    from /usr/local/lib/ruby/gems/2.1.0/gems/synapse-0.10.0/lib/synapse.rb:71:in `create_service_watchers'
    from /usr/local/lib/ruby/gems/2.1.0/gems/synapse-0.10.0/lib/synapse.rb:18:in `initialize'
    from /usr/local/lib/ruby/gems/2.1.0/gems/synapse-0.10.0/bin/synapse:59:in `new'
    from /usr/local/lib/ruby/gems/2.1.0/gems/synapse-0.10.0/bin/synapse:59:in `<top (required)>'
    from /usr/local/bin/synapse:23:in `load'
    from /usr/local/bin/synapse:23:in `<main>'

My config looks like this:


---
  services: 
    application: 
      default_servers: 
        - 
          name: "default-app"
          host: "111.111.111.111"
          port: 443
      discovery: 
        method: "zookeeper"
        path: "/services/application"
        hosts: 
          - "xhbtr.site.com:2181"
          - "xhbtr2.site.com:2181"
          - "xhbtr3.site.com:2181"
      haproxy: 
        port: 3214
        server_options: "check inter 2s rise 3 fall 2"
        listen: 
          - "mode http"
          - "option httpchk /health"
          - "http-check expect string OK"
    haproxy: 
      reload_command: "sudo service haproxy reload"
      config_file_path: "/etc/haproxy/haproxy.cfg"
      socket_file_path: "/var/haproxy/stats.sock"
      do_writes: true
      do_reloads: true
      do_socket: false
      global: 
        - "daemon"
        - "user haproxy"
        - "group haproxy"
        - "maxconn 4096"
        - "log     127.0.0.1 local0"
        - "log     127.0.0.1 local1 notice"
        - "stats   socket /var/haproxy/stats.sock mode 666 level admin"
      defaults: 
        - "log      global"
        - "option   dontlognull"
        - "maxconn  2000"
        - "retries  3"
        - "timeout  connect 5s"
        - "timeout  client  1m"
        - "timeout  server  1m"
        - "option   redispatch"
        - "balance  leastconn"
      extra_sections: 
        listen stats :3212: 
          - "mode http"
          - "stats enable"
          - "stats uri /"
          - "stats refresh 5s"

What am I missing?

Thanks!

the reason is that your haproxy section is at the same level of indentation as the application section, under services; haproxy should be a top-level key, at the same level as services instead of under it. currently, it looks like you have no haproxy section but two services, one application which a valid discovery method and one haproxy with no valid discovery method.

this took me a long time to spot. the point of YAML was to make writing these kinds of configs easier, but it still doesn't do an amazing job...

Thank you, Igor! Looks like this has taken me a step forward.

However, now I get:

/usr/local/lib/ruby/gems/2.1.0/gems/synapse-0.10.0/lib/synapse/service_watcher.rb:28:in `create': Invalid discovery method ["zookeeper"] (ArgumentError)
    from /usr/local/lib/ruby/gems/2.1.0/gems/synapse-0.10.0/lib/synapse.rb:72:in `block in create_service_watchers'
    from /usr/local/lib/ruby/gems/2.1.0/gems/synapse-0.10.0/lib/synapse.rb:71:in `each'
    from /usr/local/lib/ruby/gems/2.1.0/gems/synapse-0.10.0/lib/synapse.rb:71:in `create_service_watchers'
    from /usr/local/lib/ruby/gems/2.1.0/gems/synapse-0.10.0/lib/synapse.rb:18:in `initialize'
    from /usr/local/lib/ruby/gems/2.1.0/gems/synapse-0.10.0/bin/synapse:59:in `new'
    from /usr/local/lib/ruby/gems/2.1.0/gems/synapse-0.10.0/bin/synapse:59:in `<top (required)>'
    from /usr/local/bin/synapse:23:in `load'
    from /usr/local/bin/synapse:23:in `<main>'

I have tried to follow the project documentation, but it seems like it's a bit outdated (with YAML instead of JSON, and apparently the methods). Would be glad to help fix it up once I understand how to make it work.

why is it ["zookeeper"] in square brackets? are you accidentally creating a yaml list?

That's the thing, my YAML does not contain any square brackets, nor does it have the hyphen+space that indicates a list in the case of discovery method.

I have tried a number of variations, with no luck.

It currently looks like this:

services:
 application:
  default_servers:
    name: "default-app"
    host: "111.111.111.111"
    port: 443
  discovery:
    method: "zookeeper"
    path: "/services/application"
    hosts:
     - "xhbtr.site.com:2181"
     - "xhbtr2.site.com:2181"
     - "xhbtr3.site.com:2181"
  haproxy:
    port: 3213
    server_options: "check inter 2s rise 3 fall 2"
    listen:
     - "mode http"
     - "option httpchk /health"
     - "http-check expect string OK"
haproxy:
 reload_command: "sudo service haproxy reload"
 config_file_path: "/etc/haproxy/haproxy.cfg"
 socket_file_path: "/var/haproxy/stats.sock"
 do_writes: true
 do_reloads: true
 do_socket: false
 global:
  - "daemon"
  - "user haproxy"
  - "group haproxy"
  - "maxconn 4096"
  - "log     127.0.0.1 local0"
  - "log     127.0.0.1 local1 notice"
  - "stats   socket /var/haproxy/stats.sock mode 666 level admin"
 defaults:
  - "log      global"
  - "option   dontlognull"
  - "maxconn  2000"
  - "retries  3"
  - "timeout  connect 5s"
  - "timeout  client  1m"
  - "timeout  server  1m"
  - "option   redispatch"
  - "balance  leastconn"
 extra_sections:
  listen stats :3212:
   - "mode http"
   - "stats enable"
   - "stats uri /"
   - "stats refresh 5s"

Figured it out, had an extra space that I didn't notice.

--comment moved to a separate ticket--