-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add prioritization of conflicting constraints #293
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -333,31 +333,66 @@ func TestGetEligibleOperations(t *testing.T) { | |
|
||
// test conflicts between constraints | ||
// | ||
// Entirely conflicting constraints (max < min) shall paralyze Castellum and | ||
// suppress all actions. | ||
// Entirely conflicting constraints of equal priority shall paralyze Castellum and | ||
// suppress all actions. Otherwise, the stronger constraint should be enforced. | ||
// Priority 0: StrictMinimumSize, StrictMaximumSize | ||
// Priority 1: MinimumFreeSize, MinimumSize, MaximumSize | ||
|
||
check( | ||
"low=20%, high=80%, crit=95%, step=200%, min=1000", | ||
"size=1000, usage=500, smax=900", | ||
"", "", // MinimumSize is upheld, but StrictMaximumSize is trying to get us to break it | ||
"low=20%, high=80%, crit=95%, step=20%, max=900", | ||
"size=1000, usage=500, smin=1100", | ||
"high->1200", "high->1100", // StrictMinimumSize takes precedence over maximum constraint | ||
) | ||
check( | ||
"low=20%, high=80%, crit=95%, step=200%, min=1000", | ||
"size=900, usage=500, smax=800", | ||
"", "", // MinimumSize is already broken, and StrictMaximumSize is trying to get us to break it further | ||
"low=20%, high=80%, crit=95%, step=20%, min=900", | ||
"size=1000, usage=100, smin=950", | ||
"low->950", "low->950", // StrictMinimumSize takes precedence over minimum constraint | ||
) | ||
check( | ||
"low=20%, high=80%, crit=95%, step=200%, max=1000", | ||
"low=10%, high=80%, crit=95%, step=20%, min_free=550", | ||
"size=1000, usage=500, smin=1100", | ||
"", "", // MaximumSize is upheld, but StrictMinimumSize is trying to get us to break it | ||
"high->1200", "high->1100", // StrictMinimumSize takes precedence over minimum free constraint | ||
) | ||
check( | ||
"low=20%, high=80%, crit=95%, step=200%, max=1000", | ||
"size=1100, usage=500, smin=1200", | ||
"", "", // MaximumSize is already broken, and StrictMinimumSize is trying to get us to break it further | ||
"low=20%, high=80%, crit=95%, step=20%, min_free=200", | ||
"size=1000, usage=900, smax=1050", | ||
"high->1050", "high->1050", // StrictMaximumSize takes precedence over minimum free constraint | ||
) | ||
check( | ||
"low=20%, high=80%, crit=95%, step=20%, min_free=200", | ||
"size=1000, usage=800, smax=900", | ||
"low->900", "low->900", // StrictMaximumSize enforces downsizing over minimum free constraint | ||
) | ||
check( | ||
"low=20%, high=80%, crit=95%, step=20%, min=1100", | ||
"size=1000, usage=500, smax=900", | ||
"low->800", "low->900", // StrictMaximumSize takes precedence over minimum constraint | ||
) | ||
check( | ||
"low=20%, high=80%, crit=95%, step=20%, max=1100", | ||
"size=1000, usage=990, smax=1050", | ||
"critical->1050", "critical->1050", // StrictMaximumSize takes precedence over maximum constraint | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For what it's worth, this test does not establish that "StrictMaximumSize takes precedence over maximum constraint". In fact, two maximum constraints cannot really take precedence over each other. If there is no lower bound, the strongest upper bound will always win. So this testcase would have the same result if the values for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. |
||
check( | ||
"low=20%, high=80%, crit=95%, step=20%, max=1050, min_free=600", | ||
"size=1000, usage=500", | ||
"high->1050", "high->1050", // Upsizing due to MinimumFreeSize should not exceed maximum constraint | ||
) | ||
check( | ||
"low=20%, high=80%, crit=95%, step=20%", | ||
"size=1000, usage=500, smin=1100, smax=900", | ||
"", "", // Conflict of strict constrains should result in no action | ||
) | ||
check( | ||
"low=20%, high=80%, crit=95%, step=20%, min=1100, max=900", | ||
"size=1000, usage=990", | ||
"", "", // Conflict of non-strict constrains should prevent upsizing | ||
) | ||
check( | ||
"low=20%, high=80%, crit=95%, step=20%, min=1100, max=900", | ||
"size=1000, usage=100", | ||
"", "", // Conflict of non-strict constrains should prevent downsizing | ||
) | ||
|
||
//TODO: change the unit tests above to enforce proper precedence between limiting and enforceable constraints | ||
// (paralysis shall only happen when the conflicting constraints are of equal rank, e.g. `smin > smax`) | ||
} | ||
|
||
// Builds a ResourceLogic from a compact string representation like "low=20%, high=80%, step=single, min=200". | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand why percentage-step resizing goes to 800 here, but I feel weird about StrictMaximumSize = 900 causing a downsize to 800 here. If the downsize goes through, we will upsize back to 900 immediately afterwards (right?). So I would rather have it go to 900 in both cases.
Having said that, if this turns out to be too difficult to do in this PR without making invasive changes, I'm fine with putting this down as a TODO for later. There are more things to do in the constraint engine soon anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this particular case, there wouldn't be an immediate upsize afterwards, since the new usage would be 62,5% which is within all the thresholds.
check( "low=20%, high=80%, crit=95%, step=20%, min=1100", "size=1000, usage=800, smax=900", "low->900", "low->900", // StrictMaximumSize takes precedence over minimum constraint )
In the case that the forced downsize operation would cross the high threshold, the percentage step strategy will also downsize to 900.