Skip to content

Commit

Permalink
Fix bug: cpu.usage and memory.usage not syncing
Browse files Browse the repository at this point in the history
  • Loading branch information
jrauh01 committed Jul 15, 2024
1 parent 3a2e108 commit e074d71
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
kcache "k8s.io/client-go/tools/cache"
"k8s.io/klog/v2"
"net"
"strings"
"sync"
"time"
)
Expand Down Expand Up @@ -200,10 +201,14 @@ func (pms *PromMetricSync) Nodes(ctx context.Context, informer kcache.SharedInde

nodeName := string(res.Metric["node"])
if nodeName == "" {
if host, _, err := net.SplitHostPort(string(res.Metric["instance"])); err == nil {
nodeName = host
if strings.Contains(string(res.Metric["instance"]), ":") {
if host, _, err := net.SplitHostPort(string(res.Metric["instance"])); err == nil {
nodeName = host
} else {
continue
}
} else {
continue
nodeName = string(res.Metric["instance"])
}
}
uuid, exists := nodes.Load(nodeName)
Expand Down

0 comments on commit e074d71

Please sign in to comment.