Skip to content

Commit

Permalink
ioweight: adding pod level setting
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Lu <robin.lu@bytedance.com>
  • Loading branch information
lubinszARM committed Apr 18, 2024
1 parent bd179d0 commit 462a158
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions pkg/agent/qrm-plugins/io/handlers/ioweight/ioweight_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,35 @@ func applyIOWeightQoSLevelConfig(conf *coreconfig.Configuration,
if !ok {
continue
}

// setup pod level.
podAbsCGPath, err := common.GetPodAbsCgroupPath(common.CgroupSubsysIO, string(pod.UID))
if err != nil {
general.Errorf("GetPodAbsCgroupPath for pod: %s/%s failed with error: %v",
pod.Namespace, pod.Name, err)
continue
}

ioWeightValue, err := strconv.ParseInt(qosLevelDefaultValue, 10, 64)
if err != nil {
general.Warningf("strconv.ParseInt failed, string=%v, err=%v", qosLevelDefaultValue, err)
continue
}
err = cgroupmgr.ApplyIOWeightWithAbsolutePath(podAbsCGPath, defaultDevID, uint64(ioWeightValue))
if err != nil {
general.Errorf("ApplyIOWeightWithAbsolutePath for pod: %s/%s failed with error: %v",
pod.Namespace, pod.Name, err)
continue
} else {
general.Infof("ApplyIOWeightWithRelativePath for pod: %s/%s, weight: %d successfully",
pod.Namespace, pod.Name, ioWeightValue)
}
_ = emitter.StoreInt64(metricNameIOWeight, ioWeightValue, metrics.MetricTypeNameRaw,
metrics.ConvertMapToTags(map[string]string{
"cgPath": podAbsCGPath,
})...)

// setup contaienr level.
for _, containerStatus := range pod.Status.ContainerStatuses {
podUID, containerID := string(pod.UID), native.TrimContainerIDPrefix(containerStatus.ContainerID)
err := cgroupmgr.ApplyUnifiedDataForContainer(podUID, containerID, extraControlKnobConfigs[controlKnobKeyIOWeight].CgroupSubsysName, cgroupIOWeightName, qosLevelDefaultValue)
Expand All @@ -109,12 +138,6 @@ func applyIOWeightQoSLevelConfig(conf *coreconfig.Configuration,
continue
}

ioWeightValue, err := strconv.ParseInt(qosLevelDefaultValue, 10, 64)
if err != nil {
general.Warningf("strconv.ParseInt failed, string=%v, err=%v", qosLevelDefaultValue, err)
continue
}

_ = emitter.StoreInt64(metricNameIOWeight, ioWeightValue, metrics.MetricTypeNameRaw,
metrics.ConvertMapToTags(map[string]string{
"podUID": podUID,
Expand Down

0 comments on commit 462a158

Please sign in to comment.