Files
alex bezek 962d5d7720 Fix/k8sop 251 agent driver util (#802)
* fix(agent): pass caller context to Forward() — bug 2.7

Forward() was called with context.Background(), ignoring the
reconciler's context. Shutdown cancellation now propagates
correctly.

Bug-ID: 2.7

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(agent): protect d.done channel close with sync.Once — bug 2.23

Multiple Stop/Restart RPCs from the ngrok backend could trigger
close() on an already-closed channel, causing a panic. Wrapped
in sync.Once for safety.

Bug-ID: 2.23

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(agent): clear stale TrafficPolicyApplied condition on policy removal — bug 2.15

When a traffic policy was removed from an AgentEndpoint, the stale
TrafficPolicyApplied=False condition was never cleared, permanently
blocking Ready=True.

Bug-ID: 2.15

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(util): add missing return and fix doc comment in mergeEnabled — bug 2.22

Added early return when t.enabled is nil to prevent redundant
fallthrough. Fixed doc comment that incorrectly described the
merge behavior.

Bug-ID: 2.22

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor(agent): move RemoveStatusCondition into updateStatus

Move the stale TrafficPolicy condition cleanup from the controller's
update() method into updateStatus(), consistent with how all other
controllers handle condition lifecycle in their status update path.

Remove the now-redundant StaleTrafficPolicyConditionCleared test since
TestCalculateAgentEndpointReadyCondition_TrafficPolicyNotSet already
covers the case where the condition is absent.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(agent): fold condition cleanup into existing else branch

Remove redundant if trafficPolicy == "" check — already handled by
the else branch of the same condition above.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(tests): apply go fix modernizations

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(agent): don't remove TrafficPolicy condition when policy fails to resolve

The RemoveStatusCondition call in updateStatus was removing the
ConditionTrafficPolicy condition that getTrafficPolicy had just set
when a referenced policy was missing. This happened because a failed
policy lookup returns trafficPolicy="" which hit the else branch.

Now only clears the condition when no policy is configured at all
(Spec.TrafficPolicy == nil), preserving the error condition when a
configured policy fails to resolve.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address PR feedback

- Move newBaseTrafficPolicy doc comment to the function itself
- Revert Forward(ctx) back to Forward(context.Background()) — the reconciler
  context gets cancelled when reconciliation returns, which would stop the
  forwarder's background goroutine

* Add comment about why we use background context for agent.Forward

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Jonathan Stacks <jonstacks@users.noreply.github.com>
2026-04-24 19:38:58 +00:00
..