kubeslice / kubeslice/worker-operator

Bug: `controllers.GetSlice` returns error on NotFound instead of (nil, nil)

Open
#482 0 comments 0 reactions 4 assignees Claimed by @richiesebastian View on GitHub
bug
Dominant language
Go
Stars
62
Forks
33
Avg merge
3d 10h
Merged PRs (30d)
3

Description

### 📜 Description

`controllers/controller.go`, `GetSlice` (line 51–63) returns the raw error from `c.Get(...)` including `IsNotFound` errors. Callers in `slicegateway/reconciler.go` (line 122–131) handle `slice == nil` as the not-found case, but `GetSlice` never returns `(nil, nil)` — it only returns `(nil, err)`. The `slice == nil` branch is dead code; a not-found Get call returns `(nil, NotFoundError)`, which takes the error path, not the `slice == nil` path.

### 👟 Reproduction steps

1. Call `GetSlice` when the slice doesn't exist yet.
2. Observe `(nil, &NotFoundError{})` — the `slice == nil` + `RequeueAfter: 10*time.Second` path in the slicegateway reconciler is never taken.

### 👍 Expected behavior

`GetSlice` should return `(nil, nil)` on `IsNotFound` so callers can distinguish "not found" from "API error".

### 👎 Actual Behavior

NotFound errors propagate as real errors, causing the slicegateway reconciler to return an error rather than a graceful requeue.

### 🐚 Relevant log output

```shell

```

### Version

_No response_

### 🖥️ What operating system are you seeing the problem on?

_No response_

### ✅ Proposed Solution

Add `if errors.IsNotFound(err) { return nil, nil }` in `GetSlice`.

### 👀 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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.