Scope host tag-rule matches to deployment plan in allocators - #13951
Open
DaanHoogland wants to merge 1 commit into
Open
Scope host tag-rule matches to deployment plan in allocators#13951DaanHoogland wants to merge 1 commit into
DaanHoogland wants to merge 1 commit into
Conversation
Contributor
Author
|
pretty sure I started working on this for some issue or discussion, but I lost the link. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.20 #13951 +/- ##
============================================
+ Coverage 16.32% 16.34% +0.01%
- Complexity 13556 13564 +8
============================================
Files 5669 5669
Lines 501399 501409 +10
Branches 60902 60903 +1
============================================
+ Hits 81847 81941 +94
+ Misses 410390 410273 -117
- Partials 9162 9195 +33
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 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.


Scope host tag-rule matches to deployment plan in FirstFit/Random allocators
Problem
FirstFitAllocatorandRandomAllocatorboth callHostDao#findHostsWithTagRuleThatMatchComputeOferringTags(String)to pick up hosts whosehost tag is defined as a rule (a boolean/regex expression, e.g.
!ssd) rather than aliteral string, so they match the compute offering's host tag.
That DAO method evaluates every rule-tagged host in the entire installation against the
offering tag and returns all matches, with no zone/pod/cluster filtering. The allocators then
unconditionally
addAll/unionthose hosts into the candidate list for the currentdeployment plan:
As a result, a host in a different datacenter/pod/cluster than the one being deployed into —
but whose rule tag happens to match the offering's host tag — can be added as an allocation
candidate. Once storage-pool selection is scoped correctly but the host list isn't, the two
diverge and valid host+pool pairings that should have worked can be rejected, or (in the
FirstFitAllocator path) a host outside the deployment's scope can be picked entirely.
This reproduces most easily in a setup combining host tags and storage tags with more than
one pod/cluster/zone and a host tag configured as a rule.
Fix
HostDao:findHostsWithTagRuleThatMatchComputeOferringTags(String computeOfferingTags, Long clusterId, Long podId, Long dcId),implemented in
HostDaoImplby reusing the existing rule evaluation and filtering thematched hosts down to the given zone/pod/cluster.
FirstFitAllocator(bothallocateTooverloads) andRandomAllocatornow call the scopedoverload with the deployment plan's
dcId/podId/clusterIdinstead of the unscoped one.main, the rule-tag lookup lives in the sharedBaseAllocator#addHostsBasedOnTagRuleshelper (used by both allocators); that helper and its two call sites were updated the same
way.
The old unscoped overload is left in place since it's still the correct primitive for the
handful of call sites (e.g.
findClustersThatMatchHostTagRule) that intentionally looksystem-wide.
Testing
Added/extended unit tests to assert the allocators call the scoped DAO overload (and never
fall back to the unscoped one) when resolving rule-tagged hosts:
FirstFitAllocatorTest(new on 4.20/4.22; extended on main)RandomAllocatorTestBaseAllocatorTest(main only, covers the shared helper directly)Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?