Skip to content

Commit

Permalink
feat(eviction): add qos tag
Browse files Browse the repository at this point in the history
  • Loading branch information
nightmeng committed Jan 23, 2024
1 parent 3c06012 commit 6fa9116
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions pkg/agent/evictionmanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package evictionmanager // import "github.com/kubewharf/katalyst-core/pkg/evicti
import (
"context"
"fmt"
"github.com/kubewharf/katalyst-core/pkg/config/generic"
"strconv"
"sync"
"time"
Expand Down Expand Up @@ -348,7 +349,7 @@ func (m *EvictionManger) doEvict(softEvictPods, forceEvictPods map[string]*rule.
general.Infof(" evict %d pods in evictionmanager", len(rpList))
_ = m.emitter.StoreInt64(MetricsNameVictimPodCNT, int64(len(rpList)), metrics.MetricTypeNameRaw,
metrics.MetricTag{Key: "type", Val: "total"})
metricPodsToEvict(m.emitter, rpList)
metricPodsToEvict(m.emitter, rpList, m.conf.GenericConfiguration.QoSConfiguration)
}

// ValidatePlugin validates a plugin if the version is correct and the name has the format of an extended resource
Expand Down Expand Up @@ -608,19 +609,27 @@ func logConfirmedThresholdMet(thresholds map[string]*pluginapi.ThresholdMetRespo
}
}

func metricPodsToEvict(emitter metrics.MetricEmitter, rpList rule.RuledEvictPodList) {
func metricPodsToEvict(emitter metrics.MetricEmitter, rpList rule.RuledEvictPodList, qosConfig *generic.QoSConfiguration) {
if emitter == nil {
general.Errorf(" metricPodsToEvict got nil emitter")
return
}

for _, rp := range rpList {
if rp != nil && rp.EvictionPluginName != "" {
_ = emitter.StoreInt64(MetricsNameVictimPodCNT, 1, metrics.MetricTypeNameRaw,
metrics.MetricTag{Key: "name", Val: rp.EvictionPluginName},
metrics.MetricTag{Key: "type", Val: "plugin"},
metrics.MetricTag{Key: "victim_ns", Val: rp.Pod.Namespace},
metrics.MetricTag{Key: "victim_name", Val: rp.Pod.Name})
metricTags := []metrics.MetricTag{
{Key: "name", Val: rp.EvictionPluginName},
{Key: "type", Val: "plugin"},
{Key: "victim_ns", Val: rp.Pod.Namespace},
{Key: "victim_name", Val: rp.Pod.Name},
}
if qosConfig != nil {
qosLevel, err := qosConfig.GetQoSLevelForPod(rp.Pod)
if err == nil {
metricTags = append(metricTags, metrics.MetricTag{Key: "qos", Val: qosLevel})
}
}
_ = emitter.StoreInt64(MetricsNameVictimPodCNT, 1, metrics.MetricTypeNameRaw, metricTags...)
}
}
}

0 comments on commit 6fa9116

Please sign in to comment.