Skip to content

Commit

Permalink
add resmanager unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Liu <jasonliu747@gmail.com>
  • Loading branch information
jasonliu747 committed Apr 29, 2022
1 parent dd30303 commit 18b1f65
Show file tree
Hide file tree
Showing 5 changed files with 503 additions and 11 deletions.
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 {
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

0 comments on commit 18b1f65

Please sign in to comment.