Skip to content

Commit

Permalink
operator: patch cluster before checking for cnpg.io/hibernation (#1039
Browse files Browse the repository at this point in the history
)
  • Loading branch information
vrmiguel authored Nov 12, 2024
1 parent 9997dd9 commit b91608d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tembo-operator/src/cloudnativepg/hibernate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@ pub async fn reconcile_cluster_hibernation(cdb: &CoreDB, ctx: &Arc<Context>) ->
return Err(action);
}

patch_cluster_merge(cdb, ctx, patch_hibernation_annotation).await?;
info!(
"Toggled hibernation annotation of {} to '{}'",
name, hibernation_value
);
info!(
"Toggled CNPG reconcilation annotation of {} to '{}'",
name, stop_cnpg_reconciliation_value
);

// Check the annotation we are about to match was already there
if let Some(current_hibernation_setting) = cluster_annotations.get("cnpg.io/hibernation") {
if current_hibernation_setting == hibernation_value {
Expand All @@ -206,11 +216,6 @@ pub async fn reconcile_cluster_hibernation(cdb: &CoreDB, ctx: &Arc<Context>) ->
return Ok(());
}
}
patch_cluster_merge(cdb, ctx, patch_hibernation_annotation).await?;
info!(
"Toggled hibernation annotation of {} to '{}'",
name, hibernation_value
);

let mut status = cdb.status.clone().unwrap_or_default();
status.running = !cdb.spec.stop;
Expand Down

0 comments on commit b91608d

Please sign in to comment.