cassandra-web icon indicating copy to clipboard operation
cassandra-web copied to clipboard

Resolving FQDN for hostname params

Open aroundthecode opened this issue 6 years ago • 9 comments

Hi @avalanche123 et al.

I've done a small modification to the code in order to let HOST parameter work also with FQDN instead of only IPS.

I'm trying to use cassandra-web in kubernetes environments where IPs cannot be know in advance, so this small fix is really useful to me. Sadly I'm not a ruby developer so I tried to arrange it the best I could, but I'd like to share it to have it included in mainstream (maybe with some more elegant adjustment).

PR also include integration with Travis CI to create docker image and upload it to Docker hub (just change environment variables and secure to work on another account)

aroundthecode avatar Feb 17 '19 21:02 aroundthecode

Ruby driver already performs dns lookup on hostnames, I’m not sure why this is needed

avalanche123 avatar Feb 17 '19 22:02 avalanche123

This is what happens if you pass a fqdn instaed of ip to 0.4.0 version:

✗ docker run -e"CASSANDRA_HOST_IP=www.google.com" delermando/docker-cassandra-web:v0.4.0                                                                                                                                     

cassandra-web --hosts www.google.com --port 9042 --username cassandra --password cassandra
IPAddr::InvalidAddressError: invalid address

Usage: cassandra-web [options]
    -B, --bind BIND                  ip:port or path for cassandra web to bind on (default: 0.0.0.0:3000)
    -H, --hosts HOSTS                coma-separated list of cassandra hosts (default: 127.0.0.1)
    -P, --port PORT                  integer port that cassandra is running on (default: 9042)
    -L, --log-level LEVEL            log level (default: info)
    -u, --username USER              username to use when connecting to cassandra
    -p, --password PASS              password to use when connecting to cassandra
    -C, --compression NAME           compression algorithm to use (lz4 or snappy)
        --server-cert PATH           server ceritificate pathname
        --client-cert PATH           client ceritificate pathname
        --private-key PATH           path to private key
        --passphrase SECRET          passphrase for the private key
    -h, --help                       Show help

aroundthecode avatar Feb 18 '19 12:02 aroundthecode

Hmm, I’ll take a look, we might have to update the version of the ruby driver that cassandra-web is using

avalanche123 avatar Feb 18 '19 12:02 avalanche123

Can you rerun cassandra-web with --debug. And paste the stack-trace

avalanche123 avatar Feb 18 '19 12:02 avalanche123

no change in output ( I suppose you intended -L debug )

docker run -e"CASSANDRA_HOST_IP=www.google.com -L debug " delermando/docker-cassandra-web:v0.4.0

cassandra-web --hosts www.google.com -L debug --port 9042 --username cassandra --password cassandra
IPAddr::InvalidAddressError: invalid address

Usage: cassandra-web [options]
    -B, --bind BIND                  ip:port or path for cassandra web to bind on (default: 0.0.0.0:3000)
    -H, --hosts HOSTS                coma-separated list of cassandra hosts (default: 127.0.0.1)
    -P, --port PORT                  integer port that cassandra is running on (default: 9042)
    -L, --log-level LEVEL            log level (default: info)
    -u, --username USER              username to use when connecting to cassandra
    -p, --password PASS              password to use when connecting to cassandra
    -C, --compression NAME           compression algorithm to use (lz4 or snappy)
        --server-cert PATH           server ceritificate pathname
        --client-cert PATH           client ceritificate pathname
        --private-key PATH           path to private key
        --passphrase SECRET          passphrase for the private key
    -h, --help                       Show help

aroundthecode avatar Feb 18 '19 15:02 aroundthecode

I just realized that the Gemfile.lock was pretty stale and I updated it, can you try again without your patch to ensure you get dns resolving now, thanks!

avalanche123 avatar Feb 28 '19 03:02 avalanche123

For me, version 0.5.0 still doesn't accept hostnames.

ghost avatar Apr 09 '19 10:04 ghost

It's the line Cassandra::LoadBalancing::Policies::WhiteList.new(hosts, ::Cassandra::LoadBalancing::Policies::RoundRobin.new) thats the culprit. It does not accept hostnames in hosts. So I think the patch is still needed.

mwik avatar Jun 19 '19 09:06 mwik

Hi @avalanche123 , Can you take a look at this again?

lanphan avatar Jul 09 '20 04:07 lanphan