Skip to content

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

Description

@mdryaaan

📜 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

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?

  • I checked and didn't find any similar issue

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions