Skip to content

Commit

Permalink
helper.ParseKatalystQOSEnhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
yanxiaoqi932 committed Dec 13, 2023
1 parent 41e2f5c commit bf5463b
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions pkg/config/generic/qos.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package generic

import (
"encoding/json"
"fmt"
"sync"

Expand Down Expand Up @@ -112,6 +111,7 @@ func NewQoSConfiguration() *QoSConfiguration {
// it works both for default katalyst QoS keys and expanded QoS keys.
func (c *QoSConfiguration) FilterQoSAndEnhancement(annotations map[string]string) (map[string]string, error) {
filteredAnnotations := c.FilterQoSMap(annotations)
wrappedEnhancements := c.GetQoSEnhancements(annotations)

c.RLock()
defer c.RUnlock()
Expand All @@ -121,26 +121,20 @@ func (c *QoSConfiguration) FilterQoSAndEnhancement(annotations map[string]string
validEnhancementKeyList = append(validEnhancementKeyList, enhancementExpandKey)
}

for _, enhancementKey := range validEnhancementKeyList {
if annotations[enhancementKey] != "" {
enhancementKVs := make(map[string]string)
for _, enhancementKey := range validQosEnhancementKey.List() {
if wrappedEnhancements[enhancementKey] != "" {
if enhancementKey != apiconsts.PodAnnotationMicroTopologyInterPodAffinity &&
enhancementKey != apiconsts.PodAnnotationMicroTopologyInterPodAntiAffinity {
err := json.Unmarshal([]byte(annotations[enhancementKey]), &enhancementKVs)
if err != nil {
return nil, fmt.Errorf("unmarshal %s: %s failed with error: %v",
enhancementKey, annotations[enhancementKey], err)
enhancementKVs := helper.ParseKatalystQOSEnhancement(wrappedEnhancements, annotations, enhancementKey)
for key, val := range enhancementKVs {
if filteredAnnotations[key] != "" {
general.Warningf("get enhancements %s:%s from %s, but the kv already exists: %s:%s",
key, val, enhancementKey, key, filteredAnnotations[key])
}
filteredAnnotations[key] = val
}
} else {
enhancementKVs[enhancementKey] = annotations[enhancementKey]
}

for key, val := range enhancementKVs {
if filteredAnnotations[key] != "" {
general.Warningf("get enhancements %s:%s from %s, but the kv already exists: %s:%s",
key, val, enhancementKey, key, filteredAnnotations[key])
}
filteredAnnotations[key] = val
filteredAnnotations[enhancementKey] = wrappedEnhancements[enhancementKey]
}

}
Expand Down

0 comments on commit bf5463b

Please sign in to comment.