Skip to content

Commit 37b7627

Browse files
pgoronPeter Goron
and
Peter Goron
authoredDec 12, 2024
discard not yet reconciliated node disruption (#73)
adb and ndb controllers are reporting information about node disruption not yet reconciliated, for which state is still unknown. It breaks contract of adb/ndb object status where reported nd should have a valid status. Co-authored-by: Peter Goron <[email protected]>
1 parent f1470c9 commit 37b7627

4 files changed

+12
-1
lines changed
 

‎api/v1alpha1/nodedisruption_types.go

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type NamespacedName struct {
3636
type NodeDisruptionState string
3737

3838
const (
39+
Unknown NodeDisruptionState = ""
3940
Pending NodeDisruptionState = "pending"
4041
Granted NodeDisruptionState = "granted"
4142
Rejected NodeDisruptionState = "rejected"

‎internal/controller/applicationdisruptionbudget_controller.go

+5
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,11 @@ func (r *ApplicationDisruptionBudgetResolver) ResolveDisruption(ctx context.Cont
294294
}
295295

296296
for _, nd := range nodeDisruptions.Items {
297+
if nd.Status.State == nodedisruptionv1alpha1.Unknown {
298+
// node disruption has just been created and hasn't been reconciliated yet
299+
continue
300+
}
301+
297302
impactedNodes, err := r.Resolver.GetNodeFromNodeSelector(ctx, nd.Spec.NodeSelector)
298303
if err != nil {
299304
return 0, disruptions, err

‎internal/controller/nodedisruption_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func (ndr *SingleNodeDisruptionReconciler) Reconcile(ctx context.Context) (err e
186186
func (ndr *SingleNodeDisruptionReconciler) TryTransitionState(ctx context.Context) (err error) {
187187
logger := log.FromContext(ctx)
188188
// If the state is unknown, switch it to Pending
189-
if ndr.NodeDisruption.Status.State == "" {
189+
if ndr.NodeDisruption.Status.State == nodedisruptionv1alpha1.Unknown {
190190
ndr.NodeDisruption.Status.State = nodedisruptionv1alpha1.Pending
191191

192192
return err

‎internal/controller/nodedisruptionbudget_controller.go

+5
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ func (r *NodeDisruptionBudgetResolver) ResolveDisruption(ctx context.Context) (i
240240
}
241241

242242
for _, nd := range nodeDisruptions.Items {
243+
if nd.Status.State == nodedisruptionv1alpha1.Unknown {
244+
// node disruption has just been created and hasn't been reconciliated yet
245+
continue
246+
}
247+
243248
impactedNodes, err := r.Resolver.GetNodeFromNodeSelector(ctx, nd.Spec.NodeSelector)
244249
if err != nil {
245250
return 0, disruptions, err

0 commit comments

Comments
 (0)