Skip to content

Don't allow adding of existing host to another zone, pod or cluster - #13182

Open
vishesh92 wants to merge 4 commits into
apache:4.20from
shapeblue:fix-add-host-diff-location
Open

Don't allow adding of existing host to another zone, pod or cluster#13182
vishesh92 wants to merge 4 commits into
apache:4.20from
shapeblue:fix-add-host-diff-location

Conversation

@vishesh92

Copy link
Copy Markdown
Member

Description

This PR fixes #13080

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?

@codecov

codecov Bot commented May 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.26%. Comparing base (549daae) to head (9228b5a).

Files with missing lines Patch % Lines
...n/java/com/cloud/resource/ResourceManagerImpl.java 71.42% 5 Missing and 5 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.20   #13182      +/-   ##
============================================
- Coverage     16.26%   16.26%   -0.01%     
- Complexity    13434    13442       +8     
============================================
  Files          5667     5667              
  Lines        500731   500766      +35     
  Branches      60803    60810       +7     
============================================
- Hits          81455    81449       -6     
- Misses       410172   410214      +42     
+ Partials       9104     9103       -1     
Flag Coverage Δ
uitests 4.14% <ø> (ø)
unittests 17.12% <71.42%> (-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.

@apache apache deleted a comment from blueorangutan May 18, 2026
@vishesh92
vishesh92 force-pushed the fix-add-host-diff-location branch from 2f64bcd to 6bf5881 Compare May 18, 2026 12:06
@apache apache deleted a comment from blueorangutan May 18, 2026
@vishesh92

Copy link
Copy Markdown
Member Author

@blueorangutan package

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@vishesh92

Copy link
Copy Markdown
Member Author

@blueorangutan package

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

Comment thread server/src/main/java/com/cloud/resource/ResourceManagerImpl.java Outdated
Comment thread server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
Comment thread server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
Comment thread server/src/main/java/com/cloud/resource/ResourceManagerImpl.java Outdated
@vishesh92
vishesh92 marked this pull request as ready for review May 19, 2026 08:10
@vishesh92

Copy link
Copy Markdown
Member Author

@blueorangutan package

@vishesh92 vishesh92 linked an issue May 20, 2026 that may be closed by this pull request
@vishesh92

Copy link
Copy Markdown
Member Author

@blueorangutan package

@vishesh92

Copy link
Copy Markdown
Member Author

@blueorangutan test

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

clgtm

if (existingPodId == null || existingClusterId == null) {
return;
}
if (existingDcId == dcId && Objects.equals(existingPodId, podId) && Objects.equals(existingClusterId, clusterId)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if (existingDcId == dcId && Objects.equals(existingPodId, podId) && Objects.equals(existingClusterId, clusterId)) {
if (Objects.equals(existingDcId, dcId) && Objects.equals(existingPodId, podId) && Objects.equals(existingClusterId, clusterId)) {

if (existingDcId == dcId && Objects.equals(existingPodId, podId) && Objects.equals(existingClusterId, clusterId)) {
return;
}
final String identity = host.getUuid() != null ? host.getUuid() : host.getGuid();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
final String identity = host.getUuid() != null ? host.getUuid() : host.getGuid();
final String identity = ObjectUtils.defaultIfNull(host.getUuid(), host.getGuid());

potiuk added a commit to potiuk/cloudstack that referenced this pull request Jun 17, 2026
- Q15: sensitive-file ownership root:cloud, mode 0640
- Q24: same-IP host re-add updates existing record, gated by creds + key/certs
  (apache#13182); not an unauthenticated spoof path
- Q29: data-at-rest delegation to storage/hypervisor confirmed by vishesh92

Generated-by: Claude Opus 4.8
@harikrishna-patnala

Copy link
Copy Markdown
Member

@vishesh92 can you please address the remaining code review comments.

@apache apache deleted a comment from blueorangutan Aug 4, 2026
@apache apache deleted a comment from blueorangutan Aug 4, 2026
@apache apache deleted a comment from blueorangutan Aug 4, 2026
@apache apache deleted a comment from blueorangutan Aug 4, 2026
@apache apache deleted a comment from blueorangutan Aug 4, 2026
@apache apache deleted a comment from blueorangutan Aug 4, 2026
@apache apache deleted a comment from blueorangutan Aug 4, 2026
@apache apache deleted a comment from blueorangutan Aug 4, 2026
@DaanHoogland
DaanHoogland force-pushed the fix-add-host-diff-location branch from 97e2f7b to 9228b5a Compare August 4, 2026 08:00
@blueorangutan

Copy link
Copy Markdown

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't allow adding an existing KVM host to another zone

7 participants