Skip to content
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 unit test for resmanager #111

Merged
merged 1 commit into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions pkg/koordlet/resmanager/resmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ func (r *resmanager) mergeNodeSLOSpec(nodeSLO *slov1alpha1.NodeSLO) {
if mergedResourceQoSStrategySpec != nil {
r.nodeSLO.Spec.ResourceQoSStrategy = mergedResourceQoSStrategySpec
}

// merge CPUBurstStrategy
mergedCPUBurstStrategySpec := mergeSLOSpecCPUBurstStrategy(util.DefaultNodeSLOSpecConfig().CPUBurstStrategy,
nodeSLO.Spec.CPUBurstStrategy)
if mergedCPUBurstStrategySpec != nil {
r.nodeSLO.Spec.CPUBurstStrategy = mergedCPUBurstStrategySpec
}
}

func (r *resmanager) createNodeSLO(nodeSLO *slov1alpha1.NodeSLO) {
Expand Down Expand Up @@ -216,19 +223,18 @@ func NewResManager(cfg *Config, schema *apiruntime.Scheme, kubeClient clientset.
// isFeatureDisabled returns whether the featuregate is disabled by nodeSLO config
func isFeatureDisabled(nodeSLO *slov1alpha1.NodeSLO, feature featuregate.Feature) (bool, error) {
if nodeSLO == nil || nodeSLO.Spec == (slov1alpha1.NodeSLOSpec{}) {
return false, fmt.Errorf("cannot parse feature config for invalid nodeSLO %v", nodeSLO)
return true, fmt.Errorf("cannot parse feature config for invalid nodeSLO %v", nodeSLO)
}

spec := nodeSLO.Spec
switch feature {
case features.BECPUSuppress, features.BEMemoryEvict:
// nil value means enabled
if spec.ResourceUsedThresholdWithBE == nil {
return false, fmt.Errorf("cannot parse feature config for invalid nodeSLO %v", nodeSLO)
if spec.ResourceUsedThresholdWithBE == nil || spec.ResourceUsedThresholdWithBE.Enable == nil {
Copy link
Member

Choose a reason for hiding this comment

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

these change the default setting of BECPUSuppress & BEMemoryEvict but i think it's acceptable. WDYT @zwzhang0107

return true, fmt.Errorf("cannot parse feature config for invalid nodeSLO %v", nodeSLO)
}
return spec.ResourceUsedThresholdWithBE.Enable != nil && !(*spec.ResourceUsedThresholdWithBE.Enable), nil
return !(*spec.ResourceUsedThresholdWithBE.Enable), nil
default:
return false, fmt.Errorf("cannot parse feature config for unsupported feature %s", feature)
return true, fmt.Errorf("cannot parse feature config for unsupported feature %s", feature)
}
}

Expand Down
Loading