Skip to content

Commit

Permalink
discard not yet reconciliated node disruption
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Peter Goron committed Dec 12, 2024
1 parent f1470c9 commit 14e7b82
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/v1alpha1/nodedisruption_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type NamespacedName struct {
type NodeDisruptionState string

const (
Unknown NodeDisruptionState = ""
Pending NodeDisruptionState = "pending"
Granted NodeDisruptionState = "granted"
Rejected NodeDisruptionState = "rejected"
Expand Down
5 changes: 5 additions & 0 deletions internal/controller/applicationdisruptionbudget_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ func (r *ApplicationDisruptionBudgetResolver) ResolveDisruption(ctx context.Cont
}

for _, nd := range nodeDisruptions.Items {
if nd.Status.State == nodedisruptionv1alpha1.Unknown {
// node disruption has just been created and hasn't been reconciliated yet
continue
}

impactedNodes, err := r.Resolver.GetNodeFromNodeSelector(ctx, nd.Spec.NodeSelector)
if err != nil {
return 0, disruptions, err
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/nodedisruption_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (ndr *SingleNodeDisruptionReconciler) Reconcile(ctx context.Context) (err e
func (ndr *SingleNodeDisruptionReconciler) TryTransitionState(ctx context.Context) (err error) {
logger := log.FromContext(ctx)
// If the state is unknown, switch it to Pending
if ndr.NodeDisruption.Status.State == "" {
if ndr.NodeDisruption.Status.State == nodedisruptionv1alpha1.Unknown {
ndr.NodeDisruption.Status.State = nodedisruptionv1alpha1.Pending

return err
Expand Down
5 changes: 5 additions & 0 deletions internal/controller/nodedisruptionbudget_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ func (r *NodeDisruptionBudgetResolver) ResolveDisruption(ctx context.Context) (i
}

for _, nd := range nodeDisruptions.Items {
if nd.Status.State == nodedisruptionv1alpha1.Unknown {
// node disruption has just been created and hasn't been reconciliated yet
continue
}

impactedNodes, err := r.Resolver.GetNodeFromNodeSelector(ctx, nd.Spec.NodeSelector)
if err != nil {
return 0, disruptions, err
Expand Down

0 comments on commit 14e7b82

Please sign in to comment.