Skip to content

Commit

Permalink
fix(operator/inventory): signal node out of inventory if unschedulable (
Browse files Browse the repository at this point in the history
akash-network#202)

Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian authored Feb 27, 2024
1 parent 5f10b77 commit ab0546e
Showing 1 changed file with 10 additions and 27 deletions.
37 changes: 10 additions & 27 deletions operator/inventory/node-discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,16 @@ func (dp *nodeDiscovery) monitor() error {
switch obj := evt.Object.(type) {
case *corev1.Node:
if obj.Name == dp.name {
currLabels = copyAkashLabels(obj.Labels)
signalLabels()
switch evt.Type {
case watch.Modified:
if obj.Spec.Unschedulable || obj.Status.Phase != corev1.NodeRunning {
currLabels = nil
} else {
currLabels = copyAkashLabels(obj.Labels)
}

signalLabels()
}
}
}
case res, isopen := <-podsWatch.ResultChan():
Expand Down Expand Up @@ -553,7 +561,6 @@ func (dp *nodeDiscovery) monitor() error {
if currPodsInitCount == 0 {
signalState()
}

case <-statech:
if len(currLabels) > 0 {
bus.Pub(nodeState{
Expand Down Expand Up @@ -654,30 +661,6 @@ func (dp *nodeDiscovery) initNodeInfo(gpusIds RegistryGPUVendors) (v1.Node, erro
}
}

// initPods := make(map[string]bool)

// podsList, err := kc.CoreV1().Pods(corev1.NamespaceAll).List(dp.ctx, metav1.ListOptions{
// FieldSelector: fields.OneTermEqualSelector("spec.nodeName", dp.name).String(),
// })
// if err != nil {
// return res, nil, err
// }

// if podsList == nil {
// return res, initPods, nil
// }

// for _, pod := range podsList.Items {
// for _, container := range pod.Spec.Containers {
// if container.Resources.Requests != nil {
// addAllocatedResources(&res, container.Resources.Requests)
// } else if container.Resources.Limits != nil {
// addAllocatedResources(&res, container.Resources.Limits)
// }
// }
// initPods[pod.Name] = true
// }

return res, nil
}

Expand Down

0 comments on commit ab0546e

Please sign in to comment.