Skip to content

cloudstack-setup-databases: get local address instead of 127.0.1.1 - #10571

Draft
weizhouapache wants to merge 3 commits into
apache:4.20from
weizhouapache:4.19-fix-cluster-node-ip-127.0.1.1
Draft

cloudstack-setup-databases: get local address instead of 127.0.1.1#10571
weizhouapache wants to merge 3 commits into
apache:4.20from
weizhouapache:4.19-fix-cluster-node-ip-127.0.1.1

Conversation

@weizhouapache

Copy link
Copy Markdown
Member

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

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

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@weizhouapache weizhouapache added this to the 4.19.3 milestone Mar 14, 2025
@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@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

codecov Bot commented Mar 14, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 16.33%. Comparing base (6136ac9) to head (dcaf38a).

Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #10571   +/-   ##
=========================================
  Coverage     16.32%   16.33%           
- Complexity    13556    13559    +3     
=========================================
  Files          5669     5669           
  Lines        501399   501399           
  Branches      60902    60902           
=========================================
+ Hits          81847    81884   +37     
+ Misses       410390   410348   -42     
- Partials       9162     9167    +5     
Flag Coverage Δ
uitests 4.14% <ø> (ø)
unittests 17.19% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 12779

@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

Comment thread setup/bindir/cloud-setup-databases.in Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment on lines +331 to +335
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

Copy link

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.
@weizhouapache
weizhouapache marked this pull request as draft September 3, 2025 07:23
@weizhouapache weizhouapache modified the milestones: 4.20.2, 4.20.3 Sep 10, 2025
@abh1sar abh1sar modified the milestones: 4.20.3, 4.20.4 Feb 16, 2026
@DaanHoogland
DaanHoogland force-pushed the 4.19-fix-cluster-node-ip-127.0.1.1 branch from 3efd24b to 6ed1e20 Compare August 31, 2026 09:23
@DaanHoogland
DaanHoogland changed the base branch from 4.19 to 4.20 August 31, 2026 09:24
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
```
@DaanHoogland
DaanHoogland force-pushed the 4.19-fix-cluster-node-ip-127.0.1.1 branch from 6ed1e20 to dcaf38a Compare August 31, 2026 09:24
@DaanHoogland DaanHoogland moved this from Backlog to Ready in CloudStack Testing Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Ready

Development

Successfully merging this pull request may close these issues.

8 participants