cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

[10996] - use 'ip' structured data to safely retrieve default route interface

Open mosys0815 opened this issue 2 months ago • 19 comments

Using ip route structured data allows to query safely the default route interface, no matter the output of the standard 'ip route' output.

mosys0815 avatar Oct 07 '25 09:10 mosys0815

Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) Here are some useful points:

  • In case of a new feature add useful documentation (raise doc PR at https://github.com/apache/cloudstack-documentation)
  • Be patient and persistent. It might take some time to get a review or get the final approval from the committers.
  • Pay attention to the quality of your code, ensure tests are passing and your PR doesn't have conflicts.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Issues, Mailing list and Slack.
  • Be sure to read the CloudStack Coding Conventions. Apache CloudStack is a community-driven project and together we are making it better 🚀. In case of doubts contact the developers at: Mailing List: [email protected] (https://cloudstack.apache.org/mailing-lists.html) Slack: https://apachecloudstack.slack.com/

boring-cyborg[bot] avatar Oct 07 '25 09:10 boring-cyborg[bot]

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 17.54%. Comparing base (4d46bec) to head (6b9c422). :warning: Report is 331 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #11800      +/-   ##
============================================
+ Coverage     16.57%   17.54%   +0.96%     
- Complexity    13987    15467    +1480     
============================================
  Files          5746     5897     +151     
  Lines        510860   527397   +16537     
  Branches      62140    64407    +2267     
============================================
+ Hits          84696    92516    +7820     
- Misses       416690   424486    +7796     
- Partials       9474    10395     +921     
Flag Coverage Δ
uitests 3.60% <ø> (-0.31%) :arrow_down:
unittests 18.60% <100.00%> (+1.12%) :arrow_up:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

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

codecov[bot] avatar Oct 07 '25 13:10 codecov[bot]

it worked on ubuntu 24

# /bin/ip -j a | /bin/jq -r '.[] | .addr_info | map(select(.local == "'`/bin/ip -j r s default | /bin/jq -r '.[0] | .prefsrc'`'")) | .[].label'
eth0

however, on RHEL and variants, the path of ip is not /bin/ip

# which ip
/usr/sbin/ip

weizhouapache avatar Oct 07 '25 13:10 weizhouapache

well, until now plain ip is used, i could replace is with just ip, or the script can get the path beforehand, what would you prefer?

mosys0815 avatar Oct 07 '25 14:10 mosys0815

I changed the script to use short-paths for ipand jq, as like as it was before

mosys0815 avatar Oct 08 '25 10:10 mosys0815

@weizhouapache anything missing still?

mosys0815 avatar Nov 17 '25 12:11 mosys0815

Dear @mosys0815,

I agree with the goal of finding a more reliable way to retrieve the interface, but I want to apologize in advance for my straightforward feedback on the proposed solutions:

The approach feels overly complex, which makes it hard to understand and, in my opinion, not an effective way to achieve the goal.

When I tried to run it, it didn’t work due to unescaped characters (as @weizhouapache also mentioned).

Were you able to run the command successfully? If so, could you share your environment or context?

I would prefer updating the PR to use the following instead:

ip route show default | awk '{print $5}'

The following one also accomplish the same goal but I would prefer to use the one above because does not require jq to be installed.

ip -j r s default | jq -r '.[0] | .dev'

Regards,

daviftorres avatar Nov 17 '25 15:11 daviftorres

@blueorangutan package

DaanHoogland avatar Dec 08 '25 09:12 DaanHoogland

@DaanHoogland 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.

blueorangutan avatar Dec 08 '25 09:12 blueorangutan

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

blueorangutan avatar Dec 08 '25 10:12 blueorangutan

@blueorangutan package

weizhouapache avatar Dec 08 '25 10:12 weizhouapache

@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.

blueorangutan avatar Dec 08 '25 10:12 blueorangutan

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

blueorangutan avatar Dec 08 '25 12:12 blueorangutan

@blueorangutan test matrix

DaanHoogland avatar Dec 08 '25 13:12 DaanHoogland

@DaanHoogland a [SL] Trillian-Jenkins matrix job (EL8 mgmt + EL8 KVM, Ubuntu22 mgmt + Ubuntu22 KVM, EL8 mgmt + VMware 7.0u3, EL9 mgmt + XCP-ng 8.2 ) has been kicked to run smoke tests

blueorangutan avatar Dec 08 '25 13:12 blueorangutan

[SF] Trillian Build Failed (tid-14918)

blueorangutan avatar Dec 08 '25 13:12 blueorangutan

[SF] Trillian Build Failed (tid-14919)

blueorangutan avatar Dec 08 '25 14:12 blueorangutan

[SF] Trillian test result (tid-14917) Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8 Total time taken: 60853 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr11800-t14917-kvm-ol8.zip Smoke tests completed. 147 look OK, 3 have errors, 0 did not run Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_uservm_host_control_state Failure 17.02 test_host_control_state.py
ContextSuite context=TestHostControlState>:teardown Error 31.68 test_host_control_state.py
test_01_vpn_usage Error 1.12 test_usage.py
test_01_secure_vm_migration Error 136.48 test_vm_life_cycle.py
test_01_secure_vm_migration Error 136.49 test_vm_life_cycle.py

blueorangutan avatar Dec 09 '25 07:12 blueorangutan

[SF] Trillian test result (tid-14920) Environment: xcpng82 (x2), zone: Advanced Networking with Mgmt server ol9 Total time taken: 116184 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr11800-t14920-xcpng82.zip Smoke tests completed. 128 look OK, 22 have errors, 0 did not run Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_01_events_resource Error 144.25 test_events_resource.py
test_07_arping_in_vr Failure 5.24 test_diagnostics.py
test_01_non_strict_host_anti_affinity Error 215.29 test_nonstrict_affinity_group.py
test_02_non_strict_host_affinity Error 66.08 test_nonstrict_affinity_group.py
test_CRUD_operations_userdata Error 1522.79 test_register_userdata.py
test_deploy_vm_with_registered_userdata Error 9.11 test_register_userdata.py
test_deploy_vm_with_registered_userdata_with_override_policy_allow Error 8.40 test_register_userdata.py
test_deploy_vm_with_registered_userdata_with_override_policy_append Error 8.15 test_register_userdata.py
test_deploy_vm_with_registered_userdata_with_override_policy_deny Error 8.28 test_register_userdata.py
test_deploy_vm_with_registered_userdata_with_params Error 8.28 test_register_userdata.py
test_link_and_unlink_userdata_to_template Error 8.33 test_register_userdata.py
test_user_userdata_crud Error 8.69 test_register_userdata.py
ContextSuite context=TestResetVmOnReboot>:setup Error 0.00 test_reset_vm_on_reboot.py
ContextSuite context=TestRAMCPUResourceAccounting>:setup Error 0.00 test_resource_accounting.py
ContextSuite context=TestResourceNames>:setup Error 0.00 test_resource_names.py
ContextSuite context=TestRestoreVM>:setup Error 0.00 test_restore_vm.py
ContextSuite context=TestRouterDHCPHosts>:setup Error 0.00 test_router_dhcphosts.py
ContextSuite context=TestRouterDHCPOpts>:setup Error 0.00 test_router_dhcphosts.py
ContextSuite context=TestRouterDns>:setup Error 0.00 test_router_dns.py
ContextSuite context=TestRouterDnsService>:setup Error 0.00 test_router_dnsservice.py
ContextSuite context=TestRouterIpTablesPolicies>:setup Error 0.00 test_routers_iptables_default_policy.py
ContextSuite context=TestVPCIpTablesPolicies>:setup Error 0.00 test_routers_iptables_default_policy.py
ContextSuite context=TestIsolatedNetworks>:setup Error 0.00 test_routers_network_ops.py
ContextSuite context=TestRedundantIsolateNetworks>:setup Error 0.00 test_routers_network_ops.py
ContextSuite context=TestRouterServices>:setup Error 0.00 test_routers.py
ContextSuite context=TestScaleVm>:setup Error 0.00 test_scale_vm.py
ContextSuite context=TestServiceOfferings>:setup Error 1516.93 test_service_offerings.py
test_01_volume_usage Failure 99.12 test_usage.py
ContextSuite context=TestSetSourceNatIp>:setup Error 0.00 test_set_sourcenat.py
ContextSuite context=TestSnapshotRootDisk>:setup Error 0.00 test_snapshots.py
ContextSuite context=TestSnapshotStandaloneBackup>:setup Error 0.00 test_snapshots.py
test_11_destroy_vm_and_volumes Error 21.21 test_vm_life_cycle.py
ContextSuite context=TestSslOffloading>:setup Error 0.00 test_ssl_offloading.py
test_01_migrate_vm_strict_tags_success Error 76.72 test_vm_strict_host_tags.py

blueorangutan avatar Dec 09 '25 22:12 blueorangutan