Skip to content

Commit

Permalink
Update after code review
Browse files Browse the repository at this point in the history
  • Loading branch information
mszadkow committed Nov 4, 2024
1 parent 275a18a commit d230cc6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
22 changes: 9 additions & 13 deletions pkg/cache/tas_flavor.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,17 @@ func (c *TASFlavorCache) snapshotForNodes(log logr.Logger, nodes []corev1.Node,
snapshot := newTASFlavorSnapshot(log, c.Levels)
nodeToDomain := make(map[string]utiltas.TopologyDomainID)
for _, node := range nodes {
ready := false
for _, cond := range node.Status.Conditions {
if ready := utiltas.IsNodeStatusConditionTrue(node.Status.Conditions, corev1.NodeReady, corev1.ConditionTrue); !ready {
// Only healthy and ready to accept pods nodes are considered for scheduling calculation
ready = (cond.Type == corev1.NodeReady && cond.Status == corev1.ConditionTrue)
}
if ready {
levelValues := utiltas.LevelValues(c.Levels, node.Labels)
capacity := resources.NewRequests(node.Status.Allocatable)
domainID := utiltas.DomainID(levelValues)
snapshot.levelValuesPerDomain[domainID] = levelValues
snapshot.addCapacity(domainID, capacity)
nodeToDomain[node.Name] = domainID
} else {
log.V(3).Info("Node was excluded from TAS Flavor snapshot", "nodeName", node.Name, "nodeStatusConditions", node.Status.Conditions)
log.V(3).Info("Node was excluded from TAS Flavor snapshot", "ready", ready)
continue
}
levelValues := utiltas.LevelValues(c.Levels, node.Labels)
capacity := resources.NewRequests(node.Status.Allocatable)
domainID := utiltas.DomainID(levelValues)
snapshot.levelValuesPerDomain[domainID] = levelValues
snapshot.addCapacity(domainID, capacity)
nodeToDomain[node.Name] = domainID
}
snapshot.initialize()
for domainID, usage := range c.usage {
Expand Down
11 changes: 11 additions & 0 deletions pkg/util/tas/tas.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package tas
import (
"strings"

corev1 "k8s.io/api/core/v1"

kueuealpha "sigs.k8s.io/kueue/apis/kueue/v1alpha1"
)

Expand Down Expand Up @@ -51,3 +53,12 @@ func Levels(topology *kueuealpha.Topology) []string {
}
return result
}

func IsNodeStatusConditionTrue(conditions []corev1.NodeCondition, conditionType corev1.NodeConditionType, conditionStatus corev1.ConditionStatus) bool {
for _, cond := range conditions {
if cond.Type == conditionType {
return cond.Status == conditionStatus
}
}
return false
}

0 comments on commit d230cc6

Please sign in to comment.