mdevilliers / redishappy

Redis Sentinel high availabillity daemon
Apache License 2.0
114 stars 23 forks source link

redis-consul isn't sending complete register message #61

Closed rumenvasilev closed 7 years ago

rumenvasilev commented 7 years ago

For some reason, redis-consul is sending empty "Address" field inside the register request. Consul version is 0.7.1. Here's an excerpt from tcpdump:

IP 127.0.0.1.42980 > 127.0.0.1.fmtp: tcp 311
E..k..@.@.|...........!4..\.M%.r...V._.....
.$...$..PUT /v1/catalog/register HTTP/1.1
Host: 127.0.0.1:8500
User-Agent: Go-http-client/1.1
Content-Length: 176
Accept-Encoding: gzip

{"Node":"ip-10-5-4-97","Address":"","Datacenter":"live","Service":{"ID":"redishappy-consul-redis-live","Service":"redis-live","Tags":["redis","master"],"Port":0},"Check":null}

IP 127.0.0.1.fmtp > 127.0.0.1.42980: tcp 0
E..4*.@.@...........!4..M%.r..]J...^.(.....
.$...$..
IP 127.0.0.1.fmtp > 127.0.0.1.42980: tcp 176
E...*.@.@..K........!4..M%.r..]J...^.......
.$...$..HTTP/1.1 500 Internal Server Error
Date: Tue, 20 Dec 2016 10:55:22 GMT
Content-Length: 40
Content-Type: text/plain; charset=utf-8

rpc error: Must provide node and address

Config file:

{
  "SentinelTCPKeepAlive": 0,
  "Clusters": [
    {
      "name": "redis-live",
      "externalPort": 6380
    }
  ],
  "sentinels": [
    {
      "host": "10.5.4.97",
      "port": 26379
    }
  ],
  "consul": {
    "address": "127.0.0.1:8500",
    "services": [
      {
        "cluster": "redis-live",
        "node": "ip-10-5-4-97",
        "datacenter": "live",
        "tags": [
          "redis",
          "master"
        ]
      }
    ]
  }
}

Sentinels are discovered:

[root@ip-10-5-4-97 ~]# curl localhost:8000/api/sentinels 2>/dev/null | python -m json.tool
{
    "sentinels": {
        "10.5.133.98:26379": {
            "clusters": [
                "mymaster"
            ],
            "lastUpdated": "2016-12-20T11:07:03.835668822Z",
            "sentinelLocation": "10.5.133.98:26379",
            "state": 3
        },
        "10.5.4.97:26379": {
            "clusters": [
                "mymaster"
            ],
            "lastUpdated": "2016-12-20T11:07:03.223261374Z",
            "sentinelLocation": "10.5.4.97:26379",
            "state": 3
        },
        "10.5.69.31:26379": {
            "clusters": [
                "mymaster"
            ],
            "lastUpdated": "2016-12-20T11:07:03.835097067Z",
            "sentinelLocation": "10.5.69.31:26379",
            "state": 3
        }
    }
}
rumenvasilev commented 7 years ago

Just found the problem. Not a bug, but a misunderstanding of the documentation. Cluster name should be the name of the redis cluster, as defined in redis/sentinel, and not how it should appear in consul (as I originally thought).

  "Clusters": [
    {
      "name": "mymaster",
      "externalPort": 6380
    }
  ],