Skip to content

Commit

Permalink
Fix: Clear status for bound services when exit node deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
korewaChino committed Dec 26, 2023
1 parent a906df7 commit 310efa4
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,6 @@ async fn reconcile_nodes(obj: Arc<ExitNode>, ctx: Arc<Context>) -> Result<Action
let nodes: Api<ExitNode> =
Api::namespaced(ctx.client.clone(), &obj.namespace().unwrap());


let exitnode_patch = serde_json::json!({
"status": None::<ExitNodeStatus>
});
Expand Down Expand Up @@ -689,6 +688,35 @@ async fn reconcile_nodes(obj: Arc<ExitNode>, ctx: Arc<Context>) -> Result<Action
Event::Cleanup(node) => {
info!("Cleanup finalizer triggered for {}", node.name_any());

// Okay, now we should also clear the service status if this node has a service binding

if let Some(status) = node.status {
if let Some(binding) = status.service_binding {
info!("Clearing service binding for {}", node.name_any());

// get service API
let services: Api<Service> =
Api::namespaced(ctx.client.clone(), &binding.namespace);

let patch = serde_json::json!({
"status": {
"load_balancer": None::<LoadBalancerStatus>
}
});

let _svc = services
.patch_status(
// We can unwrap safely since Service is guaranteed to have a name
&binding.name,
&serverside.clone(),
&Patch::Merge(patch),
)
.await?;

info!("Cleared service binding for {}", node.name_any());
}
}

if is_managed {
info!("Deleting cloud resource for {}", node.name_any());
provisioner_api
Expand Down

0 comments on commit 310efa4

Please sign in to comment.