kubeslice / kubeslice/kubeslice-controller
Bug: copier error in ReconcileWorkerSliceConfig logged but not returned — zero-value config written to cluster
- Dominant language
- Go
- Stars
- 73
- Forks
- 48
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 8
Description
### 📜 Description
In `ReconcileWorkerSliceConfig`, `copier.CopyWithOption` is used at line 230 to deep-copy `externalGatewayControllersConfig` into `externalGatewayConfig`. If the copy fails, the error is logged at line 234 but execution continues. At line 275, `workerSliceConfig.Spec.ExternalGatewayConfig = externalGatewayConfig` writes the zero-value (empty) struct to the Kubernetes API. Worker clusters then receive an empty external gateway config, silently losing all gateway configuration.
### 👟 Reproduction steps
1. Read `service/worker_slice_config_service.go:230-235` — error from `copier.CopyWithOption` is logged but not returned.
2. Read line 275 — `workerSliceConfig.Spec.ExternalGatewayConfig = externalGatewayConfig` unconditionally writes the result.
3. If `copier.CopyWithOption` fails at runtime, `externalGatewayConfig` remains as its zero value and overwrites real config on the worker slice.
### 👍 Expected behavior
If `copier.CopyWithOption` returns an error, `ReconcileWorkerSliceConfig` should return `ctrl.Result{}, err` immediately so the bad value is never written to Kubernetes.
### 👎 Actual Behavior
The error is logged and execution continues. A zero-value `ExternalGatewayConfig` is written to the worker slice config resource, silently erasing the real gateway configuration.
### 🐚 Relevant log output
```shell
```
### Version
main branch — run `git describe --tags` in the repo
### 🖥️ What operating system are you seeing the problem on?
Linux
### ✅ Proposed Solution
Change lines 233–235 from logging-and-continuing to returning the error:
```go
if err != nil {
return ctrl.Result{}, err
}
```
### 👀 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
Assessment
This issue has not been assessed yet.