hack/util.sh: auto-detect macOS host IP instead of interactive prompt#7267
hack/util.sh: auto-detect macOS host IP instead of interactive prompt#7267Krishiv-Mahajan wants to merge 3 commits intokarmada-io:masterfrom
Conversation
Signed-off-by: Krishiv-Mahajan <mahajankrishiv10@gmail.com>
|
Welcome @Krishiv-Mahajan! It looks like this is your first PR to karmada-io/karmada 🎉 |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Code Review
This pull request significantly improves the user experience for macOS users by replacing an interactive prompt for the host IP address with a robust, layered auto-detection mechanism in hack/util.sh. The new logic correctly handles various network configurations, including the use of an existing environment variable, detection of the active network interface, and sensible fallbacks. This change makes the scripts non-interactive, which is a great enhancement for CI/CD pipelines and automated setups. The implementation is clean and well-commented. The only minor issue found was a typo in a comment, which has been noted for correction.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7267 +/- ##
==========================================
+ Coverage 41.99% 42.00% +0.01%
==========================================
Files 874 874
Lines 53542 53539 -3
==========================================
+ Hits 22483 22490 +7
+ Misses 29372 29364 -8
+ Partials 1687 1685 -2
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:
|
Signed-off-by: Krishiv-Mahajan <mahajankrishiv10@gmail.com>
f8d1139 to
619dbc4
Compare
There was a problem hiding this comment.
Pull request overview
Updates the macOS host IP discovery in hack/util.sh to avoid interactive prompts and better handle non-en0 interfaces, preventing hack/local-up-karmada.sh from hanging in non-interactive environments.
Changes:
- Remove interactive
readprompt fromutil::get_macos_ipaddressand use layered auto-detection instead. - Detect the default-route interface IP (via
route get default) and fall back to scanningen0–en3. - Add a last-resort fallback behavior when no IP can be detected.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Make iface variable local to prevent scope pollution - Fail fast with clear instructions instead of silent 127.0.0.1 fallback Fixes silent cluster join failures on macOS due to non-routable loopback IP. Signed-off-by: Krishiv-Mahajan <mahajankrishiv10@gmail.com>
16cb5bd to
57cb736
Compare
What type of PR is this?
/kind bug
What this PR does / why we need it:
The
util::get_macos_ipaddressfunction in hack/util.sh unconditionally calls read to wait for user input, even when a valid IP was already auto-detected. This causeshack/local-up-karmada.shto hang indefinitely in any non-interactive environment (CI pipelines, GitHub Actions, background scripts).Additionally, the detection was hardcoded to en0 (WiFi only), which silently fails for developers on USB Ethernet, Thunderbolt, or VPN — resulting in an empty HOST_IPADDRESS and member clusters unable to reach the control plane.
This PR replaces the interactive prompt with a layered auto-detection approach:
If MAC_NIC_IPADDRESS is already set (e.g. by CI), use it directly
Detect the active interface via route get default instead of hardcoding en0
If the default route interface has no IP (VPN tunnel), scan en0–en3
Fall back to 127.0.0.1 with a clear warning if all detection fails
Which issue(s) this PR fixes:
Fixes #7257
Part of #7269
Special notes for your reviewer:
Tested end-to-end on macOS 14.3 (Apple Silicon) — ./hack/local-up-karmada.sh completed without any user input and all three member clusters reached Ready status. Linux and WSL2 code paths are unaffected (change is inside the existing darwin guard).
Does this PR introduce a user-facing change?:
hack/util.sh: Fixedutil::get_macos_ipaddresshanging for user input on macOS by replacing the interactive prompt with layered auto-detection from the active network interface, enabling non-interactive and CI usage.