kubeslice / kubeslice/worker-operator

Bug: `NetpolReconciler.Compare` uses `context.Background()` instead of the reconcile context

Open
#491 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

`pkg/networkpolicy/reconciler.go`, `Compare` method, uses `context.Background()` for all Kubernetes API calls (lines 152, 157, 170, 183, 199). The reconcile context (`ctx`) carries a deadline, logger, and cancellation signal. Using `context.Background()` bypasses the reconcile timeout and loses structured logging, making it impossible to correlate log lines with a specific reconcile run.

### 👟 Reproduction steps

Read `pkg/networkpolicy/reconciler.go` — every `client.List` inside `Compare` uses `context.Background()`.

### 👍 Expected behavior

All API calls inside `Compare` should use the `ctx` parameter passed into `Reconcile`.

### 👎 Actual Behavior

Calls use `context.Background()`, stripping deadline and request context.

### 🐚 Relevant log output

```shell

```

### Version

_No response_

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

_No response_

### ✅ Proposed Solution

Pass `ctx` through `Compare` and replace every `context.Background()` call in it with `ctx`.

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