Skip to content

Conversation

vishesh92
Copy link
Member

@vishesh92 vishesh92 commented Jan 20, 2025

Description

Fixes #9775

This PR adds check to ensure we check for unique hostname for other networks in the VPC as well.

This PR also adds another global setting vm.distinct.hostname.scope which sets the scope of resources for which the VMs should have a unique hostname. Default value is network.

Details

This pull request includes several changes to enhance the network domain search functionality and improve the configuration management for VM hostname uniqueness. The most important changes include adding new methods for network domain searches, updating the search builder initialization, and modifying the hostname uniqueness check logic.

Enhancements to network domain search functionality:

Improvements to VM hostname uniqueness check:

Mock implementation updates:

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?

@vishesh92
Copy link
Member Author

@blueorangutan package

@blueorangutan
Copy link

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

codecov bot commented Jan 20, 2025

Codecov Report

❌ Patch coverage is 1.25000% with 79 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.54%. Comparing base (f67b738) to head (03f8c2f).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 0.00% 57 Missing ⚠️
...ain/java/com/cloud/network/dao/NetworkDaoImpl.java 0.00% 22 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #10212      +/-   ##
============================================
- Coverage     17.54%   17.54%   -0.01%     
+ Complexity    15483    15482       -1     
============================================
  Files          5897     5897              
  Lines        527484   527554      +70     
  Branches      64432    64441       +9     
============================================
  Hits          92566    92566              
- Misses       424508   424578      +70     
  Partials      10410    10410              
Flag Coverage Δ
uitests 3.60% <ø> (ø)
unittests 18.60% <1.25%> (-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.

🚀 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

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

@vishesh92 vishesh92 force-pushed the enforce-distinct-hostnames-network branch from befd5a5 to 8888b27 Compare January 20, 2025 12:27
@vishesh92
Copy link
Member Author

@blueorangutan package

@blueorangutan
Copy link

@vishesh92 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]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 12130

@vishesh92 vishesh92 marked this pull request as ready for review January 21, 2025 06:26
@DaanHoogland DaanHoogland added this to the 4.19.2 milestone Jan 21, 2025
@vishesh92 vishesh92 force-pushed the enforce-distinct-hostnames-network branch from d7336c1 to c9855aa Compare January 21, 2025 10:39
@vishesh92 vishesh92 force-pushed the enforce-distinct-hostnames-network branch 3 times, most recently from 5aa2b60 to 91344bf Compare January 21, 2025 10:44
@vishesh92
Copy link
Member Author

@blueorangutan package

@blueorangutan
Copy link

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

@apache apache deleted a comment from blueorangutan Jan 21, 2025
@blueorangutan
Copy link

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

@vishesh92
Copy link
Member Author

@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

Test Result Time (s) Test File
test_01_secure_vm_migration Error 134.42 test_vm_life_cycle.py
test_01_secure_vm_migration Error 134.42 test_vm_life_cycle.py
test_10_attachAndDetach_iso Error 12.63 test_vm_life_cycle.py

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.

clgtm

"Scope of resources to check while checking if the hostname is unique. Possible values are global, domain, subdomain, account, network.",
true, ConfigKey.Scope.Global, null, "VM distinct hostname scope", null, null, null, ConfigKey.Kind.Select,
"global,domain,subdomain,account,network");

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please help me understand what's the purpose of this global setting, if VM names have to be unique within a network domain?

Copy link
Member Author

Choose a reason for hiding this comment

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

So, the network domain can be same for networks in different domain, account, etc. If a user a launches a VM with the same name in these networks, there can be conflict. This global setting allows the user to set scope for what all networks we need to check when creating a vm.

Copy link
Contributor

Choose a reason for hiding this comment

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

@vishesh92 can you please add "project" and "vpc" to the scope

Copy link
Member Author

Choose a reason for hiding this comment

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

For project, we specify account_id as the project id. So, this is covered by the account scope. Adding project will make the check complicated.
For networks in a VPC, the network domain is same for all.

