-
Notifications
You must be signed in to change notification settings - Fork 1.2k
cloudstack-setup-databases: get local address instead of 127.0.1.1 #10571
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
base: 4.19
Are you sure you want to change the base?
cloudstack-setup-databases: get local address instead of 127.0.1.1 #10571
Conversation
In some linux setup, the server has the line in /etc/hosts ``` 127.0.1.1 <hostname> ``` If the mgmt serve IP is not specified when run cloudstack-setup-databases, ACS detects the host ip in python, however there is an issue with it. ``` >>> import socket >>> socket.gethostbyname(socket.gethostname()) '127.0.1.1' <<<<=======================this is not good >>> socket.gethostbyname(socket.gethostname() + ".local") '10.0.100.100' <<<========================this is good ```
@blueorangutan package |
@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.19 #10571 +/- ##
==========================================
Coverage 15.16% 15.17%
- Complexity 11326 11347 +21
==========================================
Files 5414 5416 +2
Lines 474804 475621 +817
Branches 57909 58054 +145
==========================================
+ Hits 72002 72157 +155
- Misses 394749 395393 +644
- Partials 8053 8071 +18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 12779 |
@blueorangutan test |
@weizhouapache a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
…0.1.1" This reverts commit b1b01a7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the issue where the CloudStack database setup script incorrectly detects the management server IP address as 127.0.1.1 on some Linux systems due to hostname resolution returning localhost addresses instead of the actual network interface IP.
Key changes:
- Replace simple hostname resolution with comprehensive IP address detection
- Filter out localhost addresses (127.0.0.1 and 127.0.1.1) to find actual network interface IP
- Fallback to 127.0.0.1 if no valid external IP is found
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
hostname, aliases, addresses = socket.gethostbyname_ex(socket.gethostname()) | ||
for address in addresses: | ||
if address != "127.0.0.1" and address != "127.0.1.1": | ||
return address | ||
return "127.0.0.1" |
Copilot
AI
Sep 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded IP address strings should be replaced with constants or use the ipaddress module for better maintainability. Consider using ipaddress.ip_address(address).is_loopback
to check for all loopback addresses, not just the two specific ones.
Copilot uses AI. Check for mistakes.
Description
This PR fixes the issue which has been mentioned in #8218 #9880 #7533 #10384
In some linux setup, the server has the line in /etc/hosts
If the mgmt serve IP is not specified when run cloudstack-setup-databases, ACS detects the host ip in python, however there is an issue with it.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?