Skip to content

Commit

Permalink
finalizer patch
Browse files Browse the repository at this point in the history
Signed-off-by: Bangqi Zhu <[email protected]>
  • Loading branch information
Bangqi Zhu committed Oct 28, 2024
1 parent bc8e411 commit fc7e596
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions pkg/controllers/ragengine_gc_finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ func (c *RAGEngineReconciler) garbageCollectRAGEngine(ctx context.Context, ragEn
}
}

staleWObj := ragEngineObj.DeepCopy()
staleWObj.SetFinalizers(nil)
if updateErr := c.Update(ctx, staleWObj, &client.UpdateOptions{}); updateErr != nil {
klog.ErrorS(updateErr, "failed to remove the finalizer from the ragengine",
"ragengine", klog.KObj(ragEngineObj), "ragengine", klog.KObj(staleWObj))
return ctrl.Result{}, updateErr
if controllerutil.RemoveFinalizer(ragEngineObj, consts.RAGEngineFinalizer) {
if updateErr := c.Update(ctx, ragEngineObj, &client.UpdateOptions{}); updateErr != nil {
klog.ErrorS(updateErr, "failed to remove the finalizer from the ragengine",
"ragengine", klog.KObj(ragEngineObj))
return ctrl.Result{}, updateErr
}
}

klog.InfoS("successfully removed the ragengine finalizers",
"ragengine", klog.KObj(ragEngineObj))
controllerutil.RemoveFinalizer(ragEngineObj, consts.RAGEngineFinalizer)
return ctrl.Result{}, nil
}
14 changes: 7 additions & 7 deletions pkg/controllers/workspace_gc_finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ func (c *WorkspaceReconciler) garbageCollectWorkspace(ctx context.Context, wObj
}
}

staleWObj := wObj.DeepCopy()
staleWObj.SetFinalizers(nil)
if updateErr := c.Update(ctx, staleWObj, &client.UpdateOptions{}); updateErr != nil {
klog.ErrorS(updateErr, "failed to remove the finalizer from the workspace",
"workspace", klog.KObj(wObj), "workspace", klog.KObj(staleWObj))
return ctrl.Result{}, updateErr
if controllerutil.RemoveFinalizer(wObj, consts.WorkspaceFinalizer) {
if updateErr := c.Update(ctx, wObj, &client.UpdateOptions{}); updateErr != nil {
klog.ErrorS(updateErr, "failed to remove the finalizer from the workspace",
"workspace", klog.KObj(wObj))
return ctrl.Result{}, updateErr
}
}

klog.InfoS("successfully removed the workspace finalizers",
"workspace", klog.KObj(wObj))
controllerutil.RemoveFinalizer(wObj, consts.WorkspaceFinalizer)
return ctrl.Result{}, nil
}

0 comments on commit fc7e596

Please sign in to comment.