Skip to content
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

utils: cleanup MacAddress and MacAddressTest #8988

Merged
merged 2 commits into from
Apr 29, 2024

Conversation

rohityadavcloud
Copy link
Member

Cleanup old mac address handling code to use JDK11 lib instead of hacks. Also really strange to see some basic string parsing code was written by hand, replaced with Long.parseValue(str, 16) to convert hex string to long.

Fixes #8174

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

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Cleanup old mac address handling code to use JDK11 lib instead of hacks.
Also really strange to see some basic string parsing code was written by
hand, replaced with Long.parseValue(str, 16) to convert hex string to
long.

Signed-off-by: Rohit Yadav <[email protected]>
@rohityadavcloud
Copy link
Member Author

@blueorangutan package

@blueorangutan
Copy link

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

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice cleanup

utils/src/main/java/com/cloud/utils/net/MacAddress.java Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Apr 26, 2024

Codecov Report

Attention: Patch coverage is 57.14286% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 14.96%. Comparing base (e409c6d) to head (67e5ae4).

Files Patch % Lines
.../src/main/java/com/cloud/utils/net/MacAddress.java 57.14% 5 Missing and 7 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.19    #8988      +/-   ##
============================================
- Coverage     14.96%   14.96%   -0.01%     
+ Complexity    10995    10986       -9     
============================================
  Files          5373     5373              
  Lines        468989   468899      -90     
  Branches      61009    60411     -598     
============================================
- Hits          70191    70159      -32     
+ Misses       391019   390971      -48     
+ Partials       7779     7769      -10     
Flag Coverage Δ
uitests 4.31% <ø> (ø)
unittests 15.66% <57.14%> (-0.01%) ⬇️

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

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

@blueorangutan
Copy link

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

@rohityadavcloud
Copy link
Member Author

@blueorangutan test

@weizhouapache
Copy link
Member

@rohityadavcloud
I copied the code and run it locally

  • on mgmt server (with only 1 interface), the macAddressInLong value is same as previous legacy code. that is good
macAddressInLong = 32989023043991

mysql> select msid from mshost where state='Up';
+----------------+
| msid           |
+----------------+
| 32989023043991 |
+----------------+
1 row in set (0.00 sec)

  • run it on kvm host
network.getName() = vnet125
network.getName() = vnet150
network.getName() = vnet110
network.getName() = vnet127
network.getName() = vnet111
network.getName() = vnet124
network.getName() = vnet148
network.getName() = vnet78
network.getName() = vnet145
network.getName() = vnet118
network.getName() = vnet122
network.getName() = vnet116
network.getName() = vnet147
network.getName() = vnet117
network.getName() = vnet123
network.getName() = vnet80
network.getName() = vnet79
network.getName() = vnet146
network.getName() = vnet149
network.getName() = vnet112
network.getName() = vnet126
network.getName() = vnet131
network.getName() = cloud0
network.getName() = cloudbr1
network.getName() = cloudbr0
network.getName() = lo

my suggestion is

  • reverse the elements in the return of NetworkInterface.getNetworkInterfaces
  • ignore lo interface, so the code will get the mac address of the first non-loopback nic.

Signed-off-by: Rohit Yadav <[email protected]>
@rohityadavcloud
Copy link
Member Author

Thanks @weizhouapache @sureshanaparti I've addressed the review comments.

@blueorangutan package

@blueorangutan
Copy link

@rohityadavcloud 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
Copy link

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

@rohityadavcloud
Copy link
Member Author

@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

[SF] Trillian test result (tid-10064)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 47052 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr8988-t10064-kvm-centos7.zip
Smoke tests completed. 128 look OK, 2 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 405.75 test_events_resource.py
test_01_redundant_vpc_site2site_vpn Failure 406.81 test_vpc_vpn.py

Copy link
Contributor

@shwstppr shwstppr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@weizhouapache
Copy link
Member

code lgtm

deployed it on an existing environment, there is no new management server added to mshost table

@rohityadavcloud rohityadavcloud merged commit b23ceef into apache:4.19 Apr 29, 2024
24 checks passed
@rohityadavcloud rohityadavcloud deleted the fix-mshost-uniq-entry branch April 29, 2024 08:12
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request May 3, 2024
* utils: cleanup MacAddress and MacAddressTest

Cleanup old mac address handling code to use JDK11 lib instead of hacks.
Also really strange to see some basic string parsing code was written by
hand, replaced with Long.parseValue(str, 16) to convert hex string to
long.

Signed-off-by: Rohit Yadav <[email protected]>

* address review comments

Signed-off-by: Rohit Yadav <[email protected]>

---------

Signed-off-by: Rohit Yadav <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: No status
Development

Successfully merging this pull request may close these issues.

7 participants