[FIX]: Database Connection Issue by Hostname Resolution During Setup #6075
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
fileWhen 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
Other Questions:
This also needs updation in the Docker docs
So should I make that also ?