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

Resolving FQDN for hostname params #17

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

aroundthecode
Copy link

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)

@avalanche123
Copy link
Owner

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

@aroundthecode
Copy link
Author

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

@avalanche123
Copy link
Owner

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

@avalanche123
Copy link
Owner

avalanche123 commented Feb 18, 2019

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

@aroundthecode
Copy link
Author

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

@avalanche123
Copy link
Owner

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!

@ghost
Copy link

ghost commented Apr 9, 2019

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

@mwik
Copy link

mwik commented Jun 19, 2019

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.

@lanphan
Copy link

lanphan commented Jul 9, 2020

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

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

Successfully merging this pull request may close these issues.

5 participants