kubeslice / kubeslice/kubeslice-controller
Bug: Nil Pointer Dereference in validateClustersOnUpdate
- Dominant language
- Go
- Stars
- 73
- Forks
- 48
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 8
Description
### 📜 Description
`validateClustersOnUpdate` dereferences `cluster.Status.ClusterHealth` without a nil guard. When a newly added cluster has not yet reported health status, `ClusterHealth` is `nil` and accessing `.ClusterHealthStatus` on it causes a nil pointer dereference panic.
**File:** `service/slice_config_webhook_validation.go`
### 👟 Reproduction steps
1. Register a new cluster that has not yet reported its health status (`ClusterHealth` is `nil`).
2. Create or update a `SliceConfig` that adds this cluster to `spec.clusters`.
3. The admission webhook calls `validateClustersOnUpdate`.
4. The controller panics of `slice_config_webhook_validation.go`.
### 👍 Expected behavior
It should validate gracefully - either skip the health check when `ClusterHealth` is `nil` , or return a clear validation error.
### 👎 Actual Behavior
It panics with a nil pointer dereference, crashing the webhook admission handler and blocking all `SliceConfig` updates.
### 🐚 Relevant log output
```shell
panic: runtime error: invalid memory address or nil pointer dereference
goroutine [running]:
github.com/kubeslice/kubeslice-controller/service.validateClustersOnUpdate(...)
service/slice_config_webhook_validation.go
```
### Version
_No response_
### 🖥️ What operating system are you seeing the problem on?
_No response_
### ✅ Proposed Solution
_No response_
### 👀 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.