@vishesh92 vishesh92 force-pushed the enforce-distinct-hostnames-network branch from 94c9fc8 to 6f2136e Compare October 1, 2025 09:20
@apache apache deleted a comment from blueorangutan Oct 1, 2025
@vishesh92
Copy link
Member Author

@blueorangutan package

@blueorangutan
Copy link

@vishesh92 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]: ✖️ el8 ✖️ el9 ✔️ debian ✖️ suse15. SL-JID 15252

@vishesh92
Copy link
Member Author

@blueorangutan package

@blueorangutan
Copy link

@vishesh92 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]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15273

@vishesh92
Copy link
Member Author

@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

Test Result Time (s) Test File
test_13_retrieve_vr_default_files Error 1.11 test_diagnostics.py
test_14_retrieve_vr_one_file Error 1.10 test_diagnostics.py
test_15_retrieve_ssvm_default_files Error 1.12 test_diagnostics.py
test_16_retrieve_ssvm_single_file Error 1.14 test_diagnostics.py
test_17_retrieve_cpvm_default_files Error 1.13 test_diagnostics.py
test_18_retrieve_cpvm_single_file Error 1.12 test_diagnostics.py
ContextSuite context=TestClusterDRS>:setup Error 0.00 test_cluster_drs.py
test_list_system_vms_metrics_history Failure 0.29 test_metrics_api.py

Copy link

github-actions bot commented Oct 7, 2025

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@nvazquez
Copy link
Contributor

nvazquez commented Oct 9, 2025

@blueorangutan package

@blueorangutan
Copy link

@nvazquez 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]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15364

@nvazquez
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

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

Copy link
Contributor

@nvazquez nvazquez left a comment

Choose a reason for hiding this comment

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

LGTM - manually tested these cases:

  • Default value: vm.distinct.hostname.scope = network:

    • Created a project and VPC1 and VPC2 under the project with one tier each
    • Created VM with name 'vm1' on VPC1 tier 1
    • Created VM with name 'vm1' on VPC2 tier 1 -> OK (previous behavior preserved)
  • Set vm.distinct.hostname.scope = global:

    • Created VPC2 tier 2
    • Tried creating VM with name 'vm1' -> Fails with error: The vm with hostName vm1 already exists in the network domain: cs130cloud.internal; network=Vpc1-Tier1
  • Set vm.distinct.hostname.scope = domain:

    • Created subdomain D1 and a domain admin on the new domain, log in as the domain admin:
    • Created Isolated network D1N1 on D1
    • Created VM on D1N1 with name 'vm1'
    • Created Isolated network D1N2 on D1
    • Tried creating VM with name 'vm1' on D1N2 -> Fails with error: The vm with hostName vm1 already exists in the network domain: cs131cloud.internal; network=Isolated-Dom1
  • Set vm.distinct.hostname.scope = account:

    • Login as the ROOT admin
    • Create Isolated network
    • Create VM with name 'vm1' on the network
    • Create Isolated network 2
    • Try to create VM with name 'vm1' on Isolated Network 2 -> Fails with error: The vm with hostName vm1 already exists in the network domain: cs2cloud.internal; network=Isolated1-Admin
    • Set vm.distinct.hostname.scope = network
    • Create VM with name 'vm1' on Isolated Network 2 -> OK

@DaanHoogland
Copy link
Contributor

@harikrishna-patnala @Pearl1594 are you ok to merge this?

@blueorangutan
Copy link

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

Test Result Time (s) Test File

@harikrishna-patnala harikrishna-patnala merged commit 0b9afe7 into apache:main Oct 13, 2025
25 of 28 checks passed
@harikrishna-patnala harikrishna-patnala deleted the enforce-distinct-hostnames-network branch October 13, 2025 07:08
@github-project-automation github-project-automation bot moved this from In Progress to Done in ACS 4.20.1 Oct 13, 2025
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Oct 17, 2025
* Check for unique hostnames for all networks in the vpc

* Address comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Option to restrict duplicate instance names in same network domain, VPC etc

8 participants