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

HDFS cache test assumes identity of explicit hostname and "default" #297

Open
simleo opened this issue Apr 4, 2018 · 0 comments
Open

HDFS cache test assumes identity of explicit hostname and "default" #297

simleo opened this issue Apr 4, 2018 · 0 comments
Assignees
Labels

Comments

@simleo
Copy link
Member

simleo commented Apr 4, 2018

In hdfs/fs.py we cache fs instances by (IP, port, user). The purpose here is twofold: save time by reusing an existing connection and avoid situations where two different Python objects map to the same Java instance (this can lead to crashes if the currently used instance is closed unexpectedly somewhere else). What the cache does not do is guarantee that different cache entries map to different name nodes, since a given name node can have multiple IPs (e.g., a NIC and the loopback interface).

In test_utils.py we have:

_DEFAULT_HDFS_HOST = os.getenv("HOSTNAME", "localhost")
HDFS_HOST = os.getenv("HDFS_HOST", _DEFAULT_HDFS_HOST)

test_hdfs_fs.cache incorrectly checks that connections to "default" and to the explicit HDFS_HOST value map to the same cache item, while this can easily fail. For instance, on EC2 I currently have the following setup:

$ grep -A1 defaultFS /opt/hadoop/etc/hadoop/core-site.xml 
    <name>fs.defaultFS</name>
    <value>hdfs://localhost:9000</value>
python -c "import os, socket; print([socket.gethostbyname(_) for _ in ('localhost', os.getenv('HOSTNAME'))])"
['127.0.0.1', '172.31.18.195']
@simleo simleo added the bug label Apr 4, 2018
@simleo simleo self-assigned this Apr 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant