Adding more detailed logging for Topology Hints

This commit is contained in:
Rob Scott 2021-09-02 15:46:14 -07:00
parent 295a8c1371
commit f24d917d3c
No known key found for this signature in database
GPG Key ID: D91A796D0CFF0C5D
2 changed files with 6 additions and 1 deletions

View File

@ -543,6 +543,7 @@ func (c *Controller) checkNodeTopologyDistribution() {
c.topologyCache.SetNodes(nodes)
serviceKeys := c.topologyCache.GetOverloadedServices()
for _, serviceKey := range serviceKeys {
klog.V(2).Infof("Queuing %s Service after Node change due to overloading", serviceKey)
c.queue.Add(serviceKey)
}
}

View File

@ -20,7 +20,7 @@ import (
"math"
"sync"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
discovery "k8s.io/api/discovery/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/klog/v2"
@ -132,6 +132,7 @@ func (t *TopologyCache) AddHints(si *SliceInfo) ([]*discovery.EndpointSlice, []*
// cache.
func (t *TopologyCache) SetHints(serviceKey string, addrType discovery.AddressType, allocatedHintsByZone EndpointZoneInfo) {
if len(allocatedHintsByZone) == 0 {
klog.V(2).Infof("No hints allocated for zones, removing them from %s EndpointSlices for %s Service", addrType, serviceKey)
t.RemoveHints(serviceKey, addrType)
return
}
@ -184,6 +185,7 @@ func (t *TopologyCache) SetNodes(nodes []*v1.Node) {
if !ok || zone == "" || nodeCPU.IsZero() {
cpuByZone = map[string]*resource.Quantity{}
sufficientNodeInfo = false
klog.Warningf("Can't get CPU or zone information for %s node", node.Name)
break
}
@ -199,6 +201,7 @@ func (t *TopologyCache) SetNodes(nodes []*v1.Node) {
defer t.lock.Unlock()
if totalCPU.IsZero() || !sufficientNodeInfo || len(cpuByZone) < 2 {
klog.V(2).Infof("Insufficient node info for topology hints (%d zones, %s CPU, %t)", len(cpuByZone), totalCPU.MilliValue(), sufficientNodeInfo)
t.sufficientNodeInfo = false
t.cpuByZone = nil
t.cpuRatiosByZone = nil
@ -219,6 +222,7 @@ func (t *TopologyCache) SetNodes(nodes []*v1.Node) {
// threshold, a nil value will be returned.
func (t *TopologyCache) getAllocations(numEndpoints int) map[string]Allocation {
if t.cpuRatiosByZone == nil || len(t.cpuRatiosByZone) < 2 || len(t.cpuRatiosByZone) > numEndpoints {
klog.V(2).Infof("Insufficient info to allocate endpoints (%d endpoints, %d zones)", numEndpoints, len(t.cpuRatiosByZone))
return nil
}