status_changed

Function status_changed 

Source
pub fn status_changed<T: PartialEq>(
    current_value: &Option<T>,
    new_value: &Option<T>,
) -> bool
Expand description

Check if a status value has actually changed compared to the current status.

This helper prevents unnecessary status updates that would trigger reconciliation loops. It compares a new status value with the existing status and returns true only if they differ, indicating an update is needed.

§Arguments

  • current_value - The current status value (from existing resource)
  • new_value - The new status value to potentially set

§Returns

  • true - Status has changed and needs updating
  • false - Status is unchanged, skip the update

§Example

use bindy::reconcilers::status_changed;

let current_ready = instance.status.as_ref()
    .and_then(|s| s.ready_replicas);
let new_ready = Some(3);

if status_changed(&current_ready, &new_ready) {
    // Status has changed, safe to update
    update_status(client, instance, new_ready).await?;
}

§Why This Matters

In kube-rs, status updates trigger “object updated” events which cause new reconciliations. Without this check, updating status on every reconciliation creates a tight loop:

  1. Reconcile → Update status
  2. Status update → “object updated” event
  3. Event → New reconciliation
  4. Repeat from step 1 (infinite loop)

By only updating when status actually changes, we break this cycle.