Skip to content

Commit 042f956

Browse files
authored
account for all covered resources when a node is cordoned (#239)
1 parent f5d8153 commit 042f956

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

internal/controller/appwrapper/node_health_monitor.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,11 @@ func (r *NodeHealthMonitor) Reconcile(ctx context.Context, req ctrl.Request) (ct
115115
// update unschedulable resource quantities for this node
116116
flaggedQuantities := make(map[string]*resource.Quantity)
117117
if node.Spec.Unschedulable {
118-
// flag all configured resources if the node is cordoned
119-
for resourceName := range r.Config.Autopilot.ResourceTaints {
120-
flaggedQuantities[resourceName] = node.Status.Capacity.Name(v1.ResourceName(resourceName), resource.DecimalSI)
118+
// flag all non-pod resources covered by cq if the node is cordoned
119+
for _, resourceName := range cq.Spec.ResourceGroups[0].Flavors[0].Resources {
120+
if string(resourceName.Name) != "pods" {
121+
flaggedQuantities[string(resourceName.Name)] = node.Status.Capacity.Name(resourceName.Name, resource.DecimalSI)
122+
}
121123
}
122124
} else {
123125
for key, value := range node.GetLabels() {
@@ -173,15 +175,19 @@ func (r *NodeHealthMonitor) Reconcile(ctx context.Context, req ctrl.Request) (ct
173175
}
174176

175177
// update lending limits
176-
var err error
177178
if limitsChanged {
178-
err = r.Update(ctx, cq)
179+
err := r.Update(ctx, cq)
179180
if err == nil {
180181
log.FromContext(ctx).Info("Updated lending limits", "Resources", resources)
182+
return ctrl.Result{}, nil
183+
} else if errors.IsConflict(err) {
184+
return ctrl.Result{Requeue: true}, nil
185+
} else {
186+
return ctrl.Result{}, err
181187
}
182188
}
183189

184-
return ctrl.Result{}, err
190+
return ctrl.Result{}, nil
185191
}
186192

187193
// SetupWithManager sets up the controller with the Manager.

0 commit comments

Comments
 (0)