WIP: server: refuse re-registration of deleted hosts by GUID - #13719
Open
wido wants to merge 4 commits into
Open
WIP: server: refuse re-registration of deleted hosts by GUID#13719wido wants to merge 4 commits into
wido wants to merge 4 commits into
Conversation
A still-running agent whose host was deleted keeps its locally-persisted GUID and reconnects indefinitely. The management server looks up hosts by GUID excluding removed rows, so it fails to recognize the returning agent and re-registers it as a brand-new host. The existing 'add.host.on.service.restart.kvm' setting only guards this agent-side, for KVM/LXC, and only when the agent is still connected at delete time. Enforce that setting's intent on the management server: when 'add.host.on.service.restart.kvm' is false, refuse an agent whose GUID matches a previously deleted host. This also covers the case where the agent was offline when the host was deleted, and applies to all hypervisor types. - Preserve the host GUID on the soft-deleted record so the returning agent can be recognized (deleteHost no longer nulls the GUID). - Add HostDao.findByGuidIncludingRemoved / findByGuidPrefixIncludingRemoved. - getNewHost now rejects re-registration via rejectReAddOfDeletedHost.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #13719 +/- ##
============================================
- Coverage 19.74% 19.73% -0.01%
- Complexity 19960 19969 +9
============================================
Files 6371 6371
Lines 575784 575820 +36
Branches 70478 70482 +4
============================================
- Hits 113665 113664 -1
- Misses 449765 449806 +41
+ Partials 12354 12350 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
…ed-hosts # Conflicts: # server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
Cover the management-server guard that refuses an agent whose GUID belongs to a previously deleted host: - honours 'add.host.on.service.restart.kvm': when true the guard returns early and issues no database lookup at all - rejects a match on the full GUID and, separately, on the GUID prefix - the rejection message names both the GUID and the setting to flip - a full-GUID hit short-circuits the prefix lookup - a live host (removed = null) returned by the *IncludingRemoved lookups is never rejected, so an ordinary agent reconnect keeps working - blank/null GUID and prefix are not looked up, so a blank prefix cannot turn into a wildcard query matching an unrelated host The tests mutate the static ADD_HOST_ON_SERVICE_RESTART_KVM ConfigKey, so tearDown() restores its declared default to keep the change from leaking into other tests sharing the JVM fork.
Addresses review feedback: the explanation lives in the javadoc on rejectReAddOfDeletedHost(), the inline comments only cluttered the code.
Contributor
Author
|
@DaanHoogland comments removed in 43a3adc, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A still-running agent whose host was deleted keeps its locally-persisted GUID and reconnects indefinitely. The management server looks up hosts by GUID excluding removed rows, so it fails to recognize the returning agent and re-registers it as a brand-new host. The existing 'add.host.on.service.restart.kvm' setting only guards this agent-side, for KVM/LXC, and only when the agent is still connected at delete time.
Enforce that setting's intent on the management server: when 'add.host.on.service.restart.kvm' is false, refuse an agent whose GUID matches a previously deleted host. This also covers the case where the agent was offline when the host was deleted, and applies to all hypervisor types.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity