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

[FIX]: Database Connection Issue by Hostname Resolution During Setup Using Docker #6090

Merged

Conversation

JiyaGupta-cs
Copy link
Contributor

What this PR does

This pull request addresses an issue encountered during the setup process on Fedora using Docker, where the database connection fails due to hostname resolution issues. The error occurs when the system is unable to resolve the required hostname, leading to the failure of the setup process.

Fixes #6074

Changes Introduced:

Added a script that automatically resolves the hostname by ensuring proper network mapping, allowing the database connection to be established successfully.
This script ensures that the system can correctly resolve the hostname and connect to the database without errors.
Can be invoked by bash ./update_hosts.sh

Explanation:

The issue arises because the necessary host entries are not present in the /etc/hosts file
When the system attempts to resolve an address, it fails to locate the corresponding hostname in the local resolution file and subsequently defaults to querying the network gateway to determine if the address exists.
To address this, I have implemented a script to automate the addition of host entries to the /etc/hosts file. This ensures that the hostname resolution process can efficiently locate and map the desired addresses locally without needing to fallback to external network queries.
The current Docker Compose file lacks the necessary configurations to locate the mappings effectively.

Key Cases Handled:

  • Container Running:
    If the Docker container is up, the script updates the /etc/hosts file with the new IP address, ensuring correct hostname resolution.

  • Container Restarted:
    If the Docker container is restarted and the IP address changes, the script checks for the old address and updates it with the new IP address in /etc/hosts.

  • Container Down:
    If the Docker container is down, the update_hosts.sh script removes the corresponding address from the /etc/hosts file to prevent stale entries.

  • No Duplicate Entries:
    The script ensures that there are no duplicate IP addresses for the same hostname in the /etc/hosts file, maintaining clean mappings.

Testing:

Verified that running the script ensures successful hostname resolution.
Confirmed that the database connection is now established properly, and the setup process completes without errors.

Remark

This PR solves the database connection issue for Fedora

@JiyaGupta-cs
Copy link
Contributor Author

Video Demonstration of setting up with and without script

Wikimedia.mp4

@JiyaGupta-cs
Copy link
Contributor Author

have updated the video demonstration and the docker docs also 👍

@JiyaGupta-cs
Copy link
Contributor Author

@ragesoss , the PR is ready to be merged now, could you please review it and let me know if any changes or improvements are needed?

@ragesoss
Copy link
Member

ragesoss commented Jan 6, 2025

I haven't tested this, but it looks like it worked for you! I'm going to merge it, as it's done in a way that won't affect users unless run into the same problem and run it per the updated doc.

@ragesoss ragesoss merged commit 151fc26 into WikiEducationFoundation:master Jan 6, 2025
1 check passed
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.

Database Connection Error: During Setup using Docker
2 participants