Skip to content

Refactor(webhook): remove AgentRuntimeOverrides from injection path#427

Open
r3v5 wants to merge 3 commits into
kagenti:mainfrom
r3v5:remove-ar-overrides-from-webhook
Open

Refactor(webhook): remove AgentRuntimeOverrides from injection path#427
r3v5 wants to merge 3 commits into
kagenti:mainfrom
r3v5:remove-ar-overrides-from-webhook

Conversation

@r3v5

@r3v5 r3v5 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Remove per-workload AgentRuntime CR override layer from the mutating webhook, aligning with the controller's 2-layer config model (platform defaults + namespace ConfigMap)
  • Eliminate List AgentRuntime API call on the webhook hot path (every pod CREATE)
  • Simplify ResolveConfig from 3-param to 2-param, delete agentruntime_config.go entirely

Changes

Deleted:

  • agentruntime_config.goAgentRuntimeOverrides struct, ReadAgentRuntimeOverrides(), extractOverrides()
  • agentruntime_config_test.go — all AR config tests

Modified:

  • pod_mutator.go — removed AR override call, AllowedAudiences injection, AR branches from mTLS/mode resolution
  • resolved_config.go — simplified ResolveConfig to 2-layer (platform + namespace)
  • constants.go — updated comments to reflect 2-layer model
  • container_builder.go — updated ResolveConfig call signature
  • pod_mutator_test.go — switched from CR-based to namespace ConfigMap-based mode selection
  • resolved_config_test.go — removed AR-specific tests
  • authbridge_webhook_test.go — updated integration test to use namespace ConfigMap

Motivation

The controller already uses a 2-layer model (cluster + namespace). This aligns the webhook to the same model. No clusters use AR overrides today. The CRD describes AllowedAudiences as "transitional" (ref).

Test plan

  • go build ./... — clean compilation
  • go test ./... — all unit/integration tests pass (excluding e2e which needs Kind)
  • grep -r "AgentRuntimeOverrides" internal/webhook/ — zero references remain
  • Kind cluster integration test with Helm-deployed operator:
    • Default proxy-sidecar mode via Deployment (no ConfigMap, no AR) → authbridge-proxy injected
    • Namespace ConfigMap mode: envoy-sidecarenvoy-proxy injected
    • AgentRuntime CR authBridgeMode: waypoint ignored → pod mutated with default proxy-sidecar
    • Operator logs show zero AR lookup references

Ref: RHAIENG-4936

🤖 Generated with Claude Code

r3v5 added 3 commits June 12, 2026 15:07
…n path

Remove the per-workload AgentRuntime CR override layer from the mutating
webhook, aligning it with the controller's 2-layer config model
(platform defaults + namespace ConfigMap).

- Delete agentruntime_config.go (AgentRuntimeOverrides struct,
  ReadAgentRuntimeOverrides, extractOverrides)
- Remove AllowedAudiences injection from per-agent ConfigMap
- Remove AR branches from mTLS and authBridgeMode resolution chains
- Simplify ResolveConfig from 3-param to 2-param signature
- Remove injectAllowedAudiences helper function
- Update constants.go comments to reflect 2-layer model
- Remove slices and agentv1alpha1 imports from webhook injector

This eliminates a List AgentRuntime API call on the webhook hot path
(every pod CREATE), reducing webhook latency. No clusters use AR
overrides today; the CRD describes AllowedAudiences as "transitional".

Ref: RHAIENG-4936

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Ian Miller <milleryan2003@gmail.com>
Update all webhook tests to match the 2-layer config model (platform +
namespace only, no AgentRuntime CR overrides).

- Remove newAgentRuntime and newAgentRuntimeWithMode test helpers
- Remove agentv1alpha1 import and scheme registration from tests
- Switch mode-selection tests from CR-based to namespace ConfigMap-based
- Rename CRBeatsNamespaceConfigMap → NamespaceConfigMapWinsOverCR
- Rename CRBeatsAnnotation → AnnotationWinsOverCR
- Remove AllowedAudiences injection test cases
- Update integration test to create namespace ConfigMap instead of
  AgentRuntime CR for envoy-sidecar mode selection
- Simplify ResolveConfig tests to 2-param signature

Ref: RHAIENG-4936

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Ian Miller <milleryan2003@gmail.com>
Update pod_mutator_test.go to match production code changes from the
AgentRuntimeOverrides removal.

- Remove newAgentRuntime and newAgentRuntimeWithMode test helpers
- Remove agentv1alpha1 import and scheme registration
- Switch mode-selection tests from CR-based to namespace ConfigMap-based
- Rename CRBeatsNamespaceConfigMap → NamespaceConfigMapWinsOverCR
- Rename CRBeatsAnnotation → AnnotationWinsOverCR
- Remove AllowedAudiences injection test cases
- Remove allowedAudiences param from ensurePerAgentConfigMap calls

Ref: RHAIENG-4936

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Ian Miller <milleryan2003@gmail.com>
@r3v5 r3v5 requested a review from a team as a code owner June 12, 2026 14:15
@r3v5 r3v5 changed the title refactor(webhook): remove AgentRuntimeOverrides from injection path Refactor(webhook): remove AgentRuntimeOverrides from injection path Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant