kubeslice / kubeslice/kubeslice-controller
Bug: RemoveWorkerFinalizers swallows UpdateResource error, causing finalizer leak
- Dominant language
- Go
- Stars
- 73
- Forks
- 48
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 8
Description
### 📜 Description
`RemoveWorkerFinalizers` in `service/service_helper.go` (line 64) logs but does not return the error from `util.UpdateResource`. The function signature returns only `ctrl.Result` with no error value. Three reconcilers call this function and proceed with deletion-path logic even if the finalizer removal failed, potentially leaving objects stuck in `Terminating` state forever.
### 👟 Reproduction steps
1. Open `service/service_helper.go`.
2. Locate `RemoveWorkerFinalizers` (L38). Observe the function signature returns `ctrl.Result` (no error).
3. On L64, observe `util.UpdateResource` error is logged with `logger.Errorf` but not returned.
4. Check the three callers:
- `worker_slice_gateway_service.go` L105
- `worker_slice_config_service.go` L90
- `worker_service_import_service.go` L88
5. All three proceed with `if result.Requeue` and then deletion logic, never checking for an error from finalizer removal.
### 👍 Expected behavior
If `util.UpdateResource` fails (e.g., conflict error from ResourceVersion mismatch), the error should be returned to the caller so the controller-runtime requeues the reconciliation and retries the finalizer removal.
### 👎 Actual Behavior
The error is swallowed. The caller proceeds to delete dependent resources (secrets, paired gateways, service imports) while the finalizer is still present on the object. The object is stuck in `Terminating` state because the API server refuses to GC it with outstanding finalizers, but the dependent resources have already been cleaned up.
### 🐚 Relevant log output
```shell
# The error IS logged but not acted upon:
"Failed to cleanup finalizers" error="Operation cannot be fulfilled on workerslicegateways.worker.kubeslice.io \"gw-xxx\": the object has been modified; please apply your changes to the latest version and try again"
```
### Version
master branch (latest HEAD as of 2026-05-14). Affects all branches.
### 🖥️ What operating system are you seeing the problem on?
_No response_
### ✅ Proposed Solution
Change the function signature from `ctrl.Result` to `(ctrl.Result, error)` and propagate the error to all three callers so they trigger a requeue on failure.
### 👀 Have you spent some time to check if this issue has been raised before?
- [x] I checked and didn't find any similar issue
### Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Contributor guide
Research direction
Start in service/service_helper.go at RemoveWorkerFinalizers, then trace its callers in worker_slice_gateway_service.go, worker_slice_config_service.go, and worker_service_import_service.go. Verify how util.UpdateResource failures are handled and confirm that all three deletion paths propagate the error and requeue instead of continuing after finalizer removal fails.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100